|
Boost Users : |
Subject: Re: [Boost-users] [MPL] implementing a "trait"?
From: Rodrigo Madera (rodrigo.madera_at_[hidden])
Date: 2014-02-04 13:24:00
namespace john {
template <typename T>
struct is_pretty : boost::false_type {};
template <>
struct is_pretty<foo> : boost::true_type {};
template <>
struct is_pretty<bar> : boost::true_type {};
// ...
}
BOOST_MPL_ASSERT((john::is_pretty<foo>));
BOOST_MPL_ASSERT((john::is_pretty<bar>));
Regards,
Rodrigo Madera
On Tue, Feb 4, 2014 at 4:03 PM, John M. Dlugosz <ngnr63q02_at_[hidden]>wrote:
> I want to mark certain types as being of a category of my invention (e.g.
> is_pretty), for purposes of using enable_if in the same manner is standard
> type traits such as is_arithmetic etc.
>
> The trait will be false by default, and I'd declare something to nominate
> types that should be seen to have that trait. I want it to follow
> inheritance; if B has been declared to be in my category, and C is derived
> from B, then C will also be in that category without needing to do anything
> more (though some way to turn it _off_ would be available).
>
> Can someone advise me on an easy way to structure this?
>
> Thanks,
> --John
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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