
6 Oct
2008
6 Oct
'08
11:02 a.m.
Mathias Gaunard a écrit :
As of today, in GCC 4.4, you can do something equivalent but have to be significantly more verbose:
template<typename T, size_t Cond> struct foo_type { typedef decltype(((T*)0)->foo()) type; };
template<typename T> typename foo_type<T, sizeof(((T*)0)->foo() > 0)>::type foo(T&& t) { return t.foo(); }
(You cannot put decltype directly in the return type because of name mangling issues)
Can't this be packaged into some macro like BOOST_HAS_XXX ?