dmem_fun.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_FUN_HPP)
  6. #define BOOST_TTI_DETAIL_MEM_FUN_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/function_types/is_member_function_pointer.hpp>
  9. #include <boost/function_types/property_tags.hpp>
  10. #include <boost/mpl/and.hpp>
  11. #include <boost/mpl/logical.hpp>
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/mpl/bool.hpp>
  14. #include <boost/mpl/eval_if.hpp>
  15. #include <boost/mpl/vector.hpp>
  16. #include <boost/preprocessor/cat.hpp>
  17. #include <boost/type_traits/detail/yes_no_type.hpp>
  18. #include <boost/type_traits/is_class.hpp>
  19. #include <boost/type_traits/is_same.hpp>
  20. #include <boost/type_traits/remove_const.hpp>
  21. #include <boost/tti/detail/dcomp_mem_fun.hpp>
  22. #include <boost/tti/detail/ddeftype.hpp>
  23. #include <boost/tti/detail/dnullptr.hpp>
  24. #include <boost/tti/detail/dptmf.hpp>
  25. #include <boost/tti/gen/namespace_gen.hpp>
  26. #if defined(__SUNPRO_CC)
  27. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \
  28. template<class BOOST_TTI_DETAIL_TP_PMEMF,class BOOST_TTI_DETAIL_TP_C> \
  29. struct BOOST_PP_CAT(trait,_detail_types) \
  30. { \
  31. template<BOOST_TTI_DETAIL_TP_PMEMF> \
  32. struct helper {}; \
  33. \
  34. template<class BOOST_TTI_DETAIL_TP_EC> \
  35. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_EC::name> *); \
  36. \
  37. template<class BOOST_TTI_DETAIL_TP_EC> \
  38. static ::boost::type_traits::no_type chkt(...); \
  39. \
  40. typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_C>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \
  41. }; \
  42. /**/
  43. #else
  44. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \
  45. template<class BOOST_TTI_DETAIL_TP_PMEMF,class BOOST_TTI_DETAIL_TP_C> \
  46. struct BOOST_PP_CAT(trait,_detail_types) \
  47. { \
  48. template<BOOST_TTI_DETAIL_TP_PMEMF> \
  49. struct helper; \
  50. \
  51. template<class BOOST_TTI_DETAIL_TP_EC> \
  52. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_EC::name> *); \
  53. \
  54. template<class BOOST_TTI_DETAIL_TP_EC> \
  55. static ::boost::type_traits::no_type chkt(...); \
  56. \
  57. typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_C>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \
  58. }; \
  59. /**/
  60. #endif
  61. #define BOOST_TTI_DETAIL_TRAIT_CTMF_INVOKE(trait,name) \
  62. BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \
  63. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_R,class BOOST_TTI_DETAIL_TP_FS,class BOOST_TTI_DETAIL_TP_TAG> \
  64. struct BOOST_PP_CAT(trait,_detail_ctmf_invoke) : \
  65. BOOST_PP_CAT(trait,_detail_types) \
  66. < \
  67. typename BOOST_TTI_NAMESPACE::detail::ptmf_seq<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_R,BOOST_TTI_DETAIL_TP_FS,BOOST_TTI_DETAIL_TP_TAG>::type, \
  68. BOOST_TTI_DETAIL_TP_T \
  69. > \
  70. { \
  71. }; \
  72. /**/
  73. #define BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION(trait,name) \
  74. BOOST_TTI_DETAIL_TRAIT_CTMF_INVOKE(trait,name) \
  75. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_R,class BOOST_TTI_DETAIL_TP_FS,class BOOST_TTI_DETAIL_TP_TAG> \
  76. struct BOOST_PP_CAT(trait,_detail_call_types) : \
  77. boost::mpl::eval_if \
  78. < \
  79. boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
  80. BOOST_PP_CAT(trait,_detail_ctmf_invoke) \
  81. < \
  82. BOOST_TTI_DETAIL_TP_T, \
  83. BOOST_TTI_DETAIL_TP_R, \
  84. BOOST_TTI_DETAIL_TP_FS, \
  85. BOOST_TTI_DETAIL_TP_TAG \
  86. >, \
  87. boost::mpl::false_ \
  88. > \
  89. { \
  90. }; \
  91. /**/
  92. #define BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION(trait,name) \
  93. BOOST_TTI_DETAIL_TRAIT_HAS_COMP_MEMBER_FUNCTION(trait,name) \
  94. template<class BOOST_TTI_DETAIL_TP_T> \
  95. struct BOOST_PP_CAT(trait,_detail_check_comp) : \
  96. BOOST_PP_CAT(trait,_detail_hcmf)<BOOST_TTI_DETAIL_TP_T> \
  97. { \
  98. BOOST_MPL_ASSERT((boost::function_types::is_member_function_pointer<BOOST_TTI_DETAIL_TP_T>)); \
  99. }; \
  100. /**/
  101. #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \
  102. BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION(trait,name) \
  103. BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION(trait,name) \
  104. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_R,class BOOST_TTI_DETAIL_TP_FS,class BOOST_TTI_DETAIL_TP_TAG> \
  105. struct BOOST_PP_CAT(trait,_detail_hmf) : \
  106. boost::mpl::eval_if \
  107. < \
  108. boost::mpl::and_ \
  109. < \
  110. boost::is_same<BOOST_TTI_DETAIL_TP_R,BOOST_TTI_NAMESPACE::detail::deftype>, \
  111. boost::is_same<BOOST_TTI_DETAIL_TP_FS,boost::mpl::vector<> >, \
  112. boost::is_same<BOOST_TTI_DETAIL_TP_TAG,boost::function_types::null_tag> \
  113. >, \
  114. BOOST_PP_CAT(trait,_detail_check_comp)<BOOST_TTI_DETAIL_TP_T>, \
  115. BOOST_PP_CAT(trait,_detail_call_types)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_R,BOOST_TTI_DETAIL_TP_FS,BOOST_TTI_DETAIL_TP_TAG> \
  116. > \
  117. { \
  118. }; \
  119. /**/
  120. #endif // BOOST_TTI_DETAIL_MEM_FUN_HPP