]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // (C) Copyright Edward Diener 2011,2012,2013 | |
3 | // Use, modification and distribution are subject to the Boost Software License, | |
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt). | |
6 | ||
7 | #if !defined(BOOST_TTI_DETAIL_MEM_FUN_HPP) | |
8 | #define BOOST_TTI_DETAIL_MEM_FUN_HPP | |
9 | ||
10 | #include <boost/config.hpp> | |
11 | #include <boost/function_types/is_member_function_pointer.hpp> | |
12 | #include <boost/function_types/property_tags.hpp> | |
13 | #include <boost/mpl/and.hpp> | |
14 | #include <boost/mpl/logical.hpp> | |
15 | #include <boost/mpl/assert.hpp> | |
16 | #include <boost/mpl/bool.hpp> | |
17 | #include <boost/mpl/eval_if.hpp> | |
18 | #include <boost/mpl/vector.hpp> | |
19 | #include <boost/preprocessor/cat.hpp> | |
20 | #include <boost/type_traits/detail/yes_no_type.hpp> | |
21 | #include <boost/type_traits/is_class.hpp> | |
22 | #include <boost/type_traits/is_same.hpp> | |
23 | #include <boost/type_traits/remove_const.hpp> | |
24 | #include <boost/tti/detail/dcomp_mem_fun.hpp> | |
25 | #include <boost/tti/detail/ddeftype.hpp> | |
26 | #include <boost/tti/detail/dnullptr.hpp> | |
27 | #include <boost/tti/detail/dptmf.hpp> | |
28 | #include <boost/tti/gen/namespace_gen.hpp> | |
29 | ||
30 | #if defined(__SUNPRO_CC) | |
31 | ||
32 | #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \ | |
33 | template<class BOOST_TTI_DETAIL_TP_PMEMF,class BOOST_TTI_DETAIL_TP_C> \ | |
34 | struct BOOST_PP_CAT(trait,_detail_types) \ | |
35 | { \ | |
36 | template<BOOST_TTI_DETAIL_TP_PMEMF> \ | |
37 | struct helper {}; \ | |
38 | \ | |
39 | template<class BOOST_TTI_DETAIL_TP_EC> \ | |
40 | static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_EC::name> *); \ | |
41 | \ | |
42 | template<class BOOST_TTI_DETAIL_TP_EC> \ | |
43 | static ::boost::type_traits::no_type chkt(...); \ | |
44 | \ | |
45 | typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_C>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \ | |
46 | }; \ | |
47 | /**/ | |
48 | ||
49 | #else | |
50 | ||
51 | #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \ | |
52 | template<class BOOST_TTI_DETAIL_TP_PMEMF,class BOOST_TTI_DETAIL_TP_C> \ | |
53 | struct BOOST_PP_CAT(trait,_detail_types) \ | |
54 | { \ | |
55 | template<BOOST_TTI_DETAIL_TP_PMEMF> \ | |
56 | struct helper; \ | |
57 | \ | |
58 | template<class BOOST_TTI_DETAIL_TP_EC> \ | |
59 | static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_EC::name> *); \ | |
60 | \ | |
61 | template<class BOOST_TTI_DETAIL_TP_EC> \ | |
62 | static ::boost::type_traits::no_type chkt(...); \ | |
63 | \ | |
64 | typedef boost::mpl::bool_<sizeof(chkt<BOOST_TTI_DETAIL_TP_C>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type)> type; \ | |
65 | }; \ | |
66 | /**/ | |
67 | ||
68 | #endif | |
69 | ||
70 | #define BOOST_TTI_DETAIL_TRAIT_CTMF_INVOKE(trait,name) \ | |
71 | BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \ | |
72 | 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> \ | |
73 | struct BOOST_PP_CAT(trait,_detail_ctmf_invoke) : \ | |
74 | BOOST_PP_CAT(trait,_detail_types) \ | |
75 | < \ | |
76 | 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, \ | |
77 | BOOST_TTI_DETAIL_TP_T \ | |
78 | > \ | |
79 | { \ | |
80 | }; \ | |
81 | /**/ | |
82 | ||
83 | #define BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION(trait,name) \ | |
84 | BOOST_TTI_DETAIL_TRAIT_CTMF_INVOKE(trait,name) \ | |
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_call_types) : \ | |
87 | boost::mpl::eval_if \ | |
88 | < \ | |
89 | boost::is_class<BOOST_TTI_DETAIL_TP_T>, \ | |
90 | BOOST_PP_CAT(trait,_detail_ctmf_invoke) \ | |
91 | < \ | |
92 | BOOST_TTI_DETAIL_TP_T, \ | |
93 | BOOST_TTI_DETAIL_TP_R, \ | |
94 | BOOST_TTI_DETAIL_TP_FS, \ | |
95 | BOOST_TTI_DETAIL_TP_TAG \ | |
96 | >, \ | |
97 | boost::mpl::false_ \ | |
98 | > \ | |
99 | { \ | |
100 | }; \ | |
101 | /**/ | |
102 | ||
103 | #define BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION(trait,name) \ | |
104 | BOOST_TTI_DETAIL_TRAIT_HAS_COMP_MEMBER_FUNCTION(trait,name) \ | |
105 | template<class BOOST_TTI_DETAIL_TP_T> \ | |
106 | struct BOOST_PP_CAT(trait,_detail_check_comp) : \ | |
107 | BOOST_PP_CAT(trait,_detail_hcmf)<BOOST_TTI_DETAIL_TP_T> \ | |
108 | { \ | |
109 | BOOST_MPL_ASSERT((boost::function_types::is_member_function_pointer<BOOST_TTI_DETAIL_TP_T>)); \ | |
110 | }; \ | |
111 | /**/ | |
112 | ||
113 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \ | |
114 | BOOST_TTI_DETAIL_TRAIT_HAS_CALL_TYPES_MEMBER_FUNCTION(trait,name) \ | |
115 | BOOST_TTI_DETAIL_TRAIT_CHECK_HAS_COMP_MEMBER_FUNCTION(trait,name) \ | |
116 | 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> \ | |
117 | struct BOOST_PP_CAT(trait,_detail_hmf) : \ | |
118 | boost::mpl::eval_if \ | |
119 | < \ | |
120 | boost::mpl::and_ \ | |
121 | < \ | |
122 | boost::is_same<BOOST_TTI_DETAIL_TP_R,BOOST_TTI_NAMESPACE::detail::deftype>, \ | |
123 | boost::is_same<BOOST_TTI_DETAIL_TP_FS,boost::mpl::vector<> >, \ | |
124 | boost::is_same<BOOST_TTI_DETAIL_TP_TAG,boost::function_types::null_tag> \ | |
125 | >, \ | |
126 | BOOST_PP_CAT(trait,_detail_check_comp)<BOOST_TTI_DETAIL_TP_T>, \ | |
127 | 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> \ | |
128 | > \ | |
129 | { \ | |
130 | }; \ | |
131 | /**/ | |
132 | ||
133 | #endif // BOOST_TTI_DETAIL_MEM_FUN_HPP |