|
Boost : |
Subject: Re: [boost] [MPL] RFC: An MPL macro to define a has_member_xxx<T> predicate
From: Erik Erlandson (eje_at_[hidden])
Date: 2013-10-31 13:07:36
----- Original Message -----
> > 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: http://www.boost.org/libs/tti/
Aha, serves me right for not having latest rev.
Thank you!
>
> > 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;
> > };
> >
> > CREATE_MEMBER_CHECK(foo);
> > CREATE_MEMBER_CHECK(bar);
> >
> > 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:
> > https://gist.github.com/erikerlandson/7251015
> >
> > 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
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk