Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Detecting if a tag is a proto type or not
From: Eric Niebler (eric_at_[hidden])
Date: 2008-11-17 11:35:31

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 {};


Eric Niebler
BoostPro Computing

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at