|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81813 - in trunk: boost/tti boost/tti/detail boost/tti/gen libs/tti/test
From: eldiener_at_[hidden]
Date: 2012-12-09 23:39:13
Author: eldiener
Date: 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
New Revision: 81813
URL: http://svn.boost.org/trac/boost/changeset/81813
Log:
Added BOOST_TTI_HAS_DATA macro and functionality.
Added:
trunk/boost/tti/detail/ddata.hpp (contents, props changed)
trunk/boost/tti/gen/has_data_gen.hpp (contents, props changed)
trunk/boost/tti/has_data.hpp (contents, props changed)
trunk/libs/tti/test/test_has_data.cpp (contents, props changed)
trunk/libs/tti/test/test_has_data.hpp (contents, props changed)
Text files modified:
trunk/boost/tti/has_member_data.hpp | 40 ++++++++++++++++++++--------------------
trunk/libs/tti/test/Jamfile.v2 | 12 ++++++++++++
2 files changed, 32 insertions(+), 20 deletions(-)
Added: trunk/boost/tti/detail/ddata.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/tti/detail/ddata.hpp 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -0,0 +1,44 @@
+
+// (C) Copyright Edward Diener 2012
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#if !defined(BOOST_TTI_DETAIL_DATA_HPP)
+#define BOOST_TTI_DETAIL_DATA_HPP
+
+#include <boost/config.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/tti/detail/dmem_data.hpp>
+#include <boost/tti/detail/dstatic_mem_data.hpp>
+#include <boost/tti/gen/namespace_gen.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#define BOOST_TTI_DETAIL_TRAIT_HAS_DATA(trait,name) \
+ BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \
+ BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
+ template<class ET,class DT> \
+ struct BOOST_PP_CAT(trait,_detail_hd) \
+ { \
+ \
+ typedef typename \
+ BOOST_PP_CAT(trait,_detail_hmd) \
+ < \
+ typename BOOST_TTI_NAMESPACE::detail::ptmd<ET,DT>::type, \
+ typename boost::remove_const<ET>::type \
+ >::type hmdtype; \
+ \
+ typedef typename \
+ BOOST_PP_CAT(trait,_detail_hsd)<ET,DT>::type hsdtype; \
+ \
+ BOOST_STATIC_CONSTANT \
+ ( \
+ bool, \
+ value = hmdtype::value || hsdtype::value \
+ ); \
+ \
+ typedef boost::mpl::bool_<value> type; \
+ }; \
+/**/
+
+#endif // BOOST_TTI_DETAIL_DATA_HPP
Added: trunk/boost/tti/gen/has_data_gen.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/tti/gen/has_data_gen.hpp 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -0,0 +1,31 @@
+
+// (C) Copyright Edward Diener 2012
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#if !defined(BOOST_TTI_DATA_GEN_HPP)
+#define BOOST_TTI_DATA_GEN_HPP
+
+#include <boost/preprocessor/cat.hpp>
+
+/*
+
+ The succeeding comments in this file are in doxygen format.
+
+*/
+
+/** \file
+*/
+
+/// Generates the macro metafunction name for BOOST_TTI_HAS_DATA.
+/**
+ name = the name of the member data.
+
+ returns = the generated macro metafunction name.
+*/
+#define BOOST_TTI_HAS_DATA_GEN(name) \
+ BOOST_PP_CAT(has_data_,name) \
+/**/
+
+#endif // BOOST_TTI_DATA_GEN_HPP
Added: trunk/boost/tti/has_data.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/tti/has_data.hpp 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -0,0 +1,95 @@
+
+// (C) Copyright Edward Diener 2012
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#if !defined(BOOST_TTI_HAS_DATA_HPP)
+#define BOOST_TTI_HAS_DATA_HPP
+
+#include <boost/preprocessor/cat.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/tti/gen/has_data_gen.hpp>
+#include <boost/tti/detail/ddata.hpp>
+
+/*
+
+ The succeeding comments in this file are in doxygen format.
+
+*/
+
+/** \file
+*/
+
+/// Expands to a metafunction which tests whether member data or static member with a particular name and type exists.
+/**
+
+ trait = the name of the metafunction.
+
+ name = the name of the inner member to introspect.
+
+ generates a metafunction called "trait" where 'trait' is the macro parameter.
+
+ template<class TTI_T,class TTI_Type>
+ struct trait
+ {
+ static const value = unspecified;
+ typedef mpl::bool_<true-or-false> type;
+ };
+
+ The metafunction types and return:
+
+ TTI_T = the enclosing type in which to look for our 'name'
+
+ TTI_Type = The type of the member data or static member.
+
+ returns = 'value' is true if the 'name' exists, with the correct data type,
+ otherwise 'value' is false.
+
+*/
+#define BOOST_TTI_TRAIT_HAS_DATA(trait,name) \
+ BOOST_TTI_DETAIL_TRAIT_HAS_DATA(trait,name) \
+ template<class TTI_T,class TTI_Type> \
+ struct trait : \
+ BOOST_PP_CAT(trait,_detail_hd) \
+ < \
+ typename boost::remove_const<TTI_T>::type, \
+ TTI_Type \
+ > \
+ { \
+ }; \
+/**/
+
+/// Expands to a metafunction which tests whether member data or static member data with a particular name and type exists.
+/**
+
+ name = the name of the inner member.
+
+ generates a metafunction called "has_data_name" where 'name' is the macro parameter.
+
+ template<class TTI_T,class TTI_Type>
+ struct has_data_name
+ {
+ static const value = unspecified;
+ typedef mpl::bool_<true-or-false> type;
+ };
+
+ The metafunction types and return:
+
+ TTI_T = the enclosing type in which to look for our 'name'
+
+ TTI_Type = The type of the member data or static member.
+
+ returns = 'value' is true if the 'name' exists, with the correct data type,
+ otherwise 'value' is false.
+
+*/
+#define BOOST_TTI_HAS_DATA(name) \
+ BOOST_TTI_TRAIT_HAS_DATA \
+ ( \
+ BOOST_TTI_HAS_DATA_GEN(name), \
+ name \
+ ) \
+/**/
+
+#endif // BOOST_TTI_HAS_DATA_HPP
Modified: trunk/boost/tti/has_member_data.hpp
==============================================================================
--- trunk/boost/tti/has_member_data.hpp (original)
+++ trunk/boost/tti/has_member_data.hpp 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -8,11 +8,11 @@
#define BOOST_TTI_HAS_MEMBER_DATA_HPP
#include <boost/preprocessor/cat.hpp>
-#include <boost/type_traits/remove_const.hpp>
+#include <boost/tti/detail/ddeftype.hpp>
+#include <boost/tti/detail/dmem_data.hpp>
#include <boost/tti/gen/has_member_data_gen.hpp>
#include <boost/tti/gen/namespace_gen.hpp>
-#include <boost/tti/detail/dmem_data.hpp>
-#include <boost/tti/detail/ddeftype.hpp>
+#include <boost/type_traits/remove_const.hpp>
/*
@@ -32,7 +32,7 @@
generates a metafunction called "trait" where 'trait' is the macro parameter.
- template<class TTI_T,class TTI_Type>
+ template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE>
struct trait
{
static const value = unspecified;
@@ -41,13 +41,13 @@
The metafunction types and return:
- TTI_T = the enclosing type in which to look for our 'name'
- OR
- The type of the member data in the form of a pointer
- to member data.
+ BOOST_TTI_TP_ET = the enclosing type in which to look for our 'name'
+ OR
+ The type of the member data in the form of a pointer
+ to member data.
- TTI_Type = (optional) The type of the member data if the first
- parameter is the enclosing type.
+ BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
+ parameter is the enclosing type.
returns = 'value' is true if the 'name' exists, with the correct data type,
otherwise 'value' is false.
@@ -55,14 +55,14 @@
*/
#define BOOST_TTI_TRAIT_HAS_MEMBER_DATA(trait,name) \
BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \
- template<class TTI_T,class TTI_Type = BOOST_TTI_NAMESPACE::detail::deftype> \
+ template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE = BOOST_TTI_NAMESPACE::detail::deftype> \
struct trait : \
BOOST_PP_CAT(trait,_detail_hmd) \
< \
- typename BOOST_TTI_NAMESPACE::detail::dmem_get_type<TTI_T,TTI_Type>::type, \
+ typename BOOST_TTI_NAMESPACE::detail::dmem_get_type<BOOST_TTI_TP_ET,BOOST_TTI_TP_TYPE>::type, \
typename boost::remove_const \
< \
- typename BOOST_TTI_NAMESPACE::detail::dmem_get_enclosing<TTI_T,TTI_Type>::type \
+ typename BOOST_TTI_NAMESPACE::detail::dmem_get_enclosing<BOOST_TTI_TP_ET,BOOST_TTI_TP_TYPE>::type \
>::type \
> \
{ \
@@ -76,7 +76,7 @@
generates a metafunction called "has_member_data_name" where 'name' is the macro parameter.
- template<class TTI_T,class TTI_Type>
+ template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE>
struct has_member_data_name
{
static const value = unspecified;
@@ -85,13 +85,13 @@
The metafunction types and return:
- TTI_T = the enclosing type in which to look for our 'name'
- OR
- The type of the member data in the form of a pointer
- to member data.
+ BOOST_TTI_TP_ET = the enclosing type in which to look for our 'name'
+ OR
+ The type of the member data in the form of a pointer
+ to member data.
- TTI_Type = (optional) The type of the member data if the first
- parameter is the enclosing type.
+ BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
+ parameter is the enclosing type.
returns = 'value' is true if the 'name' exists, with the correct data type,
otherwise 'value' is false.
Modified: trunk/libs/tti/test/Jamfile.v2
==============================================================================
--- trunk/libs/tti/test/Jamfile.v2 (original)
+++ trunk/libs/tti/test/Jamfile.v2 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -89,6 +89,18 @@
;
#
+# Member or static member data
+#
+alias ttidata
+ :
+ [ run test_has_data.cpp ]
+# [ compile test_has_mem_data_compile.cpp ]
+# [ compile-fail test_has_mem_data_fail.cpp ]
+# [ compile-fail test_has_mem_data_fail2.cpp ]
+# [ compile-fail test_has_mem_data_fail3.cpp ]
+ ;
+
+#
# Templates
#
alias ttitmp
Added: trunk/libs/tti/test/test_has_data.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/tti/test/test_has_data.cpp 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -0,0 +1,30 @@
+
+// (C) Copyright Edward Diener 2012
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#include "test_has_data.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+ {
+
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(AnInt)<AType,int>::value));
+ BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(SomeStaticData)<AnotherType,float>::value));
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(AnInt)<AnotherType,long>::value));
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(DSMember)<AType,short>::value));
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,bool>::value));
+ BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,int>::value));
+ BOOST_TEST((DCMember<AnotherType,bool>::value));
+ BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(someDataMember)<AType,short>::value));
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(IntBT)<AType,AType::BType>::value));
+ BOOST_TEST((DStatName<AnotherType,AType::AStructType>::value));
+ BOOST_TEST((DNestedData<AType,AType::BType::CType>::value));
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(CIntValue)<AnotherType,const int>::value));
+ BOOST_TEST((DAOther<AnotherType,AType>::value));
+ BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>::value));
+
+ return boost::report_errors();
+
+ }
Added: trunk/libs/tti/test/test_has_data.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/tti/test/test_has_data.hpp 2012-12-09 23:39:12 EST (Sun, 09 Dec 2012)
@@ -0,0 +1,26 @@
+
+// (C) Copyright Edward Diener 2012
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#if !defined(TEST_HAS_DATA_HPP)
+#define TEST_HAS_DATA_HPP
+
+#include "test_structs.hpp"
+#include <boost/tti/has_data.hpp>
+
+BOOST_TTI_HAS_DATA(AnInt)
+BOOST_TTI_HAS_DATA(DSMember)
+BOOST_TTI_HAS_DATA(aMember)
+BOOST_TTI_TRAIT_HAS_DATA(DCMember,cMem)
+BOOST_TTI_HAS_DATA(someDataMember)
+BOOST_TTI_HAS_DATA(CIntValue)
+BOOST_TTI_HAS_DATA(SomeStaticData)
+BOOST_TTI_TRAIT_HAS_DATA(DStatName,AnStat)
+BOOST_TTI_HAS_DATA(IntBT)
+BOOST_TTI_TRAIT_HAS_DATA(DNestedData,NestedCT)
+BOOST_TTI_TRAIT_HAS_DATA(DAOther,OtherAT)
+BOOST_TTI_HAS_DATA(ONestStr)
+
+#endif // TEST_HAS_DATA_HPP
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk