dmem_fun.hpp 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_same.hpp>
  19. #include <boost/type_traits/remove_const.hpp>
  20. #include <boost/tti/detail/dcomp_mem_fun.hpp>
  21. #include <boost/tti/detail/ddeftype.hpp>
  22. #include <boost/tti/detail/dnullptr.hpp>
  23. #include <boost/tti/detail/dptmf.hpp>
  24. #include <boost/tti/gen/namespace_gen.hpp>
  25. #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \
  26. template<class BOOST_TTI_DETAIL_TP_PMEMF,class BOOST_TTI_DETAIL_TP_C> \
  27. struct BOOST_PP_CAT(trait,_detail_types) \
  28. { \
  29. template<BOOST_TTI_DETAIL_TP_PMEMF> \
  30. struct helper; \
  31. \
  32. template<class BOOST_TTI_DETAIL_TP_EC> \
  33. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_EC::name> *); \
  34. \
  35. template<class BOOST_TTI_DETAIL_TP_EC> \
  36. static ::boost::type_traits::no_type chkt(...); \
  37. \
  38. BOOST_STATIC_CONSTANT(bool,value=sizeof(chkt<BOOST_TTI_DETAIL_TP_C>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)); \
  39. \
  40. typedef boost::mpl::bool_<value> type; \
  41. }; \
  42. /**/
  43. #define BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION(trait,name) \
  44. BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \
  45. 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> \
  46. struct BOOST_PP_CAT(trait,_detail_call_types) : \
  47. BOOST_PP_CAT(trait,_detail_types) \
  48. < \
  49. 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, \
  50. BOOST_TTI_DETAIL_TP_T \
  51. > \
  52. { \
  53. }; \
  54. /**/
  55. #define BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION(trait,name) \
  56. BOOST_TTI_DETAIL_TRAIT_HAS_COMP_MEMBER_FUNCTION(trait,name) \
  57. template<class BOOST_TTI_DETAIL_TP_T> \
  58. struct BOOST_PP_CAT(trait,_detail_check_comp) : \
  59. BOOST_PP_CAT(trait,_detail_hcmf)<BOOST_TTI_DETAIL_TP_T> \
  60. { \
  61. BOOST_MPL_ASSERT((boost::function_types::is_member_function_pointer<BOOST_TTI_DETAIL_TP_T>)); \
  62. }; \
  63. /**/
  64. #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \
  65. BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION(trait,name) \
  66. BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION(trait,name) \
  67. 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> \
  68. struct BOOST_PP_CAT(trait,_detail_hmf) \
  69. { \
  70. typedef typename \
  71. boost::mpl::eval_if \
  72. < \
  73. boost::mpl::and_ \
  74. < \
  75. boost::is_same<BOOST_TTI_DETAIL_TP_R,BOOST_TTI_NAMESPACE::detail::deftype>, \
  76. boost::is_same<BOOST_TTI_DETAIL_TP_FS,boost::mpl::vector<> >, \
  77. boost::is_same<BOOST_TTI_DETAIL_TP_TAG,boost::function_types::null_tag> \
  78. >, \
  79. BOOST_PP_CAT(trait,_detail_check_comp)<BOOST_TTI_DETAIL_TP_T>, \
  80. 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> \
  81. >::type type; \
  82. \
  83. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  84. }; \
  85. /**/
  86. #endif // BOOST_TTI_DETAIL_MEM_FUN_HPP