c++ - Detecting at compile-time whether a class has a member variabe or function -
I am trying to find out at compile time whether a class Foo
or Bar
in or variable value
or member variable initValue ()
.
struct foo {static const int value; Static int initValue (); }; Structure bar {};
I have got lots of promotions and have promoted MPL sections and UTI like BOOST_MPL_HAS_XXX_TRAIT_DEF
and valid_member_metafunction
which it just looks like Is unsure to use I know that it is possible to roll my own detector but I did not want to.
It has got has_static_member_data from the library and
has_static_member_function
.
#include & lt; Boost / tti / has_static_member_data.hpp & gt; BOOST_TTI_HAS_STATIC_MEMBER_DATA (value) // Class templates are created by_static_member_data_value ... has_static_member_data_value & lt; Foo, int & gt; :: value; // return true_static_member_data_value & lt; Bar, int> :: value; // false return
Comments
Post a Comment