|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66915 - in sandbox/tti/boost/tti: . detail
From: eldiener_at_[hidden]
Date: 2010-11-30 15:14:02
Author: eldiener
Date: 2010-11-30 15:14:02 EST (Tue, 30 Nov 2010)
New Revision: 66915
URL: http://svn.boost.org/trac/boost/changeset/66915
Log:
Added static member functionality
Text files modified:
sandbox/tti/boost/tti/TTIntrospection.hpp | 175 +++++++++++++++++++++++++++++++++++++++
sandbox/tti/boost/tti/detail/TTIntrospectionDetail.hpp | 43 +++++++--
2 files changed, 206 insertions(+), 12 deletions(-)
Modified: sandbox/tti/boost/tti/TTIntrospection.hpp
==============================================================================
--- sandbox/tti/boost/tti/TTIntrospection.hpp (original)
+++ sandbox/tti/boost/tti/TTIntrospection.hpp 2010-11-30 15:14:02 EST (Tue, 30 Nov 2010)
@@ -30,7 +30,7 @@
template<class T> \
struct trait \
{ \
- typedef typename tti::detail::trait<T>::type type; \
+ typedef typename tti::detail::hastype::trait<T>::type type; \
\
BOOST_STATIC_CONSTANT(bool,value=type::value); \
}; \
@@ -59,7 +59,7 @@
typedef typename \
boost::mpl::eval_if \
< \
- tti::detail::trait<T>, \
+ tti::detail::hastype::trait<T>, \
tti::detail::membertype::trait<T>, \
tti::detail::notype \
>::type \
@@ -228,6 +228,68 @@
/**/
#endif
+#if defined(BOOST_NO_NULLPTR)
+#define TTI_TRAIT_HAS_MEMBER(trait,name) \
+namespace tti \
+ { \
+ template<class T> \
+ struct trait \
+ { \
+ template<class> \
+ struct class_of; \
+ \
+ template<class R,class C> \
+ struct class_of<R C::*> \
+ { \
+ typedef C type; \
+ }; \
+ \
+ template<class F> \
+ struct class_type \
+ { \
+ typedef typename \
+ boost::mpl::eval_if \
+ < \
+ boost::function_types::is_member_object_pointer<F>, \
+ class_of<F>, \
+ boost::remove_const \
+ < \
+ typename \
+ boost::mpl::at \
+ < \
+ typename \
+ boost::function_types::parameter_types \
+ < \
+ F, \
+ boost::mpl::quote1 \
+ < \
+ boost::mpl::identity \
+ > \
+ > \
+ ::type, \
+ boost::mpl::int_<0> \
+ >::type \
+ > \
+ >::type \
+ type; \
+ }; \
+ \
+ template<T> \
+ struct helper; \
+ \
+ template<class U> \
+ static ::boost::type_traits::yes_type check(helper<&U::name> *); \
+ \
+ template<class U> \
+ static ::boost::type_traits::no_type check(...); \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=sizeof(check<typename class_type<T>::type>(0))==sizeof(::boost::type_traits::yes_type)); \
+ \
+ typedef trait type; \
+ }; \
+ } \
+/**/
+#else
#define TTI_TRAIT_HAS_MEMBER(trait,name) \
namespace tti \
{ \
@@ -288,7 +350,8 @@
}; \
} \
/**/
-
+#endif
+
#define TTI_HAS_MEMBER(name) \
TTI_TRAIT_HAS_MEMBER \
( \
@@ -297,8 +360,63 @@
) \
/**/
+#if defined(BOOST_NO_NULLPTR)
+#define TTI_TRAIT_HAS_STATIC_MEMBER(trait,name) \
+namespace tti \
+ { \
+ template<class T,class Type> \
+ struct trait \
+ { \
+ template<Type *> \
+ struct helper; \
+ \
+ template<class U> \
+ static ::boost::type_traits::yes_type check(helper<&U::name> *); \
+ \
+ template<class U> \
+ static ::boost::type_traits::no_type check(...); \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=sizeof(check<T>(0))==sizeof(::boost::type_traits::yes_type)); \
+ \
+ typedef trait type; \
+ }; \
+ } \
+/**/
+#else
+#define TTI_TRAIT_HAS_STATIC_MEMBER(trait,name) \
+namespace tti \
+ { \
+ template<class T,class Type> \
+ struct trait \
+ { \
+ template<Type *> \
+ struct helper; \
+ \
+ template<class U> \
+ static ::boost::type_traits::yes_type check(helper<&U::name> *); \
+ \
+ template<class U> \
+ static ::boost::type_traits::no_type check(...); \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=sizeof(check<T>(nullptr))==sizeof(::boost::type_traits::yes_type)); \
+ \
+ typedef trait type; \
+ }; \
+ } \
+/**/
+#endif
+
+#define TTI_HAS_STATIC_MEMBER(name) \
+ TTI_TRAIT_HAS_STATIC_MEMBER \
+ ( \
+ BOOST_PP_CAT(has_static_member_,name), \
+ name \
+ ) \
+/**/
+
namespace tti
{
+
template
<
class T,
@@ -324,6 +442,7 @@
>
{
};
+
template
<
class T,
@@ -347,6 +466,56 @@
>
{
};
+
+ template
+ <
+ class T,
+ template<class,class> class HasStaticMember,
+ class R,
+ BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(TTI_MAX_PARAMETERS,class P,tti::detail::noparam)
+ >
+ struct mf_has_static_function :
+ tti::detail::eval
+ <
+ HasStaticMember
+ <
+ boost::mpl::identity<T>,
+ tti::detail::eval
+ <
+ tti::detail::tfunction
+ <
+ R,
+ BOOST_PP_ENUM_PARAMS(TTI_MAX_PARAMETERS,P)
+ >
+ >
+ >
+ >
+ {
+ };
+
+ template
+ <
+ class T,
+ template<class,class> class HasStaticMember,
+ class R
+ >
+ struct mf_has_static_data :
+ tti::detail::eval
+ <
+ HasStaticMember
+ <
+ boost::mpl::identity<T>,
+ tti::detail::eval
+ <
+ tti::detail::tdata
+ <
+ R
+ >
+ >
+ >
+ >
+ {
+ };
}
#endif // TT_INTROSPECTION_HPP
Modified: sandbox/tti/boost/tti/detail/TTIntrospectionDetail.hpp
==============================================================================
--- sandbox/tti/boost/tti/detail/TTIntrospectionDetail.hpp (original)
+++ sandbox/tti/boost/tti/detail/TTIntrospectionDetail.hpp 2010-11-30 15:14:02 EST (Tue, 30 Nov 2010)
@@ -20,6 +20,7 @@
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/function_types/member_function_pointer.hpp>
+#include <boost/function_types/function_type.hpp>
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
#define TTI_DETAIL_TEMPLATE_PARAMETERS(z,n,args) \
@@ -182,17 +183,20 @@
/**/
#define TTI_DETAIL_TRAIT_HAS_TYPE(trait,name) \
-namespace mpl \
+namespace hastype \
{ \
- BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, false) \
+ namespace mpl \
+ { \
+ BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, false) \
+ } \
+ template<class T> \
+ struct trait \
+ { \
+ typedef typename mpl::trait<T>::type type; \
+ \
+ BOOST_STATIC_CONSTANT(bool,value=type::value); \
+ }; \
} \
-template<class T> \
-struct trait \
- { \
- typedef typename tti::detail::mpl::trait<T>::type type; \
- \
- BOOST_STATIC_CONSTANT(bool,value=type::value); \
- }; \
/**/
#define TTI_DETAIL_PP_REPEAT_CLASS(z,n,data) \
@@ -249,6 +253,27 @@
{
typedef R T::* type;
};
+
+ template
+ <
+ class R,
+ BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(TTI_MAX_PARAMETERS,class P,tti::detail::noparam)
+ >
+ struct tfunction
+ {
+ typedef boost::mpl::vector<R,BOOST_PP_ENUM_PARAMS(TTI_MAX_PARAMETERS,P) > fseq;
+ typedef typename boost::mpl::remove<fseq,tti::detail::noparam>::type ftseq;
+ typedef typename boost::function_types::function_type<ftseq>::type type;
+ };
+
+ template
+ <
+ class R
+ >
+ struct tdata
+ {
+ typedef R type;
+ };
}
}
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