dtemplate.hpp 2.2 KB

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