Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72862 - sandbox/conversion/libs/conversion_ext/test
From: vicente.botet_at_[hidden]
Date: 2011-07-02 17:00:02


Author: viboes
Date: 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
New Revision: 72862
URL: http://svn.boost.org/trac/boost/changeset/72862

Log:
Conversion: workarround on compilers that don't support is_assignable, is_convertible, ...
Text files modified:
   sandbox/conversion/libs/conversion_ext/test/array.cpp | 8 +++-
   sandbox/conversion/libs/conversion_ext/test/chrono_posix_time_duration.cpp | 1
   sandbox/conversion/libs/conversion_ext/test/extrinsec.cpp | 35 +++++++++++++++++++---
   sandbox/conversion/libs/conversion_ext/test/helper.hpp | 36 +++++++++++++++++++++++
   sandbox/conversion/libs/conversion_ext/test/intrinsec.cpp | 61 ++++++++++++++++++++++++++++++++++-----
   sandbox/conversion/libs/conversion_ext/test/optional.cpp | 16 ++++++++++
   sandbox/conversion/libs/conversion_ext/test/pair.cpp | 11 +++---
   sandbox/conversion/libs/conversion_ext/test/string.cpp | 16 +++++++++
   sandbox/conversion/libs/conversion_ext/test/tuple.cpp | 10 ++++++
   9 files changed, 171 insertions(+), 23 deletions(-)

Modified: sandbox/conversion/libs/conversion_ext/test/array.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/array.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/array.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -16,6 +16,10 @@
 #include <boost/static_assert.hpp>
 
 #if defined(BOOST_CONVERSION_ENABLE_CND)
+BOOST_STATIC_ASSERT(( boost::is_assignable< int&, short const&>::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable< int, short >::value));
+BOOST_STATIC_ASSERT(( boost::is_assignable< short&, int const& >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable< short, int >::value));
 BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable< A1, B1 >::value));
 BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable< boost::array<A1,3>, boost::array<B1,3> >::value));
 #endif
@@ -32,8 +36,8 @@
 
 }
 void explicit_assign_to() {
- boost::array<int,3> bs;
- boost::array<short,3> as;
+ boost::array<short,3> bs;
+ boost::array<int,3> as;
     boost::conversion::assign_to(as,bs);
 }
 

Modified: sandbox/conversion/libs/conversion_ext/test/chrono_posix_time_duration.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/chrono_posix_time_duration.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/chrono_posix_time_duration.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -15,6 +15,7 @@
 
 using namespace boost;
 
+
 typedef int A1;
 typedef short B1;
 

Modified: sandbox/conversion/libs/conversion_ext/test/extrinsec.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/extrinsec.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/extrinsec.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -22,14 +22,30 @@
 #include <boost/static_assert.hpp>
 
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+#define BOOST_CONVERSION_DCL_DEFAULTS(X) \
+namespace boost \
+{ \
+ template <> struct is_constructible< X > : true_type {}; \
+ template <> struct is_constructible< X, X const& > : true_type {}; \
+ template <> struct is_assignable< X&, X const& > : true_type {}; \
+}
+#else
+#define BOOST_CONVERSION_DCL_DEFAULTS(X)
+#endif
+
+
 using namespace boost;
 using namespace boost::conversion;
 
 struct A{};
+BOOST_CONVERSION_DCL_DEFAULTS(A)
 struct B{
   void k(){}
 };
+BOOST_CONVERSION_DCL_DEFAULTS(B)
 struct C{};
+BOOST_CONVERSION_DCL_DEFAULTS(C)
 
 
 #if defined(BOOST_CONVERSION_DOUBLE_CP)
@@ -90,9 +106,10 @@
 
 //////////
 struct X{};
+BOOST_CONVERSION_DCL_DEFAULTS(X)
 
-struct ICF_X {
-};
+struct ICF_X {};
+BOOST_CONVERSION_DCL_DEFAULTS(ICF_X)
 
 namespace boost {
   namespace conversion {
@@ -112,8 +129,8 @@
   BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible< X,ICF_X >::value));
 #endif
 
