Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73130 - sandbox/conversion/boost/conversion/type_traits
From: vicente.botet_at_[hidden]
Date: 2011-07-15 21:31:10


Author: viboes
Date: 2011-07-15 21:31:10 EDT (Fri, 15 Jul 2011)
New Revision: 73130
URL: http://svn.boost.org/trac/boost/changeset/73130

Log:
conversion: fix is_constructible on void, abstract types
Text files modified:
   sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp | 147 +++++++++++++++++----------------------
   1 files changed, 66 insertions(+), 81 deletions(-)

Modified: sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp (original)
+++ sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp 2011-07-15 21:31:10 EDT (Fri, 15 Jul 2011)
@@ -134,9 +134,8 @@
   template <class T, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX), class A, = type_traits_detail_is_constructible::nat BOOST_PP_INTERCEPT)> \
   struct is_constructible;
 
-#if defined BOOST_CONVERSION_IS_CONSTRUCTIBLE_USES_DECLTYPE
-
   namespace type_traits_detail_is_constructible {
+#if defined BOOST_CONVERSION_IS_CONSTRUCTIBLE_USES_DECLTYPE
 
     template <class T>
     decltype((T(), true_type()))
@@ -176,6 +175,69 @@
 #undef M0
 #undef M1
 
+//////////////
+
+
+#elif defined BOOST_CONVERSION_IS_CONSTRUCTIBLE_USES_SIZEOF
+
+
+#define M1(z,n,t) declval<A##n>()
+
+#define M0(z,n,t) \
+template<bool, class T, BOOST_PP_ENUM_PARAMS(n, class A)> \
+struct imp##n \
+{ \
+ template<class X> \
+ static type_traits_detail_is_constructible::yes_type \
+ test(type_traits_detail_is_constructible::dummy<sizeof(X(BOOST_PP_ENUM(n, M1, ~)))>*); \
+ \
+ template<class X> \
+ static type_traits_detail_is_constructible::no_type \
+ test(...); \
+ \
+ static const bool value = sizeof(test<T>(0)) == sizeof(type_traits_detail_is_constructible::yes_type); \
+ typedef boost::integral_constant<bool,value> type; \
+};
+
+BOOST_PP_REPEAT_FROM_TO(1,BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
+#undef M0
+#undef M1
+
+#if ! defined BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE
+
+ template<bool, class T>
+ struct imp0
+ {
+ template<class X>
+ static type_traits_detail_is_constructible::yes_type
+ test(type_traits_detail_is_constructible::dummy<sizeof(X(),int())>*);
+
+ template<class X>
+ static type_traits_detail_is_constructible::no_type
+ test(...);
+
+ static const bool value = sizeof(test<T>(0)) == sizeof(type_traits_detail_is_constructible::yes_type);
+ typedef boost::integral_constant<bool,value> type;
+ };
+
+#endif
+
+
+#else
+
+#define M0(z,n,t) \
+template<bool, class T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
+struct imp##n \
+ : boost::false_type \
+{ \
+};
+
+ BOOST_PP_REPEAT_FROM_TO(0,BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
+#undef M0
+
+#endif
+//////////////
+
       template <class T>
       struct imp0<true, T>
           : public is_scalar<T>
@@ -227,7 +289,7 @@
 
   }
 
-
+#if 1
 #define M1(z,n,t) || is_void<A##n>::value
 
 #define M0(z,n,t) \
@@ -241,7 +303,7 @@
 
 BOOST_PP_REPEAT(BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
 #undef M0
-
+#endif
 
   namespace type_traits_detail_is_constructible {
     template <class A, std::size_t N>
@@ -262,84 +324,7 @@
   }
 
 
-#elif defined BOOST_CONVERSION_IS_CONSTRUCTIBLE_USES_SIZEOF
-
 
-#define M1(z,n,t) declval<A##n>()
-
-#define M0(z,n,t) \
-template<class T, BOOST_PP_ENUM_PARAMS(n, class A)> \
-struct is_constructible<T, BOOST_PP_ENUM_PARAMS(n, A)> \
-{ \
- template<class X> \
- static type_traits_detail_is_constructible::yes_type \
- test(type_traits_detail_is_constructible::dummy<sizeof(X(BOOST_PP_ENUM(n, M1, ~)))>*); \
- \
- template<class X> \
- static type_traits_detail_is_constructible::no_type \
- test(...); \
- \
- static const bool value = sizeof(test<T>(0)) == sizeof(type_traits_detail_is_constructible::yes_type); \
- typedef boost::integral_constant<bool,value> type; \
-};
-
-BOOST_PP_REPEAT_FROM_TO(1,BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
-#undef M0
-#undef M1
-
-#if ! defined BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE
-#define M1(z,n,t) type_traits_detail_is_constructible::nat
-
- template<class T>
- struct is_constructible<T>
- {
- template<class X>
- static type_traits_detail_is_constructible::yes_type
- test(type_traits_detail_is_constructible::dummy<sizeof(X(),int())>*);
-
- template<class X>
- static type_traits_detail_is_constructible::no_type
- test(...);
-
- static const bool value = sizeof(test<T>(0)) == sizeof(type_traits_detail_is_constructible::yes_type);
- typedef boost::integral_constant<bool,value> type;
- };
-
- template<>
- struct is_constructible<void, BOOST_PP_ENUM(BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M1, ~)>
- : boost::false_type
- {
- };
-
-#undef M1
-
-#endif
-
-
-#define M0(z,n,t) \
-template<class A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
-struct is_constructible<void, A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
- : boost::false_type \
-{ \
-};
-
-BOOST_PP_REPEAT(BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
-#undef M0
-
-
-#else
-
-#define M0(z,n,t) \
-template<class T, BOOST_PP_ENUM_PARAMS(n, class A)> \
-struct is_constructible<T, BOOST_PP_ENUM_PARAMS(n, A)> \
- : boost::false_type \
-{ \
-};
-
- BOOST_PP_REPEAT_FROM_TO(1,BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
-#undef M0
-
-#endif
 
 #ifdef BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE
     // default constructor


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