Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73712 - in sandbox/conversion/libs/conversion_ext: example test
From: vicente.botet_at_[hidden]
Date: 2011-08-13 05:32:42


Author: viboes
Date: 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
New Revision: 73712
URL: http://svn.boost.org/trac/boost/changeset/73712

Log:
conversion: a lot of changes going on for a concept based library allowing overloading of the provided functions.

Added:
   sandbox/conversion/libs/conversion_ext/example/cp_overload.cpp (contents, props changed)
Text files modified:
   sandbox/conversion/libs/conversion_ext/example/even.cpp | 4 +++-
   sandbox/conversion/libs/conversion_ext/example/fallback.cpp | 4 ++++
   sandbox/conversion/libs/conversion_ext/test/Jamfile.v2 | 1 +
   sandbox/conversion/libs/conversion_ext/test/helper.hpp | 4 ++--
   sandbox/conversion/libs/conversion_ext/test/intrinsec.cpp | 1 +
   sandbox/conversion/libs/conversion_ext/test/is_extrinsic_convertible.cpp | 12 ++++++------
   sandbox/conversion/libs/conversion_ext/test/is_extrinsically_explicit_convertible.cpp | 12 ++++++------
   7 files changed, 23 insertions(+), 15 deletions(-)

Added: sandbox/conversion/libs/conversion_ext/example/cp_overload.cpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/libs/conversion_ext/example/cp_overload.cpp 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//[CP_OVERLOAD_CPP
+
+#include <boost/conversion/explicit_convert_to.hpp>
+#include <boost/conversion/is_extrinsically_explicit_convertible.hpp>
+#include <iostream>
+
+namespace UNS {
+ struct S{};
+ int explicit_convert_to(S const&
+ , boost::conversion::dummy::type_tag<int> const&) {
+ return 1;
+ }
+}
+#if defined BOOST_CONVERSION_NO_IS_EXTRINSIC_EXPLICIT_CONVERTIBLE_TAGGED
+namespace boost {
+ namespace conversion {
+ template <>
+ struct is_extrinsically_explicit_convertible_tagged<UNS::S,int>
+ : true_type {};
+ }
+}
+#endif
+int main()
+{
+ using namespace boost::conversion;
+ UNS::S s;
+ std::cout << explicit_convert_to<int>(s) << std::endl;
+
+ return 0;
+}
+
+//]

Modified: sandbox/conversion/libs/conversion_ext/example/even.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/even.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/example/even.cpp 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -11,6 +11,7 @@
 //[EVEN_CPP
 
     #include <boost/conversion/convert_to.hpp>
+ #include <boost/conversion/std/string.hpp>
     #include <iostream>
     using namespace boost::conversion;
 
@@ -21,7 +22,8 @@
     }
     int main()
     {
- if (is_even(2))
+ std::string str = "2";
+ if (is_even(str))
         std::cout << "2 is even" << std::endl;
       else
         std::cout << "2 is odd" << std::endl;

Modified: sandbox/conversion/libs/conversion_ext/example/fallback.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/fallback.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/example/fallback.cpp 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -28,6 +28,10 @@
 
 void convert_to_or_fallback_way()
 {
+ BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible< std::string,int >::value));
+ BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible< short,int >::value));
+ BOOST_STATIC_ASSERT(( boost::conversion::converter_or_fallbacker< int, std::string, short >::value));
+
   std::string str="not an int";
   //[FALLBACK_CPP_CONVERT_TO_OR_FALLBACK
   short f=-1;

Modified: sandbox/conversion/libs/conversion_ext/test/Jamfile.v2
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/Jamfile.v2 (original)
+++ sandbox/conversion/libs/conversion_ext/test/Jamfile.v2 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -87,6 +87,7 @@
      [ run ../example/no_throw.cpp ]
      [ run ../example/fallback.cpp ]
      [ run ../example/overload.cpp ]
