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).
7 #if !defined(BOOST_TTI_HAS_MEMBER_FUNCTION_HPP)
8 #define BOOST_TTI_HAS_MEMBER_FUNCTION_HPP
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>
21 The succeeding comments in this file are in doxygen format.
28 /// A macro which expands to a metafunction which tests whether a member function with a particular name and signature exists.
31 BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION is a macro which expands to a metafunction.
32 The metafunction tests whether a member function with a particular name
33 and signature exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(trait,name) where
35 trait = the name of the metafunction <br/>
36 name = the name of the inner member.
38 BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION generates a metafunction called "trait" where 'trait' is the macro parameter.
42 template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG>
45 static const value = unspecified;
46 typedef mpl::bool_<true-or-false> type;
49 The metafunction types and return:
51 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
52 The enclosing type can be a class, struct, or union.
54 a pointer to member function as a single type.
56 BOOST_TTI_TP_R = (optional) the return type of the member function
57 if the first parameter is the enclosing type.
59 BOOST_TTI_TP_FS = (optional) the parameters of the member function as a boost::mpl forward sequence
60 if the first parameter is the enclosing type and the member function parameters
63 BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function
64 if the first parameter is the enclosing type and a tag is needed.
66 returns = 'value' is true if the 'name' exists,
67 with the appropriate member function type,
68 otherwise 'value' is false.
73 #define BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \
74 BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION(trait,name) \
75 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> \
79 BOOST_PP_CAT(trait,_detail_hmf)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \
80 BOOST_STATIC_CONSTANT(bool,value=type::value); \
84 /// A macro which expands to a metafunction which tests whether a member function with a particular name and signature exists.
87 BOOST_TTI_HAS_MEMBER_FUNCTION is a macro which expands to a metafunction.
88 The metafunction tests whether a member function with a particular name
89 and signature exists. The macro takes the form of BOOST_TTI_HAS_MEMBER_FUNCTION(name) where
91 name = the name of the inner member.
93 BOOST_TTI_HAS_MEMBER_FUNCTION generates a metafunction called "has_member_function_name" where 'name' is the macro parameter.
97 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG>
98 struct has_member_function_'name'
100 static const value = unspecified;
101 typedef mpl::bool_<true-or-false> type;
104 The metafunction types and return:
106 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
107 The enclosing type can be a class, struct, or union.
109 a pointer to member function as a single type.
111 BOOST_TTI_TP_R = (optional) the return type of the member function
112 if the first parameter is the enclosing type.
114 BOOST_TTI_TP_FS = (optional) the parameters of the member function as a boost::mpl forward sequence
115 if the first parameter is the enclosing type and the member function parameters
118 BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function
119 if the first parameter is the enclosing type and a tag is needed.
121 returns = 'value' is true if the 'name' exists,
122 with the appropriate member function type,
123 otherwise 'value' is false.
128 #define BOOST_TTI_HAS_MEMBER_FUNCTION(name) \
129 BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION \
131 BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(name), \
136 #endif // BOOST_TTI_HAS_MEMBER_FUNCTION_HPP