• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DATA_HPP)
8 #define BOOST_TTI_HAS_MEMBER_DATA_HPP
9 
10 #include <boost/config.hpp>
11 #include <boost/preprocessor/cat.hpp>
12 #include <boost/tti/detail/ddeftype.hpp>
13 #include <boost/tti/detail/dmem_data.hpp>
14 #include <boost/tti/gen/has_member_data_gen.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 with a particular name and type exists.
26 /**
27 
28     BOOST_TTI_TRAIT_HAS_MEMBER_DATA is a macro which expands to a metafunction.
29     The metafunction tests whether member data with a particular
30     name and type exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_MEMBER_DATA(trait,name) where
31 
32     trait = the name of the metafunction. <br/>
33     name  = the name of the inner member data.
34 
35     BOOST_TTI_TRAIT_HAS_MEMBER_DATA generates a metafunction called "trait" where 'trait' is the macro parameter.
36 
37   @code
38 
39               template<class BOOST_TTI_TP_ET,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_ET   = the enclosing type in which to look for our 'name'
49                                     The enclosing type can be a class, struct, or union.
50                                                          OR
51                                     The type of the member data in the form of a pointer
52                                     to member data.
53 
54                 BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
55                                     parameter is the enclosing type.
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_MEMBER_DATA(trait,name) \
64   BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \
65   template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE = BOOST_TTI_NAMESPACE::detail::deftype> \
66   struct trait \
67     { \
68     typedef typename \
69     BOOST_PP_CAT(trait,_detail_hmd) \
70         < \
71         BOOST_TTI_TP_ET, \
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 a member data with a particular name and type exists.
79 /**
80 
81     BOOST_TTI_HAS_MEMBER_DATA is a macro which expands to a metafunction.
82     The metafunction tests whether member data with a particular
83     name and type exists. The macro takes the form of BOOST_TTI_HAS_MEMBER_DATA(name) where
84 
85     name  = the name of the inner member.
86 
87     BOOST_TTI_HAS_MEMBER_DATA generates a metafunction called "has_member_data_name" where 'name' is the macro parameter.
88 
89   @code
90 
91               template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE>
92               struct has_member_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_ET   = the enclosing type in which to look for our 'name'.
101                                     The enclosing type can be a class, struct, or union.
102                                                          OR
103                                     The type of the member data in the form of a pointer
104                                     to member data.
105 
106                 BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
107                                     parameter is the enclosing type.
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_MEMBER_DATA(name) \
116   BOOST_TTI_TRAIT_HAS_MEMBER_DATA \
117   ( \
118   BOOST_TTI_HAS_MEMBER_DATA_GEN(name), \
119   name \
120   ) \
121 /**/
122 
123 #endif // BOOST_TTI_HAS_MEMBER_DATA_HPP
124