Boost logo

Boost Users :

Subject: [Boost-users] Is there a portable way to determine whether a type is functor ?
From: ancode tran (ancodecpp_at_[hidden])
Date: 2008-12-26 16:36:50


Hi all,

The following code only works under g++ 4.x:

#include <boost/type_traits.hpp>

 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<bool, is_functor_helper<T>::value> { };

Can anyone give me a hint to make it work under other toolset, please ?
Thanks in advance.

Regards,
Trung An Tran
       
---------------------------------
  Hãy cùng chat vá»›i bạn bè trên Yahoo! Pingbox má»›i toanh!
 Tạo má»™t không gian riêng để chat trên blog là chuyện nhỏ.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net