1 2 // (C) Copyright Edward Diener 2011,2012,2013 3 // Use, modification and distribution are subject to the Boost Software License, 4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt). 6 7 #if !defined(BOOST_TTI_DETAIL_TEMPLATE_HPP) 8 #define BOOST_TTI_DETAIL_TEMPLATE_HPP 9 10 #include <boost/config.hpp> 11 #include <boost/mpl/bool.hpp> 12 #include <boost/mpl/eval_if.hpp> 13 #include <boost/mpl/has_xxx.hpp> 14 #include <boost/preprocessor/cat.hpp> 15 #include <boost/preprocessor/debug/assert.hpp> 16 #include <boost/preprocessor/facilities/is_empty.hpp> 17 #include <boost/tti/detail/denclosing_type.hpp> 18 #include <boost/tti/gen/namespace_gen.hpp> 19 #include <boost/type_traits/is_class.hpp> 20 #include <boost/type_traits/is_union.hpp> 21 22 #define BOOST_TTI_DETAIL_IS_HELPER_BOOST_PP_NIL 23 24 #define BOOST_TTI_DETAIL_IS_NIL(param) \ 25 BOOST_PP_IS_EMPTY \ 26 ( \ 27 BOOST_PP_CAT(BOOST_TTI_DETAIL_IS_HELPER_,param) \ 28 ) \ 29 /**/ 30 31 #define BOOST_TTI_DETAIL_TRAIT_ASSERT_NOT_NIL(trait,name,params) \ 32 BOOST_PP_ASSERT_MSG(0, "The parameter must be BOOST_PP_NIL") \ 33 /**/ 34 35 #define BOOST_TTI_DETAIL_TRAIT_CHECK_IS_NIL(trait,name,params) \ 36 BOOST_PP_IIF \ 37 ( \ 38 BOOST_TTI_DETAIL_IS_NIL(params), \ 39 BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE, \ 40 BOOST_TTI_DETAIL_TRAIT_ASSERT_NOT_NIL \ 41 ) \ 42 (trait,name,params) \ 43 /**/ 44 45 #define BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_THT(trait,name) \ 46 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(BOOST_PP_CAT(trait,_detail_mpl), name, false) \ 47 template<class BOOST_TTI_DETAIL_TP_T> \ 48 struct BOOST_PP_CAT(trait,_tht) : \ 49 BOOST_PP_CAT(trait,_detail_mpl)<BOOST_TTI_DETAIL_TP_T> \ 50 { \ 51 }; \ 52 /**/ 53 54 #define BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE(trait,name,params) \ 55 BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_THT(trait,name) \ 56 template<class BOOST_TTI_DETAIL_TP_T> \ 57 struct trait \ 58 { \ 59 typedef typename \ 60 boost::mpl::eval_if \ 61 < \ 62 BOOST_TTI_NAMESPACE::detail::enclosing_type<BOOST_TTI_DETAIL_TP_T>, \ 63 BOOST_PP_CAT(trait,_tht)<BOOST_TTI_DETAIL_TP_T>, \ 64 boost::mpl::false_ \ 65 >::type type; \ 66 BOOST_STATIC_CONSTANT(bool,value=type::value); \ 67 }; \ 68 /**/ 69 70 #endif // !BOOST_TTI_DETAIL_TEMPLATE_HPP 71