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/// Expands to a metafunction which tests whether a member data 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_ET,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_ET = the enclosing type in which to look for our 'name'
44 OR
45 The type of the member data in the form of a pointer
46 to member data.
47
48 BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
49 parameter is the enclosing type.
50
51 returns = 'value' is true if the 'name' exists, with the correct data type,
52 otherwise 'value' is false.
53
54*/
55#define BOOST_TTI_TRAIT_HAS_MEMBER_DATA(trait,name) \
56 BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \
57 template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE = BOOST_TTI_NAMESPACE::detail::deftype> \
58 struct trait \
59 { \
60 typedef typename \
61 BOOST_PP_CAT(trait,_detail_hmd) \
62 < \
63 BOOST_TTI_TP_ET, \
64 BOOST_TTI_TP_TYPE \
65 >::type type; \
66 BOOST_STATIC_CONSTANT(bool,value=type::value); \
67 }; \
68/**/
69
70/// Expands to a metafunction which tests whether a member data with a particular name and type exists.
71/**
72
73 name = the name of the inner member.
74
75 generates a metafunction called "has_member_data_name" where 'name' is the macro parameter.
76
77 template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE>
78 struct has_member_data_name
79 {
80 static const value = unspecified;
81 typedef mpl::bool_<true-or-false> type;
82 };
83
84 The metafunction types and return:
85
86 BOOST_TTI_TP_ET = the enclosing type in which to look for our 'name'
87 OR
88 The type of the member data in the form of a pointer
89 to member data.
90
91 BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
92 parameter is the enclosing type.
93
94 returns = 'value' is true if the 'name' exists, with the correct data type,
95 otherwise 'value' is false.
96
97*/
98#define BOOST_TTI_HAS_MEMBER_DATA(name) \
99 BOOST_TTI_TRAIT_HAS_MEMBER_DATA \
100 ( \
101 BOOST_TTI_HAS_MEMBER_DATA_GEN(name), \
102 name \
103 ) \
104/**/
105
106#endif // BOOST_TTI_HAS_MEMBER_DATA_HPP
107

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