次のコードは 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に限定された問題ですか? 2 番目の 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);
}