Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72345 - sandbox/conversion/libs/conversion_ext/test
From: vicente.botet_at_[hidden]
Date: 2011-06-02 11:25:03


Author: viboes
Date: 2011-06-02 11:25:02 EDT (Thu, 02 Jun 2011)
New Revision: 72345
URL: http://svn.boost.org/trac/boost/changeset/72345

Log:
Conversion: making double CP conditional
Text files modified:
   sandbox/conversion/libs/conversion_ext/test/extrinsec.cpp | 22 +++++++++++++++++++++-
   sandbox/conversion/libs/conversion_ext/test/helper.hpp | 2 ++
   sandbox/conversion/libs/conversion_ext/test/interval.cpp | 2 ++
   sandbox/conversion/libs/conversion_ext/test/optional.cpp | 16 +++++++++++++++-
   sandbox/conversion/libs/conversion_ext/test/rational.cpp | 2 ++
   5 files changed, 42 insertions(+), 2 deletions(-)

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-06-02 11:25:02 EDT (Thu, 02 Jun 2011)
@@ -21,6 +21,7 @@
 
 void f(B) {}
 
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
   A convert_to(const B&, boost::conversion::dummy::type_tag<A> const&) {
     return A();
   }
@@ -36,7 +37,26 @@
   B& assign_to(B& to, const C&) {
     return to;
   }
-
+#else
+ namespace boost {
+ namespace conversion {
+ template <>
+ struct converter< A,B > {
+ A operator()(B const &)
+ {
+ return A();
+ }
+ };
+ template <>
+ struct converter< B,C > {
+ B operator()(C const &)
+ {
+ return B();
+ }
+ };
+ }
+ }
+#endif
 void explicit_convert_to() {
     B b;
     A a(boost::conversion::convert_to<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-06-02 11:25:02 EDT (Thu, 02 Jun 2011)
@@ -53,6 +53,7 @@
 
     }
 }
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     A1 convert_to(const B1&, boost::conversion::dummy::type_tag<A1> const&) {
         return A1();
@@ -70,4 +71,5 @@
     }
 
 #endif
+#endif
 #endif //BOOST_CONVERSION_TEST_HELPER__HPP

Modified: sandbox/conversion/libs/conversion_ext/test/interval.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/interval.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/interval.cpp 2011-06-02 11:25:02 EDT (Thu, 02 Jun 2011)
@@ -34,7 +34,9 @@
     boost::numeric::interval<A1> a(1,4);
     boost::numeric::interval<B1> b(1,4);
     boost::conversion::assign_to(a,b);
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
     assign_to(a,b);
+#endif
     boost::conversion::assign_to(a,boost::numeric::interval<B1>(b1,b2));
 }
 

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-06-02 11:25:02 EDT (Thu, 02 Jun 2011)
@@ -17,6 +17,7 @@
 #include <boost/conversion/try_assign_to.hpp>
 
 
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
 struct A1{};
 struct B1{};
 struct C1{};
@@ -33,7 +34,18 @@
 {
   return to;
 }
-
+#else
+struct B1{};
+struct C1{};
+struct A1{
+ A1() {}
+ A1(A1 const&) {}
+ A1(B1 const&) {}
+ A1(C1 const&) {
+ throw 1;
+ }
+};
+#endif
 
 void explicit_convert_to()
 {
@@ -86,6 +98,7 @@
     boost::conversion::assign_to(a, boost::optional<B1>(b1));
     BOOST_TEST(a);
   }
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
   { // assign_to can be used when found by ADL
     B1 b1;
     boost::optional<A1> a;
@@ -93,6 +106,7 @@
     assign_to(a,b);
     BOOST_TEST(a);
   }
+#endif
 }
 
 void explicit_try_convert_to()

Modified: sandbox/conversion/libs/conversion_ext/test/rational.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/rational.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/rational.cpp 2011-06-02 11:25:02 EDT (Thu, 02 Jun 2011)
@@ -32,7 +32,9 @@
     boost::rational<B1> b(1,2);
     boost::conversion::assign_to(a, b);
     boost::conversion::assign_to(a, boost::rational<B1>(b1,b2));
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
     assign_to(a, b);
+#endif
 }
 
 int main( )


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