-struct ECF_X {
-};
+struct ECF_X {};
+BOOST_CONVERSION_DCL_DEFAULTS(ECF_X)
 
 namespace boost {
   namespace conversion {
@@ -173,9 +190,15 @@
   }
 }
 
+
 #if defined(BOOST_CONVERSION_ENABLE_CND)
   BOOST_STATIC_ASSERT(( !boost::is_extrinsic_convertible< X,AF_X >::value));
   BOOST_STATIC_ASSERT(( !boost::is_extrinsic_explicit_convertible< X,AF_X >::value));
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_convertible< X , ICF_X >::value));
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible< X , ICF_X >::value));
+ BOOST_STATIC_ASSERT(( boost::is_copy_assignable< ICF_X >::value));
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable< ICF_X, X >::value));
+
 #endif
 
 //////////////////////////
@@ -195,6 +218,7 @@
       ICF_X y2(mcf(x));
       (void)y2;// remove warning: unused variable
 #endif
+ assign_to(y1,x);
       mat(y1) = x;
     }
   }
@@ -243,6 +267,7 @@
       X x4=mcf(y);
       (void)x4;// remove warning: unused variable
 #endif
+ assign_to(x1,y);
       mat(x1) = y;
     }
 
@@ -287,7 +312,7 @@
   using namespace boost::conversion;
   B b;
   A a;
- assign_to(a, b);
+ //assign_to(a, b);
   mca(a)= b;
   mat(a)= b;
 }

Modified: sandbox/conversion/libs/conversion_ext/test/helper.hpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/helper.hpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/helper.hpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -13,11 +13,34 @@
 
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
+#include <boost/conversion/type_traits/is_convertible.hpp>
+#include <boost/conversion/type_traits/is_constructible.hpp>
+#include <boost/conversion/type_traits/is_explicitly_convertible.hpp>
+#include <boost/conversion/type_traits/is_assignable.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_assignable.hpp>
+
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+#define BOOST_CONVERSION_DCL_DEFAULTS(X) \
+namespace boost \
+{ \
+ template <> struct is_constructible< X > : true_type {}; \
+ template <> struct is_constructible< X, X const& > : true_type {}; \
+template <> struct is_assignable< X&, X const& > : true_type {}; \
+template <> struct is_assignable< X, X > : true_type {}; \
+}
+#else
+#define BOOST_CONVERSION_DCL_DEFAULTS(X)
+#endif
 
 struct A1{};
+BOOST_CONVERSION_DCL_DEFAULTS(A1)
 struct A2{};
+BOOST_CONVERSION_DCL_DEFAULTS(A2)
 struct B1{};
+BOOST_CONVERSION_DCL_DEFAULTS(B1)
 struct B2{};
+BOOST_CONVERSION_DCL_DEFAULTS(B2)
     
 
 namespace boost {
@@ -72,4 +95,17 @@
 
 #endif
 #endif
+
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_convertible<B1, A1>::value));
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_convertible<B2, A2>::value));
+
+
+ #if defined(BOOST_CONVERSION_ENABLE_CND)
+ BOOST_STATIC_ASSERT(( !boost::is_assignable<A1, B1>::value));
+ BOOST_STATIC_ASSERT(( !boost::is_assignable<A2, B2>::value));
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable<A1, B1>::value));
+ BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable<A2, B2>::value));
+ #endif
+
+
 #endif //BOOST_CONVERSION_TEST_HELPER__HPP

Modified: sandbox/conversion/libs/conversion_ext/test/intrinsec.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/intrinsec.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/intrinsec.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -54,14 +54,6 @@
 struct ECF_X {
   explicit ECF_X(X const&) {}
 };
-
-#if defined(BOOST_CONVERSION_ENABLE_CND)
-BOOST_STATIC_ASSERT(( ! boost::is_convertible< X,ECF_X >::value));
-BOOST_STATIC_ASSERT(( boost::is_explicitly_convertible< X,ECF_X >::value));
-BOOST_STATIC_ASSERT(( ! boost::is_extrinsic_convertible< X,ECF_X >::value));
-BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible< X,ECF_X >::value));
-#endif
-
 struct ICT_X {
     operator X() const{ return X(); }
 };
@@ -76,6 +68,55 @@
   AF_X& operator=(X) { return *this; }
 };
 
