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_HAS_MEMBER_FUNCTION_HPP) |
8 | #define BOOST_TTI_HAS_MEMBER_FUNCTION_HPP |
9 | |
10 | #include <boost/config.hpp> |
11 | #include <boost/function_types/property_tags.hpp> |
12 | #include <boost/mpl/vector.hpp> |
13 | #include <boost/preprocessor/cat.hpp> |
14 | #include <boost/tti/detail/ddeftype.hpp> |
15 | #include <boost/tti/detail/dmem_fun.hpp> |
16 | #include <boost/tti/gen/has_member_function_gen.hpp> |
17 | #include <boost/tti/gen/namespace_gen.hpp> |
18 | |
19 | /* |
20 | |
21 | The succeeding comments in this file are in doxygen format. |
22 | |
23 | */ |
24 | |
25 | /** \file |
26 | */ |
27 | |
28 | /// Expands to a metafunction which tests whether a member function with a particular name and signature exists. |
29 | /** |
30 | |
31 | trait = the name of the metafunction within the tti namespace. |
32 | |
33 | name = the name of the inner member. |
34 | |
35 | generates a metafunction called "trait" where 'trait' is the macro parameter.<br /> |
36 | |
37 | template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG> |
38 | struct trait |
39 | { |
40 | static const value = unspecified; |
41 | typedef mpl::bool_<true-or-false> type; |
42 | }; |
43 | |
44 | The metafunction types and return: |
45 | |
46 | BOOST_TTI_TP_T = the enclosing type in which to look for our 'name' |
47 | OR |
48 | a pointer to member function as a single type. |
49 | |
50 | BOOST_TTI_TP_R = (optional) the return type of the member function |
51 | if the first parameter is the enclosing type. |
52 | |
53 | BOOST_TTI_TP_FS = (optional) the parameters of the member function as a boost::mpl forward sequence |
54 | if the first parameter is the enclosing type and the member function parameters |
55 | are not empty. |
56 | |
57 | BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function |
58 | if the first parameter is the enclosing type and a tag is needed. |
59 | |
60 | returns = 'value' is true if the 'name' exists, |
61 | with the appropriate member function type, |
62 | otherwise 'value' is false. |
63 | |
64 | */ |
65 | #define BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \ |
66 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \ |
67 | template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R = BOOST_TTI_NAMESPACE::detail::deftype,class BOOST_TTI_TP_FS = boost::mpl::vector<>,class BOOST_TTI_TP_TAG = boost::function_types::null_tag> \ |
68 | struct trait \ |
69 | { \ |
70 | typedef typename \ |
71 | BOOST_PP_CAT(trait,_detail_hmf)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \ |
72 | BOOST_STATIC_CONSTANT(bool,value=type::value); \ |
73 | }; \ |
74 | /**/ |
75 | |
76 | /// Expands to a metafunction which tests whether a member function with a particular name and signature exists. |
77 | /** |
78 | |
79 | name = the name of the inner member. |
80 | |
81 | generates a metafunction called "has_member_function_name" where 'name' is the macro parameter. |
82 | |
83 | template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG> |
84 | struct has_member_function_name |
85 | { |
86 | static const value = unspecified; |
87 | typedef mpl::bool_<true-or-false> type; |
88 | }; |
89 | |
90 | The metafunction types and return: |
91 | |
92 | BOOST_TTI_TP_T = the enclosing type in which to look for our 'name' |
93 | OR |
94 | a pointer to member function as a single type. |
95 | |
96 | BOOST_TTI_TP_R = (optional) the return type of the member function |
97 | if the first parameter is the enclosing type. |
98 | |
99 | BOOST_TTI_TP_FS = (optional) the parameters of the member function as a boost::mpl forward sequence |
100 | if the first parameter is the enclosing type and the member function parameters |
101 | are not empty. |
102 | |
103 | BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function |
104 | if the first parameter is the enclosing type and a tag is needed. |
105 | |
106 | returns = 'value' is true if the 'name' exists, |
107 | with the appropriate member function type, |
108 | otherwise 'value' is false. |
109 | |
110 | */ |
111 | #define BOOST_TTI_HAS_MEMBER_FUNCTION(name) \ |
112 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION \ |
113 | ( \ |
114 | BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(name), \ |
115 | name \ |
116 | ) \ |
117 | /**/ |
118 | |
119 | #endif // BOOST_TTI_HAS_MEMBER_FUNCTION_HPP |
120 | |