+ [ run ../example/cp_overload.cpp ]
     ;
 
 

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-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -26,8 +26,8 @@
 { \
   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 {}; \
+ template <> struct is_assignable< X&, X const& > : true_type {}; \
+ template <> struct is_assignable< X, X > : true_type {}; \
 }
 #else
 #define BOOST_CONVERSION_DCL_DEFAULTS(X)

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-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -214,6 +214,7 @@
 
 }
 void assign_to_with_assignemet_operator() {
+ BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_assignable_tagged< AF_X, X >::value));
   {
     X x;
     //AF_X y1(x); // compile fails

Modified: sandbox/conversion/libs/conversion_ext/test/is_extrinsic_convertible.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/is_extrinsic_convertible.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/is_extrinsic_convertible.cpp 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -230,7 +230,7 @@
 
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<Array&, Array&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<Array&, const Array&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const Array&, Array&>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const Array&, Array&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<const Array&, const Array&>::value));
 
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<Array&, char>::value));
@@ -245,7 +245,7 @@
 
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<Array&, char*>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<Array&, const char*>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const Array&, char*>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const Array&, char*>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<const Array&, const char*>::value));
   }
   {
@@ -272,7 +272,7 @@
 
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<char, Array&>::value));
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<char, const Array&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char, Array&>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char, Array&>::value));
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char, const Array&>::value));
 
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<char, char>::value));
@@ -282,7 +282,7 @@
 
   //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<char, char&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<char, const char&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char, char&>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char, char&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<const char, const char&>::value));
 
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<char, char*>::value));
@@ -324,7 +324,7 @@
 
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<char&, char&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<char&, const char&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char&, char&>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const char&, char&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_convertible<const char&, const char&>::value));
 
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<char&, char*>::value));
@@ -383,6 +383,6 @@
   BOOST_STATIC_ASSERT((boost::conversion::is_extrinsically_convertible<const NonCopyable&, const volatile NonCopyable&>::value));
   BOOST_STATIC_ASSERT((boost::conversion::is_extrinsically_convertible<volatile NonCopyable&, const volatile NonCopyable&>::value));
   BOOST_STATIC_ASSERT((boost::conversion::is_extrinsically_convertible<const volatile NonCopyable&, const volatile NonCopyable&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const NonCopyable&, NonCopyable&>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_convertible<const NonCopyable&, NonCopyable&>::value));
   }
 }

Modified: sandbox/conversion/libs/conversion_ext/test/is_extrinsically_explicit_convertible.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/test/is_extrinsically_explicit_convertible.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/test/is_extrinsically_explicit_convertible.cpp 2011-08-13 05:32:40 EDT (Sat, 13 Aug 2011)
@@ -257,7 +257,7 @@
 #endif
   // BUG BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<Array&, Array&>::value));
   // BUG BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<Array&, const Array&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const Array&, Array&>::value));
+ // BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const Array&, Array&>::value));
   // BUG BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<const Array&, const Array&>::value));
 
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<Array&, char>::value));
@@ -270,10 +270,10 @@
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const Array&, char&>::value));
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const Array&, const char&>::value));
 
- // BUG BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<Array&, char*>::value));
- // BUG BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<Array&, const char*>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const Array&, char*>::value));
- // BUG BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<const Array&, const char*>::value));
+ BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<Array&, char*>::value));
+ BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<Array&, const char*>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const Array&, char*>::value));
+ BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<const Array&, const char*>::value));
   }
   {
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<char, void>::value));
@@ -309,7 +309,7 @@
 
   //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<char, char&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<char, const char&>::value));
- BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const char, char&>::value));
+ //BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<const char, char&>::value));
   BOOST_STATIC_ASSERT(( boost::conversion::is_extrinsically_explicit_convertible<const char, const char&>::value));
 
   BOOST_STATIC_ASSERT((!boost::conversion::is_extrinsically_explicit_convertible<char, char*>::value));


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