The following code has no problems in gcc. in VS 2010 express it fails giving
------ 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 ==========
In it the same for any visual studio version or is it a problem limited to vs 2010?
The problem disappears if the second operator() definition is removed
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);
}
Thanks to Seth Carnegie for confirming that this is yet another VS unsolved bug.
Possible workarounds
1) include in another structure
2) keep the template more generic