|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65922 - in sandbox/tti/boost/tti: . detail
From: eldiener_at_[hidden]
Date: 2010-10-12 09:02:55
Author: eldiener
Date: 2010-10-12 09:02:52 EDT (Tue, 12 Oct 2010)
New Revision: 65922
URL: http://svn.boost.org/trac/boost/changeset/65922
Log:
Initial source
Added:
sandbox/tti/boost/tti/TTIntrospection.h (contents, props changed)
sandbox/tti/boost/tti/detail/TTIntrospectionDetail.h (contents, props changed)
Added: sandbox/tti/boost/tti/TTIntrospection.h
==============================================================================
--- (empty file)
+++ sandbox/tti/boost/tti/TTIntrospection.h 2010-10-12 09:02:52 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,186 @@
+#pragma once
+#include <boost/config.hpp>
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/variadic_macro_data/VariadicMacroData.hpp>
+#include "detail/TTIntrospectionDetail.h"
+
+#define TTI_TRAIT_HAS_TYPE(trait,name) \
+namespace tti \
+ { \
+ namespace detail \
+ { \
+ BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, false) \
+ } \
+ template<class T> \
+ struct BOOST_PP_CAT(has_type_,name) \
+ { \
+ typedef typename BOOST_PP_CAT(tti::detail::,trait)<T>::type type; \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=type::value); \
+ }; \
+ } \
+/**/
+
+#define TTI_HAS_TYPE(name) \
+ TTI_TRAIT_HAS_TYPE \
+ ( \
+ BOOST_PP_CAT(has_type_,name), \
+ name \
+ ) \
+/**/
+
+#define TTI_TRAIT_HAS_TYPE_CHECK_TYPEDEF(trait,name) \
+namespace tti \
+ { \
+ namespace detail \
+ { \
+ BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, false) \
+ } \
+ \
+ template<class T,class U,class B> \
+ struct BOOST_PP_CAT(trait,_impl) \
+ { \
+ typedef typename \
+ boost::mpl::eval_if \
+ < \
+ boost::is_same<typename T::name,U>, \
+ boost::mpl::true_, \
+ boost::mpl::false_ \
+ >::type \
+ type; \
+ }; \
+ \
+ template<class T,class U> \
+ struct BOOST_PP_CAT(trait,_impl)<T,U,boost::mpl::false_::type> \
+ { \
+ typedef boost::mpl::false_::type type; \
+ }; \
+ \
+ template<class T,class U> \
+ struct trait \
+ { \
+ \
+ typedef typename \
+ BOOST_PP_CAT(trait,_impl) \
+ < \
+ T, \
+ U, \
+ typename BOOST_PP_CAT(tti::detail::,trait)<T>::type \
+ >::type \
+ type; \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=type::value); \
+ }; \
+ } \
+/**/
+
+#define TTI_HAS_TYPE_CHECK_TYPEDEF(name) \
+ TTI_TRAIT_HAS_TYPE_CHECK_TYPEDEF \
+ ( \
+ BOOST_PP_CAT(has_type_check_,name), \
+ name \
+ ) \
+/**/
+
+#define TTI_TRAIT_HAS_TEMPLATE(trait,name) \
+namespace tti \
+ { \
+ namespace detail \
+ { \
+ BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, false) \
+ } \
+ template<class T> \
+ struct trait \
+ { \
+ typedef typename BOOST_PP_CAT(tti::detail::,trait)<T>::type type; \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=type::value); \
+ }; \
+ } \
+/**/
+
+#define TTI_HAS_TEMPLATE(name) \
+ TTI_TRAIT_HAS_TEMPLATE \
+ ( \
+ BOOST_PP_CAT(has_template_,name), \
+ name \
+ ) \
+/**/
+
+#if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
+#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
+#define TTI_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,tpSeq) \
+namespace tti \
+ { \
+ TTI_DETAIL_HAS_MEMBER_WITH_FUNCTION_SFINAE \
+ ( \
+ ( BOOST_PP_ADD(BOOST_PP_SEQ_SIZE(tpSeq),4), ( trait, name, 1, false, BOOST_PP_SEQ_ENUM(tpSeq) ) ) \
+ ) \
+ } \
+/**/
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+#define TTI_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
+namespace tti \
+ { \
+ TTI_DETAIL_HAS_MEMBER_WITH_FUNCTION_SFINAE \
+ ( \
+ ( BOOST_PP_ADD(VMD_DATA_SIZE(__VA_ARGS__),4), ( trait, name, 1, false, __VA_ARGS__ ) ) \
+ ) \
+ } \
+/**/
+#endif // !defined(BOOST_NO_VARIADIC_MACROS)
+#else
+#define TTI_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,tpSeq) \
+namespace tti \
+ { \
+ TTI_DETAIL_HAS_MEMBER_WITH_TEMPLATE_SFINAE \
+ ( \
+ ( BOOST_PP_ADD(BOOST_PP_SEQ_SIZE(tpSeq),4), ( trait, name, 1, false, BOOST_PP_SEQ_ENUM(tpSeq) ) ) \
+ ) \
+ } \
+/**/
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+#define TTI_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
+namespace tti \
+ { \
+ TTI_DETAIL_HAS_MEMBER_WITH_TEMPLATE_SFINAE \
+ ( \
+ ( BOOST_PP_ADD(VMD_DATA_SIZE(__VA_ARGS__),4), ( trait, name, 1, false, __VA_ARGS__ ) ) \
+ ) \
+ } \
+/**/
+#endif // !defined(BOOST_NO_VARIADIC_MACROS)
+#endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
+#else
+#define TTI_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,tpSeq) \
+TTI_DETAIL_SAME(trait,name) \
+/**/
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+#define TTI_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
+TTI_DETAIL_SAME(trait,name) \
+/**/
+#endif // !defined(BOOST_NO_VARIADIC_MACROS)
+#endif // !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
+
+#define TTI_HAS_TEMPLATE_CHECK_PARAMS(name,tpSeq) \
+ TTI_TRAIT_HAS_TEMPLATE_CHECK_PARAMS \
+ ( \
+ BOOST_PP_CAT(has_template_check_,name), \
+ name, \
+ tpSeq \
+ ) \
+/**/
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+#define TTI_VM_HAS_TEMPLATE_CHECK_PARAMS(name,...) \
+ TTI_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS \
+ ( \
+ BOOST_PP_CAT(has_template_check_,name), \
+ name, \
+ __VA_ARGS__ \
+ ) \
+/**/
+#endif
Added: sandbox/tti/boost/tti/detail/TTIntrospectionDetail.h
==============================================================================
--- (empty file)
+++ sandbox/tti/boost/tti/detail/TTIntrospectionDetail.h 2010-10-12 09:02:52 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,159 @@
+#pragma once
+#include <boost/config.hpp>
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/preprocessor/array/elem.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/arithmetic/add.hpp>
+#include <boost/preprocessor/arithmetic/sub.hpp>
+#include <boost/preprocessor/array/size.hpp>
+
+#if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
+#define TTI_DETAIL_TEMPLATE_PARAMETERS(z,n,args) \
+BOOST_PP_ARRAY_ELEM(BOOST_PP_ADD(4,n),args) \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_IMPLEMENTATION(args,introspect_macro) \
+ template \
+ < \
+ typename T, \
+ typename fallback_ \
+ = boost::mpl::bool_< BOOST_PP_ARRAY_ELEM(3, args) > \
+ > \
+ class BOOST_PP_ARRAY_ELEM(0, args) \
+ { \
+ introspect_macro(args) \
+ public: \
+ static const bool value \
+ = BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args)< T >::value; \
+ typedef typename BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args) \
+ < \
+ T \
+ >::type type; \
+ }; \
+/**/
+#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
+#define TTI_DETAIL_HAS_MEMBER_MULTI_SUBSTITUTE(z,n,args) \
+ template \
+ < \
+ template \
+ < \
+ BOOST_PP_ENUM_ ## z \
+ ( \
+ BOOST_PP_SUB \
+ ( \
+ BOOST_PP_ARRAY_SIZE(args), \
+ 4 \
+ ), \
+ TTI_DETAIL_TEMPLATE_PARAMETERS, \
+ args \
+ ) \
+ > \
+ class V \
+ > \
+ struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) \
+ { \
+ }; \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_SUBSTITUTE(args) \
+ BOOST_PP_REPEAT \
+ ( \
+ BOOST_PP_ARRAY_ELEM(2, args), \
+ TTI_DETAIL_HAS_MEMBER_MULTI_SUBSTITUTE, \
+ args \
+ ) \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_INTROSPECT(args) \
+ template< typename U > \
+ struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args) \
+ { \
+ TTI_DETAIL_HAS_MEMBER_SUBSTITUTE(args) \
+ BOOST_MPL_HAS_MEMBER_REJECT(args, BOOST_PP_NIL) \
+ BOOST_MPL_HAS_MEMBER_ACCEPT(args, BOOST_PP_NIL) \
+ BOOST_STATIC_CONSTANT \
+ ( \
+ bool, value = BOOST_MPL_HAS_MEMBER_TEST(args) \
+ ); \
+ typedef boost::mpl::bool_< value > type; \
+ }; \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_WITH_FUNCTION_SFINAE(args) \
+ TTI_DETAIL_HAS_MEMBER_IMPLEMENTATION \
+ ( \
+ args, \
+ TTI_DETAIL_HAS_MEMBER_INTROSPECT \
+ ) \
+/**/
+#else
+#define TTI_DETAIL_HAS_MEMBER_MULTI_SUBSTITUTE_WITH_TEMPLATE_SFINAE(z,n,args) \
+ template \
+ < \
+ template \
+ < \
+ BOOST_PP_ENUM_ ## z \
+ ( \
+ BOOST_PP_SUB \
+ ( \
+ BOOST_PP_ARRAY_SIZE(args), \
+ 4 \
+ ), \
+ TTI_DETAIL_TEMPLATE_PARAMETERS, \
+ args \
+ ) \
+ > \
+ class U \
+ > \
+ struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE \
+ ( \
+ args, \
+ n \
+ ) \
+ { \
+ typedef \
+ BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_TAG_NAME(args) \
+ type; \
+ }; \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_SUBSTITUTE_WITH_TEMPLATE_SFINAE(args) \
+ typedef void \
+ BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_TAG_NAME(args); \
+ BOOST_PP_REPEAT \
+ ( \
+ BOOST_PP_ARRAY_ELEM(2, args), \
+ TTI_DETAIL_HAS_MEMBER_MULTI_SUBSTITUTE_WITH_TEMPLATE_SFINAE, \
+ args \
+ ) \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_INTROSPECT_WITH_TEMPLATE_SFINAE(args) \
+ BOOST_MPL_HAS_MEMBER_REJECT_WITH_TEMPLATE_SFINAE(args,BOOST_PP_NIL) \
+ BOOST_MPL_HAS_MEMBER_ACCEPT_WITH_TEMPLATE_SFINAE(args,BOOST_PP_NIL) \
+ template< typename U > \
+ struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args) \
+ : BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)< U > { \
+ }; \
+/**/
+#define TTI_DETAIL_HAS_MEMBER_WITH_TEMPLATE_SFINAE(args) \
+ TTI_DETAIL_HAS_MEMBER_SUBSTITUTE_WITH_TEMPLATE_SFINAE \
+ ( \
+ args \
+ ) \
+ TTI_DETAIL_HAS_MEMBER_IMPLEMENTATION \
+ ( \
+ args, \
+ TTI_DETAIL_HAS_MEMBER_INTROSPECT_WITH_TEMPLATE_SFINAE \
+ ) \
+/**/
+#endif
+#else
+#define TTI_DETAIL_SAME(trait,name) \
+namespace tti \
+ { \
+ BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF \
+ ( \
+ trait, \
+ name, \
+ false \
+ ) \
+ } \
+/**/
+#endif
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