Is there a portable way to determine whether a type is functor ?
Hi all,
The following code only works under g++ 4.x:
#include
AMDG ancode tran wrote:
Hi all,
The following code only works under g++ 4.x:
#include
template <class T> struct is_functor_helper { static boost::type_traits::no_type test (...); template <class U> static boost::type_traits::yes_type test (U*, typeof(&U::operator()) dummy = NULL); BOOST_STATIC_CONSTANT (bool, value = sizeof(test((T*)NULL)) == sizeof(boost::type_traits::yes_type)); };
template <class T> struct is_functor: public boost::integral_constant
{ }; Can anyone give me a hint to make it work under other toolset, please ? Thanks in advance.
That won't work with an overloaded or templated operator(). In general, there is no way to determine whether an operator() exists. If you want to determine whether a type can be called with particular parameters see http://www.boost.org/doc/html/proto/appendices.html#boost_proto.appendices.i... In Christ, Steven Watanabe
participants (2)
-
ancode tran
-
Steven Watanabe