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