1 2 // (C) Copyright Edward Diener 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_FUNCTION_HPP) 8 #define BOOST_TTI_HAS_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/dfunction.hpp> 15 #include <boost/tti/gen/has_function_gen.hpp> 16 17 /* 18 19 The succeeding comments in this file are in doxygen format. 20 21 */ 22 23 /** \file 24 */ 25 26 /// A macro which expands to a metafunction which tests whether a member function or a static member function with a particular name and signature exists. 27 /** 28 29 BOOST_TTI_TRAIT_HAS_FUNCTION is a macro which expands to a metafunction. 30 The metafunction tests whether a member function or a static member function with a particular name 31 and signature exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_FUNCTION(trait,name) where 32 33 trait = the name of the metafunction <br/> 34 name = the name of the inner member. 35 36 BOOST_TTI_TRAIT_HAS_FUNCTION generates a metafunction called "trait" where 'trait' is the macro parameter. 37 38 @code 39 40 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG> 41 struct trait 42 { 43 static const value = unspecified; 44 typedef mpl::bool_<true-or-false> type; 45 }; 46 47 The metafunction types and return: 48 49 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. 50 The enclosing type can be a class, struct, or union. 51 52 BOOST_TTI_TP_R = the return type of the function 53 54 BOOST_TTI_TP_FS = (optional) the parameters of the function as a boost::mpl forward sequence 55 if function parameters are not empty. 56 57 BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the function 58 if the need for a tag exists. 59 60 returns = 'value' is true if the 'name' exists, 61 with the appropriate static member function type, 62 otherwise 'value' is false. 63 64 @endcode 65 66 */ 67 #define BOOST_TTI_TRAIT_HAS_FUNCTION(trait,name) \ 68 BOOST_TTI_DETAIL_TRAIT_HAS_FUNCTION(trait,name) \ 69 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS = boost::mpl::vector<>,class BOOST_TTI_TP_TAG = boost::function_types::null_tag> \ 70 struct trait \ 71 { \ 72 typedef typename \ 73 BOOST_PP_CAT(trait,_detail_hf)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \ 74 BOOST_STATIC_CONSTANT(bool,value=type::value); \ 75 }; \ 76 /**/ 77 78 /// A macro which expands to a metafunction which tests whether a member function or a static member function with a particular name and signature exists. 79 /** 80 81 BOOST_TTI_HAS_FUNCTION is a macro which expands to a metafunction. 82 The metafunction tests whether a member function or a static member function with a particular name 83 and signature exists. The macro takes the form of BOOST_TTI_HAS_FUNCTION(name) where 84 85 name = the name of the inner member. 86 87 BOOST_TTI_HAS_FUNCTION generates a metafunction called "has_function_name" where 'name' is the macro parameter. 88 89 @code 90 91 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG> 92 struct has_function_'name' 93 { 94 static const value = unspecified; 95 typedef mpl::bool_<true-or-false> type; 96 }; 97 98 The metafunction types and return: 99 100 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. 101 The enclosing type can be a class, struct, or union. 102 103 BOOST_TTI_TP_R = the return type of the function 104 105 BOOST_TTI_TP_FS = (optional) the parameters of the function as a boost::mpl forward sequence 106 if function parameters are not empty. 107 108 BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the function 109 if the need for a tag exists. 110 111 returns = 'value' is true if the 'name' exists, 112 with the appropriate function type, 113 otherwise 'value' is false. 114 115 @endcode 116 117 */ 118 #define BOOST_TTI_HAS_FUNCTION(name) \ 119 BOOST_TTI_TRAIT_HAS_FUNCTION \ 120 ( \ 121 BOOST_TTI_HAS_FUNCTION_GEN(name), \ 122 name \ 123 ) \ 124 /**/ 125 126 #endif // BOOST_TTI_HAS_FUNCTION_HPP 127