dmem_fun_template.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // (C) Copyright Edward Diener 2019
  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_TEMPLATE_HPP)
  6. #define BOOST_TTI_DETAIL_MEM_FUN_TEMPLATE_HPP
  7. #include <boost/function_types/is_member_function_pointer.hpp>
  8. #include <boost/function_types/property_tags.hpp>
  9. #include <boost/mpl/and.hpp>
  10. #include <boost/mpl/logical.hpp>
  11. #include <boost/mpl/assert.hpp>
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/mpl/eval_if.hpp>
  14. #include <boost/mpl/vector.hpp>
  15. #include <boost/preprocessor/cat.hpp>
  16. #include <boost/preprocessor/array/enum.hpp>
  17. #include <boost/type_traits/detail/yes_no_type.hpp>
  18. #include <boost/type_traits/is_same.hpp>
  19. #include <boost/tti/detail/dcomp_mem_fun_template.hpp>
  20. #include <boost/tti/detail/ddeftype.hpp>
  21. #include <boost/tti/detail/dnullptr.hpp>
  22. #include <boost/tti/detail/dptmf.hpp>
  23. #include <boost/tti/detail/dmacro_sunfix.hpp>
  24. #include <boost/tti/detail/denclosing_type.hpp>
  25. #include <boost/tti/gen/namespace_gen.hpp>
  26. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  27. template<class BOOST_TTI_DETAIL_TP_PMEMF,class BOOST_TTI_DETAIL_TP_C> \
  28. struct BOOST_PP_CAT(trait,_detail_hmft_types) \
  29. { \
  30. template<BOOST_TTI_DETAIL_TP_PMEMF> \
  31. struct helper BOOST_TTI_DETAIL_MACRO_SUNFIX ; \
  32. \
  33. template<class BOOST_TTI_DETAIL_TP_EC> \
  34. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_EC::template name<BOOST_PP_ARRAY_ENUM(pparray)> > *); \
  35. \
  36. template<class BOOST_TTI_DETAIL_TP_EC> \
  37. static ::boost::type_traits::no_type chkt(...); \
  38. \
  39. typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_C>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \
  40. }; \
  41. /**/
  42. #define BOOST_TTI_DETAIL_TRAIT_CTMF_INVOKE_TEMPLATE(trait,name,pparray) \
  43. BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  44. 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> \
  45. struct BOOST_PP_CAT(trait,_detail_hmft_ctmf_invoke_template) : \
  46. BOOST_PP_CAT(trait,_detail_hmft_types) \
  47. < \
  48. 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, \
  49. BOOST_TTI_DETAIL_TP_T \
  50. > \
  51. { \
  52. }; \
  53. /**/
  54. #define BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  55. BOOST_TTI_DETAIL_TRAIT_CTMF_INVOKE_TEMPLATE(trait,name,pparray) \
  56. 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> \
  57. struct BOOST_PP_CAT(trait,_detail_hmft_call_types) : \
  58. boost::mpl::eval_if \
  59. < \
  60. BOOST_TTI_NAMESPACE::detail::enclosing_type<BOOST_TTI_DETAIL_TP_T>, \
  61. BOOST_PP_CAT(trait,_detail_hmft_ctmf_invoke_template) \
  62. < \
  63. BOOST_TTI_DETAIL_TP_T, \
  64. BOOST_TTI_DETAIL_TP_R, \
  65. BOOST_TTI_DETAIL_TP_FS, \
  66. BOOST_TTI_DETAIL_TP_TAG \
  67. >, \
  68. boost::mpl::false_ \
  69. > \
  70. { \
  71. }; \
  72. /**/
  73. #define BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  74. BOOST_TTI_DETAIL_TRAIT_HAS_COMP_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  75. template<class BOOST_TTI_DETAIL_TP_T> \
  76. struct BOOST_PP_CAT(trait,_detail_hmft_check_comp) : \
  77. BOOST_PP_CAT(trait,_detail_hcmft)<BOOST_TTI_DETAIL_TP_T> \
  78. { \
  79. BOOST_MPL_ASSERT((boost::function_types::is_member_function_pointer<BOOST_TTI_DETAIL_TP_T>)); \
  80. }; \
  81. /**/
  82. #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  83. BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  84. BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  85. 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> \
  86. struct BOOST_PP_CAT(trait,_detail_hmft) : \
  87. boost::mpl::eval_if \
  88. < \
  89. boost::mpl::and_ \
  90. < \
  91. boost::is_same<BOOST_TTI_DETAIL_TP_R,BOOST_TTI_NAMESPACE::detail::deftype>, \
  92. boost::is_same<BOOST_TTI_DETAIL_TP_FS,boost::mpl::vector<> >, \
  93. boost::is_same<BOOST_TTI_DETAIL_TP_TAG,boost::function_types::null_tag> \
  94. >, \
  95. BOOST_PP_CAT(trait,_detail_hmft_check_comp)<BOOST_TTI_DETAIL_TP_T>, \
  96. BOOST_PP_CAT(trait,_detail_hmft_call_types)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_R,BOOST_TTI_DETAIL_TP_FS,BOOST_TTI_DETAIL_TP_TAG> \
  97. > \
  98. { \
  99. }; \
  100. /**/
  101. #endif // BOOST_TTI_DETAIL_MEM_FUN_TEMPLATE_HPP