dmem_type.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_MEM_TYPE_HPP)
  6. #define BOOST_TTI_DETAIL_MEM_TYPE_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/type_traits/is_class.hpp>
  13. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_MEMBER_TYPE_OP(trait,name) \
  14. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(trait,_detail_mpl), name, false) \
  15. template<class BOOST_TTI_DETAIL_TP_T> \
  16. struct BOOST_PP_CAT(trait,_detail_op) : \
  17. BOOST_PP_CAT(trait,_detail_mpl)<BOOST_TTI_DETAIL_TP_T> \
  18. { \
  19. }; \
  20. /**/
  21. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_MEMBER_TYPE(trait,name) \
  22. BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_MEMBER_TYPE_OP(trait,name) \
  23. template<class BOOST_TTI_DETAIL_TP_T> \
  24. struct BOOST_PP_CAT(trait,_detail) \
  25. { \
  26. typedef typename \
  27. boost::mpl::eval_if \
  28. < \
  29. boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
  30. BOOST_PP_CAT(trait,_detail_op)<BOOST_TTI_DETAIL_TP_T>, \
  31. boost::mpl::false_ \
  32. >::type type; \
  33. \
  34. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  35. }; \
  36. /**/
  37. #define BOOST_TTI_DETAIL_TRAIT_MEMBER_TYPE(trait,name) \
  38. template<class BOOST_TTI_DETAIL_TP_T> \
  39. struct BOOST_PP_CAT(trait,_detail_member_type) \
  40. { \
  41. typedef typename BOOST_TTI_DETAIL_TP_T::name type; \
  42. }; \
  43. /**/
  44. #endif // BOOST_TTI_DETAIL_MEM_TYPE_HPP