+
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE)
+namespace boost
+{
+ template <> struct is_constructible< B > : true_type {};
+ template <> struct is_constructible< X > : true_type {};
+}
+#endif
+#if defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE)
+namespace boost
+{
+ template <> struct is_constructible< B, B const& > : true_type {};
+ template <> struct is_constructible< X, X const& > : true_type {};
+ template <> struct is_constructible< ICF_X, X const& > : true_type {};
+ template <> struct is_constructible< ECF_X, X const& > : true_type {};
+ template <> struct is_constructible< ECF_X, X > : true_type {};
+ template <> struct is_constructible< A, int > : true_type {};
+ template <> struct is_constructible< A, B > : true_type {};
+ template <> struct is_constructible< CC, int > : true_type {};
+ template <> struct is_constructible< AA, int > : true_type {};
+ template <> struct is_constructible< AA, A const& > : true_type {};
+ template <> struct is_constructible< CC, B const& > : true_type {};
+ template <> struct is_constructible< AE, B > : true_type {};
+}
+#endif
+#if defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template <> struct is_assignable< X&, X const& > : true_type {};
+ template <> struct is_assignable< B&, B const& > : true_type {};
+ template <> struct is_assignable< A, B > : true_type {};
+ template <> struct is_assignable< CC, B > : true_type {};
+ template <> struct is_assignable< CC, C > : true_type {};
+ template <> struct is_assignable< AA, A > : true_type {};
+ template <> struct is_assignable< AA&, A const& > : true_type {};
+ template <> struct is_assignable< AF_X, X > : true_type {};
+ template <> struct is_assignable< AA, B > : true_type {};
+}
+#endif
+
+
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+BOOST_STATIC_ASSERT(( ! boost::is_convertible< X,ECF_X >::value));
+BOOST_STATIC_ASSERT(( boost::is_explicitly_convertible< X,ECF_X >::value));
+BOOST_STATIC_ASSERT(( ! boost::is_extrinsic_convertible< X,ECF_X >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible< X,ECF_X >::value));
+#endif
+
+
 #if defined(BOOST_CONVERSION_ENABLE_CND)
 BOOST_STATIC_ASSERT(( ! boost::is_explicitly_convertible< X,AF_X >::value));
 BOOST_STATIC_ASSERT(( ! boost::is_extrinsic_convertible< X,AF_X >::value));
@@ -196,6 +237,7 @@
     {
     B b;
     AA aa(1);
+ mca(aa)=b;
     assign_to(aa,b);
     }
 #endif
@@ -218,7 +260,8 @@
     {
     C c;
     CC cc(1);
- assign_to(cc,c);
+ mca(cc)=c;
+ //assign_to(cc,c);
     }
 #endif
 }

Modified: sandbox/conversion/libs/conversion_ext/test/optional.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/optional.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/optional.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -16,6 +16,18 @@
 #include <boost/conversion/try_convert_to.hpp>
 #include <boost/conversion/try_assign_to.hpp>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+#define BOOST_CONVERSION_DCL_DEFAULTS(X) \
+namespace boost \
+{ \
+template <> struct is_constructible< X > : true_type {}; \
+template <> struct is_constructible< X, X const& > : true_type {}; \
+template <> struct is_assignable< X&, X const& > : true_type {}; \
+}
+#else
+#define BOOST_CONVERSION_DCL_DEFAULTS(X)
+#endif
+
 
 #if defined(BOOST_CONVERSION_DOUBLE_CP)
 struct A1{};
@@ -36,7 +48,9 @@
 }
 #else
 struct B1{};
+BOOST_CONVERSION_DCL_DEFAULTS(B1)
 struct C1{};
+BOOST_CONVERSION_DCL_DEFAULTS(C1)
 struct A1{
   A1() {}
   A1(A1 const&) {}
@@ -45,6 +59,8 @@
     throw 1;
   }
 };
+BOOST_CONVERSION_DCL_DEFAULTS(A1)
+
 #endif
 
 void explicit_convert_to()

Modified: sandbox/conversion/libs/conversion_ext/test/pair.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/pair.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/pair.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -20,12 +20,10 @@
 #include <boost/conversion/type_traits/is_explicitly_convertible.hpp>
 #include <boost/conversion/type_traits/is_assignable.hpp>
 #include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_assignable.hpp>
 
 using namespace boost;
 
