dtype.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_TYPE_HPP)
  6. #define BOOST_TTI_DETAIL_TYPE_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/mpl/apply.hpp>
  9. #include <boost/mpl/bool.hpp>
  10. #include <boost/mpl/eval_if.hpp>
  11. #include <boost/mpl/has_xxx.hpp>
  12. #include <boost/preprocessor/cat.hpp>
  13. #include <boost/tti/detail/ddeftype.hpp>
  14. #include <boost/tti/detail/dlambda.hpp>
  15. #include <boost/tti/gen/namespace_gen.hpp>
  16. #include <boost/type_traits/is_class.hpp>
  17. #define BOOST_TTI_DETAIL_TRAIT_INVOKE_HAS_TYPE(trait,name) \
  18. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_MFC> \
  19. struct BOOST_PP_CAT(trait,_detail_type_invoke) : \
  20. boost::mpl::apply<BOOST_TTI_DETAIL_TP_MFC,typename BOOST_TTI_DETAIL_TP_T::name> \
  21. { \
  22. }; \
  23. /**/
  24. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP_CHOOSE(trait,name) \
  25. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(trait,_detail_type_mpl), name, false) \
  26. BOOST_TTI_DETAIL_TRAIT_INVOKE_HAS_TYPE(trait,name) \
  27. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_B> \
  28. struct BOOST_PP_CAT(trait,_detail_type_op_choose) \
  29. { \
  30. BOOST_MPL_ASSERT((BOOST_TTI_NAMESPACE::detail::is_lambda_expression<BOOST_TTI_DETAIL_TP_U>)); \
  31. typedef typename BOOST_PP_CAT(trait,_detail_type_invoke)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_U>::type type; \
  32. }; \
  33. \
  34. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U> \
  35. struct BOOST_PP_CAT(trait,_detail_type_op_choose)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_U,boost::mpl::false_::type> : \
  36. boost::mpl::false_ \
  37. { \
  38. }; \
  39. \
  40. template<class BOOST_TTI_DETAIL_TP_T> \
  41. struct BOOST_PP_CAT(trait,_detail_type_op_choose)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_NAMESPACE::detail::deftype,boost::mpl::true_::type> : \
  42. boost::mpl::true_ \
  43. { \
  44. }; \
  45. /**/
  46. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP(trait,name) \
  47. BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP_CHOOSE(trait,name) \
  48. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U> \
  49. struct BOOST_PP_CAT(trait,_detail_type_op) : \
  50. BOOST_PP_CAT(trait,_detail_type_op_choose) \
  51. < \
  52. BOOST_TTI_DETAIL_TP_T, \
  53. BOOST_TTI_DETAIL_TP_U, \
  54. typename BOOST_PP_CAT(trait,_detail_type_mpl)<BOOST_TTI_DETAIL_TP_T>::type \
  55. > \
  56. { \
  57. }; \
  58. /**/
  59. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE(trait,name) \
  60. BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP(trait,name) \
  61. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U> \
  62. struct BOOST_PP_CAT(trait,_detail_type) : \
  63. boost::mpl::eval_if \
  64. < \
  65. boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
  66. BOOST_PP_CAT(trait,_detail_type_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_U>, \
  67. boost::mpl::false_ \
  68. > \
  69. { \
  70. }; \
  71. /**/
  72. #endif // BOOST_TTI_DETAIL_TYPE_HPP