[Proto] Detecting if a tag is a proto type or not

I want to do some dispatching based on the fatc that my binary_expr tag is one of predefined proto tag or not. What kind of internal properties of proto tags can I try to use to perform this discrimination ? Thanks in advance

Joel Falcou wrote:
I want to do some dispatching based on the fatc that my binary_expr tag is one of predefined proto tag or not. What kind of internal properties of proto tags can I try to use to perform this discrimination ?
Well, they're defined in the boost::proto::tag namespace. You can play tricks with ADL and sizeof.... -- Eric Niebler BoostPro Computing http://www.boostpro.com

Joel Falcou wrote:
Eric Niebler a écrit :
Well, they're defined in the boost::proto::tag namespace. You can play tricks with ADL and sizeof....
Care to elaborate a few ?
Something like this: namespace boost { namespace proto { namespace tag { template<typename T> char check_is_proto_tag(T); }}} namespace not_proto { char (&check_is_proto_tag(...))[2]; } using not_proto::check_is_proto_tag; template<typename T> struct is_proto_tag : boost::mpl::bool_<sizeof(check_is_proto_tag(T()))==1> {}; struct not_proto_tag {}; BOOST_MPL_ASSERT((is_proto_tag<boost::proto::tag::plus>)); BOOST_MPL_ASSERT_NOT((is_proto_tag<not_proto_tag>)); -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (2)
-
Eric Niebler
-
Joel Falcou