H
huili80
The code attached compiles with gcc4.8 and above, however, gcc4.3 fails to compile, and i hope to find a workaround for gcc4.3 since that's currently the only compiler available to me (at work, that is).
The non-compile appears to be a gcc4.3 issue (bug maybe?), where a substitution failure, i.e., the instantiation of test<X> when calling f<X>(0), is mistakenly being treated as an error.
As for the code itself, since i'm using gcc4.3 which doesn't have c++11, therefore no decltype, so i had to use the gcc extension typeof, which is really the only thing non-standard about it.
I'd very much appreciate any help. Thanks!
code here:
-------------------------------
template < typename T > T& obj();
template < typename T, typename=typeof(obj<T>().memfun()) >
struct test {};
template < typename T > test<T> f(int){}
template <typename> char f(...){}
struct X
{
void memfun(int){};
};
int main()
{
f<X>(0);
}
The non-compile appears to be a gcc4.3 issue (bug maybe?), where a substitution failure, i.e., the instantiation of test<X> when calling f<X>(0), is mistakenly being treated as an error.
As for the code itself, since i'm using gcc4.3 which doesn't have c++11, therefore no decltype, so i had to use the gcc extension typeof, which is really the only thing non-standard about it.
I'd very much appreciate any help. Thanks!
code here:
-------------------------------
template < typename T > T& obj();
template < typename T, typename=typeof(obj<T>().memfun()) >
struct test {};
template < typename T > test<T> f(int){}
template <typename> char f(...){}
struct X
{
void memfun(int){};
};
int main()
{
f<X>(0);
}