【发布时间】:2012-09-04 15:59:18
【问题描述】:
以下代码在 gcc 中没有问题。在 VS 2010 express 中它失败了
------ Build started: Project: helium, Configuration: Debug Win32 ------
testvs.cpp
..\..\helium\src\legacy\testvs.cpp(21): error C2664: 'ulink' : cannot convert parameter 1 from 'VP<T>' to 'VP<T> &'
with
[
T=F
]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
对于任何 Visual Studio 版本都一样,还是仅限于 vs 2010 的问题? 如果删除第二个 operator() 定义,问题就消失了
template<typename T> struct S{
void operator()(T&){}
void operator()(){}
};
template <typename T,typename G=typename T::GP,void (S<T>::*f)(T&) =&S<T>::operator() > struct VP{
void fa(){}
};
template<typename T> void ulink( VP<T >& v){}
struct F{
typedef int GP;
};
void f(){
VP<F> vps;
ulink(vps);
}
【问题讨论】:
-
@SethCarnegie 你在哪里测试的?
-
我知道它并没有违反任何 C++ 规则,也确认一下,ideone.com/nDoVO
-
谢谢,我只是想知道,我应该更新到 vs 2012 还是问题仍然存在?
-
不,它在 VS 2012 中也被破坏了。
-
@SethCarnegie:- `它没有违反 C++ 的任何规则`,但它打破了 VS 的脊梁;)
标签: c++ visual-studio templates