Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72297 - sandbox/conversion/libs/conversion_ext/test
From: vicente.botet_at_[hidden]
Date: 2011-05-31 03:16:47


Author: viboes
Date: 2011-05-31 03:16:45 EDT (Tue, 31 May 2011)
New Revision: 72297
URL: http://svn.boost.org/trac/boost/changeset/72297

Log:
Conversion: Allowing assign_to to be called by ADL
Text files modified:
   sandbox/conversion/libs/conversion_ext/test/builtins.cpp | 24 ++++++------------------
   sandbox/conversion/libs/conversion_ext/test/interval.cpp | 5 ++++-
   sandbox/conversion/libs/conversion_ext/test/intrinsec.cpp | 10 ++++++----
   sandbox/conversion/libs/conversion_ext/test/optional.cpp | 20 +++++++++++++++-----
   sandbox/conversion/libs/conversion_ext/test/rational.cpp | 4 ++--
   5 files changed, 33 insertions(+), 30 deletions(-)

Modified: sandbox/conversion/libs/conversion_ext/test/builtins.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/builtins.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/builtins.cpp 2011-05-31 03:16:45 EDT (Tue, 31 May 2011)
@@ -8,31 +8,19 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-#if 0
-#include <boost/phoenix/core/limits.hpp>
-#include <boost/phoenix/core/call.hpp>
-#include <boost/phoenix/core/expression.hpp>
-#include <boost/phoenix/core/meta_grammar.hpp>
-#include <boost/phoenix/object/detail/target.hpp>
-#include <boost/proto/transform/lazy.hpp>
-#include <boost/phoenix/core/is_actor.hpp>
-
-BOOST_PHOENIX_DEFINE_EXPRESSION(
- (boost)(convert_to)
- , (proto::terminal<boost::phoenix::detail::target<proto::_> >)
- (boost::phoenix::meta_grammar)
-)
-#endif
 
-#include <boost/conversion/fp/convert_to.hpp>
 #include <iostream>
 #include <boost/detail/lightweight_test.hpp>
 #include <boost/conversion/ca_wrapper.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/include.hpp>
-#include <boost/phoenix/core/argument.hpp>
 #include <boost/static_assert.hpp>
 
+#include <boost/conversion/try_convert_to.hpp>
+
+#include <boost/conversion/fp/convert_to.hpp>
+#include <boost/phoenix/core/argument.hpp>
+
 //using namespace boost;
 
 void convert_to_with_builtin_types() {
@@ -230,7 +218,7 @@
 
 void fp_convert_to() {
   {
- char c=0;
+ //char c=0;
     short s=1;
     int i=2;
     long l=3;

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-05-31 03:16:45 EDT (Tue, 31 May 2011)
@@ -13,7 +13,6 @@
 #include <iostream>
 #include <boost/detail/lightweight_test.hpp>
 
-using namespace boost;
 
 typedef int A1;
 typedef short B1;
@@ -25,6 +24,9 @@
     boost::numeric::interval<A1> a1(boost::conversion::convert_to<boost::numeric::interval<A1> >(b));
     boost::numeric::interval<A1> a2(boost::conversion::convert_to<boost::numeric::interval<A1> >(
                 boost::numeric::interval<B1>(b1,b2)));
+ boost::numeric::interval<A1> a3;
+ a3= boost::conversion::convert_to<boost::numeric::interval<A1> >(b);
+ //a3= convert_to<boost::numeric::interval<A1> >(b);
 
 }
 void explicit_assign_to() {
@@ -33,6 +35,7 @@
     boost::numeric::interval<A1> a(1,4);
     boost::numeric::interval<B1> b(1,4);
     boost::conversion::assign_to(a,b);
+ assign_to(a,b);
     boost::conversion::assign_to(a,boost::numeric::interval<B1>(b1,b2));
 }
 

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-05-31 03:16:45 EDT (Tue, 31 May 2011)
@@ -24,16 +24,18 @@
     explicit AE(const B&){}
 };
 struct AA {
- AA(int){}
- AA& operator=(const A&) { return *this;}
+ AA(int){}
+ AA(const A&){}
+ AA& operator=(const A&) { return *this;}
 };
 
 struct C {
     operator B() const{return B();}
 };
 struct CC {
- CC(int){}
- CC& operator=(const B&) { return *this;}
+ CC(int){}
+ CC(const B&){}
+ CC& operator=(const B&) { return *this;}
 };
 
 void convert_to_with_implicit_constructor() {

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-05-31 03:16:45 EDT (Tue, 31 May 2011)
@@ -9,11 +9,12 @@
 //////////////////////////////////////////////////////////////////////////////
 
 #include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
 #include <boost/conversion/boost/optional.hpp>
 #include <iostream>
 #include <boost/detail/lightweight_test.hpp>
+#include <boost/conversion/try_convert_to.hpp>
 
-using namespace boost;
 
 struct A1{};
 struct B1{};
@@ -33,9 +34,9 @@
   B1 b1;
   boost::optional<B1> b;
   boost::optional<A1> a1(boost::conversion::convert_to<boost::optional<A1> >(b));
- optional<A1> a3;
- a3=conversion::convert_to<optional<A1> >(b);
- a3=conversion::convert_to<optional<A1> >(b1);
+ boost::optional<A1> a3;
+ a3=boost::conversion::convert_to<boost::optional<A1> >(b);
+ //a3=convert_to<boost::optional<A1> >(b);
   boost::optional<A1> a2(boost::conversion::convert_to<boost::optional<A1> >(boost::optional<B1>(b1)));
   
 }
@@ -45,14 +46,23 @@
   B1 b1;
   boost::optional<A1> a;
   boost::optional<B1> b;
- //assign_to(b,a);
+ assign_to(a,b);
   boost::conversion::assign_to(a, boost::optional<B1>(b1));
 }
 
+void explicit_try_convert_to()
+{
+ B1 b1;
+ boost::optional<A1> a3;
+ a3=boost::conversion::convert_to<boost::optional<A1> >(b1);
+ a3=boost::conversion::try_convert_to<A1 >(b1);
+
+}
 int main()
 {
   explicit_convert_to();
   explicit_assign_to();
+ explicit_try_convert_to();
   return boost::report_errors();
 }
 

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-05-31 03:16:45 EDT (Tue, 31 May 2011)
@@ -13,8 +13,6 @@
 #include <iostream>
 #include <boost/detail/lightweight_test.hpp>
 
-using namespace boost;
-
 typedef int A1;
 typedef short B1;
 
@@ -24,6 +22,7 @@
     boost::rational<B1> b(1,2);
     boost::rational<A1> a1(boost::conversion::convert_to<boost::rational<A1> >(b));
     boost::rational<A1> a2(boost::conversion::convert_to<boost::rational<A1> >(boost::rational<B1>(b1,b2)));
+ //boost::rational<A1> a3(convert_to<boost::rational<A1> >(b));
 
 }
 void explicit_assign_to() {
@@ -33,6 +32,7 @@
     boost::rational<B1> b(1,2);
     boost::conversion::assign_to(a, b);
     boost::conversion::assign_to(a, boost::rational<B1>(b1,b2));
+ assign_to(a, b);
 }
 
 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