mpl eval_if and has_member_data use

Hello, I have BOOST_HAS_STATIC_MEMBER_DATA(size_t, maxsize) // from introspection in sandbox template <typename T> class C { static const size_t s = boost::mpl::eval_if< boost::introspection::has_static_member_data_maxsize<T>, boost::mpl::size_t<T::maxsize>, boost::mpl::size_t<0> >::value; }; if T has maxsize size_t member, then s should get maxsize and if it doesn't, s should be 0. I get a compile error for cases where T doesn't have maxsize, because I still refer to it. e.g. of T struct Texample { ... static const size_t maxsize = 5; }; Regards,

You have to delay the evaluation of your T::maxsize by using an external metafunction. template<class T ,bool Enable= boost::introspection::has_static_member_data_maxsize<T>> struct make_size : mpl::size_t<T::maxsize> {}; template<class T> struct make_size<T,false> : mpl::size_t<0> {}; -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
participants (2)
-
Hicham Mouline
-
joel