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/// Expands to a metafunction which tests whether member data or static member with a particular name and type exists.
26/**
27
28 trait = the name of the metafunction.
29
30 name = the name of the inner member to introspect.
31
32 generates a metafunction called "trait" where 'trait' is the macro parameter.
33
34 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE>
35 struct trait
36 {
37 static const value = unspecified;
38 typedef mpl::bool_<true-or-false> type;
39 };
40
41 The metafunction types and return:
42
43 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'
44
45 BOOST_TTI_TP_TYPE = The type of the member data or static member.
46
47 returns = 'value' is true if the 'name' exists, with the correct data type,
48 otherwise 'value' is false.
49
50*/
51#define BOOST_TTI_TRAIT_HAS_DATA(trait,name) \
52 BOOST_TTI_DETAIL_TRAIT_HAS_DATA(trait,name) \
53 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE> \
54 struct trait \
55 { \
56 typedef typename \
57 BOOST_PP_CAT(trait,_detail_hd) \
58 < \
59 typename boost::remove_const<BOOST_TTI_TP_T>::type, \
60 BOOST_TTI_TP_TYPE \
61 >::type type; \
62 BOOST_STATIC_CONSTANT(bool,value=type::value); \
63 }; \
64/**/
65
66/// Expands to a metafunction which tests whether member data or static member data with a particular name and type exists.
67/**
68
69 name = the name of the inner member.
70
71 generates a metafunction called "has_data_name" where 'name' is the macro parameter.
72
73 template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE>
74 struct has_data_name
75 {
76 static const value = unspecified;
77 typedef mpl::bool_<true-or-false> type;
78 };
79
80 The metafunction types and return:
81
82 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'
83
84 BOOST_TTI_TP_TYPE = The type of the member data or static member.
85
86 returns = 'value' is true if the 'name' exists, with the correct data type,
87 otherwise 'value' is false.
88
89*/
90#define BOOST_TTI_HAS_DATA(name) \
91 BOOST_TTI_TRAIT_HAS_DATA \
92 ( \
93 BOOST_TTI_HAS_DATA_GEN(name), \
94 name \
95 ) \
96/**/
97
98#endif // BOOST_TTI_HAS_DATA_HPP
99

source code of boost/boost/tti/has_data.hpp