dstatic_mem_fun.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_STATIC_MEM_FUN_HPP)
  6. #define BOOST_TTI_DETAIL_STATIC_MEM_FUN_HPP
  7. #include <boost/function_types/is_function.hpp>
  8. #include <boost/function_types/property_tags.hpp>
  9. #include <boost/mpl/and.hpp>
  10. #include <boost/mpl/bool.hpp>
  11. #include <boost/mpl/eval_if.hpp>
  12. #include <boost/mpl/identity.hpp>
  13. #include <boost/mpl/vector.hpp>
  14. #include <boost/preprocessor/cat.hpp>
  15. #include <boost/tti/detail/dnullptr.hpp>
  16. #include <boost/tti/detail/dtfunction.hpp>
  17. #include <boost/tti/gen/namespace_gen.hpp>
  18. #include <boost/type_traits/is_class.hpp>
  19. #include <boost/type_traits/is_same.hpp>
  20. #include <boost/type_traits/detail/yes_no_type.hpp>
  21. #if defined(__SUNPRO_CC)
  22. #define BOOST_TTI_DETAIL_TRAIT_IMPL_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  23. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  24. struct BOOST_PP_CAT(trait,_detail_ihsmf) \
  25. { \
  26. template<BOOST_TTI_DETAIL_TP_TYPE *> \
  27. struct helper {}; \
  28. \
  29. template<class BOOST_TTI_DETAIL_TP_U> \
  30. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_U::name> *); \
  31. \
  32. template<class BOOST_TTI_DETAIL_TP_U> \
  33. static ::boost::type_traits::no_type chkt(...); \
  34. \
  35. typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_T>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \
  36. }; \
  37. /**/
  38. #else
  39. #define BOOST_TTI_DETAIL_TRAIT_IMPL_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  40. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  41. struct BOOST_PP_CAT(trait,_detail_ihsmf) \
  42. { \
  43. template<BOOST_TTI_DETAIL_TP_TYPE *> \
  44. struct helper; \
  45. \
  46. template<class BOOST_TTI_DETAIL_TP_U> \
  47. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_U::name> *); \
  48. \
  49. template<class BOOST_TTI_DETAIL_TP_U> \
  50. static ::boost::type_traits::no_type chkt(...); \
  51. \
  52. typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_T>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \
  53. }; \
  54. /**/
  55. #endif
  56. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION_OP(trait,name) \
  57. BOOST_TTI_DETAIL_TRAIT_IMPL_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  58. 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> \
  59. struct BOOST_PP_CAT(trait,_detail_hsmf_op) : \
  60. BOOST_PP_CAT(trait,_detail_ihsmf) \
  61. < \
  62. BOOST_TTI_DETAIL_TP_T, \
  63. typename \
  64. boost::mpl::eval_if \
  65. < \
  66. boost::mpl::and_ \
  67. < \
  68. boost::function_types::is_function<BOOST_TTI_DETAIL_TP_R>, \
  69. boost::is_same<BOOST_TTI_DETAIL_TP_FS,boost::mpl::vector<> >, \
  70. boost::is_same<BOOST_TTI_DETAIL_TP_TAG,boost::function_types::null_tag> \
  71. >, \
  72. boost::mpl::identity<BOOST_TTI_DETAIL_TP_R>, \
  73. BOOST_TTI_NAMESPACE::detail::tfunction_seq<BOOST_TTI_DETAIL_TP_R,BOOST_TTI_DETAIL_TP_FS,BOOST_TTI_DETAIL_TP_TAG> \
  74. >::type \
  75. > \
  76. { \
  77. }; \
  78. /**/
  79. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  80. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION_OP(trait,name) \
  81. 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> \
  82. struct BOOST_PP_CAT(trait,_detail_hsmf) : \
  83. boost::mpl::eval_if \
  84. < \
  85. boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
  86. BOOST_PP_CAT(trait,_detail_hsmf_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_R,BOOST_TTI_DETAIL_TP_FS,BOOST_TTI_DETAIL_TP_TAG>, \
  87. boost::mpl::false_ \
  88. > \
  89. { \
  90. }; \
  91. /**/
  92. #endif // BOOST_TTI_DETAIL_STATIC_MEM_FUN_HPP