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_DATA_HPP) 8 #define BOOST_TTI_HAS_DATA_HPP 9 10 #include <boost/config.hpp> 11 #include <boost/preprocessor/cat.hpp> 12 #include <boost/type_traits/remove_const.hpp> 13 #include <boost/tti/gen/has_data_gen.hpp> 14 #include <boost/tti/detail/ddata.hpp> 15 16 /* 17 18 The succeeding comments in this file are in doxygen format. 19 20 */ 21 22 /** \file 23 */ 24 25 /// A macro which expands to a metafunction which tests whether member data or static member data with a particular name and type exists. 26 /** 27 28 BOOST_TTI_TRAIT_HAS_DATA is a macro which expands to a metafunction. 29 The metafunction tests whether member data or static member data with a particular 30 name and type exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_DATA(trait,name) where 31 32 trait = the name of the metafunction <br/> 33 name = the name of the inner data. 34 35 BOOST_TTI_TRAIT_HAS_DATA generates a metafunction called "trait" where 'trait' is the macro parameter. 36 37 @code 38 39 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE> 40 struct trait 41 { 42 static const value = unspecified; 43 typedef mpl::bool_<true-or-false> type; 44 }; 45 46 The metafunction types and return: 47 48 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name' 49 The enclosing type can be a class, struct, or union. 50 If the type is a union, static member data can only 51 be found if the C++11 unrestricted union is implemented 52 by the compiler being used, since prior to C++11 a union 53 could not have static data members. 54 55 BOOST_TTI_TP_TYPE = The type of the member data or static member. 56 57 returns = 'value' is true if the 'name' exists, with the correct data type, 58 otherwise 'value' is false. 59 60 @endcode 61 62 */ 63 #define BOOST_TTI_TRAIT_HAS_DATA(trait,name) \ 64 BOOST_TTI_DETAIL_TRAIT_HAS_DATA(trait,name) \ 65 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE> \ 66 struct trait \ 67 { \ 68 typedef typename \ 69 BOOST_PP_CAT(trait,_detail_hd) \ 70 < \ 71 typename boost::remove_const<BOOST_TTI_TP_T>::type, \ 72 BOOST_TTI_TP_TYPE \ 73 >::type type; \ 74 BOOST_STATIC_CONSTANT(bool,value=type::value); \ 75 }; \ 76 /**/ 77 78 /// A macro which expands to a metafunction which tests whether member data or static member data with a particular name and type exists. 79 /** 80 81 BOOST_TTI_HAS_DATA is a macro which expands to a metafunction. 82 The metafunction tests whether member data or static member data with a particular 83 name and type exists. The macro takes the form of BOOST_TTI_HAS_DATA(name) where 84 85 name = the name of the inner data. 86 87 BOOST_TTI_HAS_DATA generates a metafunction called "has_data_name" where 'name' is the macro parameter. 88 89 @code 90 91 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE> 92 struct has_data_'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 If the type is a union, static member data can only 103 be found if the C++11 unrestricted union is implemented 104 by the compiler being used, since prior to C++11 a union 105 could not have static data members. 106 107 BOOST_TTI_TP_TYPE = The type of the member data or static member. 108 109 returns = 'value' is true if the 'name' exists, with the correct data type, 110 otherwise 'value' is false. 111 112 @endcode 113 114 */ 115 #define BOOST_TTI_HAS_DATA(name) \ 116 BOOST_TTI_TRAIT_HAS_DATA \ 117 ( \ 118 BOOST_TTI_HAS_DATA_GEN(name), \ 119 name \ 120 ) \ 121 /**/ 122 123 #endif // BOOST_TTI_HAS_DATA_HPP 124