-BOOST_STATIC_ASSERT(( boost::is_extrinsic_convertible<B1, A1>::value));
-BOOST_STATIC_ASSERT(( boost::is_extrinsic_convertible<B2, A2>::value));
-
 #if defined(BOOST_CONVERSION_ENABLE_CND) || !defined(BOOST_NO_SFINAE_EXPR)
 BOOST_STATIC_ASSERT(( !boost::is_constructible<std::pair<A1,A2>, std::pair<B1,B2> >::value));
 BOOST_STATIC_ASSERT(( !boost::is_explicitly_convertible<std::pair<B1,B2>, std::pair<A1,A2> >::value));
@@ -33,9 +31,10 @@
 #endif
 
 #if defined(BOOST_CONVERSION_ENABLE_CND)
-BOOST_STATIC_ASSERT(( !boost::is_assignable<B1, A1>::value));
-BOOST_STATIC_ASSERT(( !boost::is_assignable<B2, A2>::value));
-BOOST_STATIC_ASSERT(( !boost::is_assignable<std::pair<B1,B2>, std::pair<A1,A2> >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_convertible<std::pair<B1,B2>, std::pair<A1,A2> >::value));
+BOOST_STATIC_ASSERT(( !boost::is_assignable<std::pair<A1,A2>, std::pair<B1,B2> >::value));
+BOOST_STATIC_ASSERT(( boost::conversion::assigner<std::pair<A1,A2>, std::pair<B1,B2> >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable<std::pair<A1,A2>, std::pair<B1,B2> >::value));
 #endif
 
 void explicit_convert_to() {

Modified: sandbox/conversion/libs/conversion_ext/test/string.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/string.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/string.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -13,18 +13,32 @@
 #include <boost/conversion/assign_to.hpp>
 #include <boost/conversion/std/string.hpp>
 #include <boost/detail/lightweight_test.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_assignable.hpp>
+
 
 using namespace boost;
 
 typedef int A1;
 typedef short B1;
 
+
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+BOOST_STATIC_ASSERT(( boost::is_copy_assignable<bool >::value));
+BOOST_STATIC_ASSERT(( boost::is_copy_assignable<std::string >::value));
+BOOST_STATIC_ASSERT(( !boost::is_assignable<std::string, bool >::value));
+BOOST_STATIC_ASSERT(( !boost::is_assignable<bool, std::string >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible<std::string, bool >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible<bool, std::string>::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable<std::string, bool >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable<bool, std::string >::value));
+#endif
+
 void explicit_convert_to() {
   bool b1=true;
   std::string str = boost::conversion::convert_to<std::string>(b1);
   bool b2=boost::conversion::convert_to<bool>(str);
   BOOST_TEST(b2);
-
 }
 void explicit_assign_to() {
   bool b1=true;

Modified: sandbox/conversion/libs/conversion_ext/test/tuple.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/tuple.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/tuple.cpp 2011-07-02 17:00:00 EDT (Sat, 02 Jul 2011)
@@ -17,6 +17,16 @@
 using namespace boost;
 #include <boost/static_assert.hpp>
 
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+BOOST_STATIC_ASSERT(( boost::is_assignable<A1, A1 >::value));
+BOOST_STATIC_ASSERT(( boost::is_assignable<A2, A2 >::value));
+BOOST_STATIC_ASSERT(( boost::is_assignable<fusion::tuple<A1,A2>, fusion::tuple<A1,A2> >::value));
+BOOST_STATIC_ASSERT(( boost::is_assignable<fusion::tuple<A1,A2>&, fusion::tuple<A1,A2> const&>::value));
+BOOST_STATIC_ASSERT(( boost::is_copy_assignable<boost::fusion::tuple<A1,A2> >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_assignable<fusion::tuple<A1,A2>, fusion::tuple<B1,B2> >::value));
+BOOST_STATIC_ASSERT(( boost::is_extrinsic_explicit_convertible<fusion::tuple<B1,B2>, fusion::tuple<A1,A2> >::value));
+#endif
+
 
 void explicit_convert_to() {
     B1 b1;


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