Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57162 - in sandbox/conversion: boost/conversion boost/conversion/boost libs/conversion/test
From: vicente.botet_at_[hidden]
Date: 2009-10-26 18:42:23


Author: viboes
Date: 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
New Revision: 57162
URL: http://svn.boost.org/trac/boost/changeset/57162

Log:
TBoost.conversion: v0.4 Applying the type_tag to help with ADL
Text files modified:
   sandbox/conversion/boost/conversion/boost/array.hpp | 7 +++----
   sandbox/conversion/boost/conversion/boost/interval.hpp | 6 +++---
   sandbox/conversion/boost/conversion/ca_wrapper.hpp | 4 ++--
   sandbox/conversion/boost/conversion/convert_to.hpp | 31 +++++++++++--------------------
   sandbox/conversion/boost/conversion/convert_to_via.hpp | 4 ++--
   sandbox/conversion/libs/conversion/test/extrinsec.cpp | 2 +-
   sandbox/conversion/libs/conversion/test/helper.hpp | 2 +-
   sandbox/conversion/libs/conversion/test/tuple.cpp | 37 -------------------------------------
   8 files changed, 23 insertions(+), 70 deletions(-)

Modified: sandbox/conversion/boost/conversion/boost/array.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/array.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/array.hpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -36,10 +36,9 @@
         struct assign_to< array<T1,N>, array<T2,N> > {
             inline static array<T1,N>& apply(array<T1,N>& to, array<T2,N> const & from)
             {
- std::transform(from.begin(), from.end(), to.begin(), boost::convert_to<T1,T2>);
- //for (unsigned int i =0; i<N; ++i) {
- // to[i]=boost::convert_to<T1>(from[i]);
- //}
+ for (unsigned int i =0; i<N; ++i) {
+ to[i]=boost::convert_to<T1>(from[i]);
+ }
                 return to;
             }
         };

Modified: sandbox/conversion/boost/conversion/boost/interval.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/interval.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/interval.hpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -8,8 +8,8 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-#ifndef BOOST_CONVERT_TO_PAIR__HPP
-#define BOOST_CONVERT_TO_PAIR__HPP
+#ifndef BOOST_CONVERT_TO_INTERVAL__HPP
+#define BOOST_CONVERT_TO_INTERVAL__HPP
 
 #include <boost/numeric/interval.hpp>
 #include <boost/conversion/convert_to.hpp>
@@ -39,7 +39,7 @@
     #else
     namespace numeric {
         template < class T, class PT, class U, class PU>
- inline static interval<T,PT> convert_to(interval<U,PU> const & from)
+ inline static interval<T,PT> convert_to(interval<U,PU> const & from, type_tag<interval<T,PT> >)
         {
             return interval<T,PT>(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
         }

Modified: sandbox/conversion/boost/conversion/ca_wrapper.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/ca_wrapper.hpp (original)
+++ sandbox/conversion/boost/conversion/ca_wrapper.hpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -23,11 +23,11 @@
         ca_wrapper(T& r) : ref_(r) {}
         template <typename U>
         operator U() {
- return convert_to<U>(ref_);
+ return boost::convert_to<U>(ref_);
         }
         template <typename U>
         T& operator =(U const& u) {
- return assign_to(ref_, u);
+ return boost::assign_to(ref_, u);
         }
     };
 

Modified: sandbox/conversion/boost/conversion/convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to.hpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -13,10 +13,14 @@
 
 #include <cstddef> //for std::size_t
 
-namespace boost { namespace conversion {
+namespace boost {
+ template <typename T>
+ struct type_tag {};
+
+ namespace conversion {
     
- template < typename To, typename From >
- To convert_to(const From& val);
+ //template < typename To, typename From >
+ //To convert_to(const From& val, type_tag<To> p=type_tag<To>());
 
   namespace partial_specialization_workaround {
     template < typename To, typename From >
@@ -26,26 +30,13 @@
             return To(val);
         }
     };
-#if 0
- template < typename To, typename From, std::size_t N >
- struct convert_to<To[N],From[N]> {
- inline static To[N] apply(const From (& val)[N])
- {
- To[N] to;
- for (std::size_t i = 0; i < N; ++i)
- {
- to[i] = boost::convert(from[i]);
- }
- return to;
- }
- };
-#endif
   }
 
   template < typename To, typename From >
- To convert_to(const From& val) {
+ To convert_to(const From& val, type_tag<To>) {
     return partial_specialization_workaround::convert_to<To,From>::apply(val);
   }
+
 }}
 
 namespace boost_conversion_impl {
@@ -53,13 +44,13 @@
     Target convert_to_impl(Source const& from) {
         using namespace boost::conversion;
         //use boost::conversion::convert_to if ADL fails
- return convert_to<Target>(from);
+ return convert_to<Target, Source>(from, boost::type_tag<Target>());
     }
 }
 
 namespace boost {
     template <typename Target, typename Source>
- Target convert_to(Source const& from) {
+ Target convert_to(Source const& from, type_tag<Target> p=type_tag<Target>()) {
         return ::boost_conversion_impl::convert_to_impl<Target>(from);
     }
 }

Modified: sandbox/conversion/boost/conversion/convert_to_via.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to_via.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to_via.hpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -16,8 +16,8 @@
 namespace boost {
 
     template < typename To, typename Via, typename From >
- To convert_to_via(const From& val) {
- convert_to<To>(convert_to<Via>(val));
+ To convert_to_via(const From& val, type_tag<To>) {
+ boost::convert_to(boost::convert_to(val, type_tag<Via>()), type_tag<To>());
     }
 
 }

Modified: sandbox/conversion/libs/conversion/test/extrinsec.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/extrinsec.cpp (original)
+++ sandbox/conversion/libs/conversion/test/extrinsec.cpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -21,7 +21,7 @@
 
 namespace boost { namespace conversion {
   template <>
- A convert_to<A,B>(const B& val) {
+ A convert_to<A,B>(const B& val, type_tag<A>) {
     return A();
   }
 

Modified: sandbox/conversion/libs/conversion/test/helper.hpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/helper.hpp (original)
+++ sandbox/conversion/libs/conversion/test/helper.hpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -21,7 +21,7 @@
 
 namespace boost {
     template <>
- A1 convert_to<A1,B1>(const B1& val) {
+ A1 convert_to<A1,B1>(const B1& val, type_tag<A1>) {
         return A1();
     }
 

Modified: sandbox/conversion/libs/conversion/test/tuple.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/tuple.cpp (original)
+++ sandbox/conversion/libs/conversion/test/tuple.cpp 2009-10-26 18:42:22 EDT (Mon, 26 Oct 2009)
@@ -17,43 +17,6 @@
 using namespace boost;
 using namespace boost::unit_test;
 
-#if 0
-struct A1{};
-struct A2{};
-struct B1{};
-struct B2{};
-
-namespace boost {
- template <>
- A1 convert_to<A1,B1>(const B1& val) {
- return A1();
- }
-
- template <>
- A1& assign_to<A1,B1>(A1& to, const B1& from) {
- return to;
- }
-
- namespace partial_specialization_workaround {
- template <>
- struct convert_to< A2,B2 > {
- inline static A2 apply(B2 const & from)
- {
- return A2();
- }
- };
- template < >
- struct assign_to< A2,B2 > {
- inline static A2& apply(A2& to, const B2& from)
- {
- return to;
- }
- };
- }
-
-
-}
-#endif
 void explicit_convert_to() {
     B1 b1;
     B2 b2;


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