John M. Dlugosz <ngnr63q02 <at> sneakemail.com> writes: [...]
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).
This may or may not be what you're looking for: #include <type_traits> struct make_pretty { }; std::true_type is_pretty_impl(make_pretty*); std::false_type is_pretty_impl(...); template <typename T> struct is_pretty : decltype(is_pretty_impl((T*)nullptr)) { }; struct pretty : make_pretty { }; struct pretty_too : pretty { }; struct ugly_by_default; struct pretty_can_be_made_ugly : make_pretty { }; template <> struct is_pretty<pretty_can_be_made_ugly> : std::false_type { }; static_assert(is_pretty<pretty>::value, ""); static_assert(is_pretty<pretty_too>::value, ""); static_assert(!is_pretty<ugly_by_default>::value, ""); static_assert(!is_pretty<pretty_can_be_made_ugly>::value, ""); Caveat: is_pretty will return false on a type that inherits something pretty until it is complete (this could be confusing). Regards, Louis Dionne