Boost logo

Boost :

Subject: Re: [boost] [MPL] RFC: An MPL macro to define a has_member_xxx<T> predicate
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-10-31 12:53:45


On 10/31/2013 09:36 AM, Erik Erlandson wrote:
> If there's already a boost solution for this, then I have egg on my face, but I can't find one:

Look at tti:

> I'd like an MPL macro that defines a predicate template which inherits from boost::true_type iff the given type defines *any* member with a particular name (false_type otherwise), and which does not assume the member name exists, like this:
> struct my_class {
> // foo might be member data, member function, a typedef, etc:
> int foo;
> };
> has_member_foo<my_class> t1; // this inherits from true_type
> has_member_bar<my_class> t2; // this inherits from false_type
> I wrote an implementation of the above, and example, here:
> The macro BOOST_MPL_HAS_XXX_TRAIT_DEF produces a predicate class that detects if a nested type exists, but only works for types, not other kinds of defined members. The class is_member_pointer<T>, but appears to require that you already know a symbol exists.
> I suppose such a macro might be called BOOST_MPL_HAS_XXX_MEMBER_DEF.

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at