Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57155 - in sandbox/conversion: boost/conversion boost/conversion/boost boost/conversion/std libs/conversion/test
From: vicente.botet_at_[hidden]
Date: 2009-10-25 13:32:05


Author: viboes
Date: 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
New Revision: 57155
URL: http://svn.boost.org/trac/boost/changeset/57155

Log:
TBoost.conversion: v0.4 Applying the same technique that bosst::swap applies.
Either:
* A function with the signature convert_to<Target>(Source const&) is available via argument dependent lookup
Or:
* A template specialization of boost::conversion::convert_to exists for Target and Source
Or:
* Target is copy constructible from Source (default implementation)

Added:
   sandbox/conversion/libs/conversion/test/helper.hpp (contents, props changed)
Text files modified:
   sandbox/conversion/boost/conversion/boost/array.hpp | 24 ++++
   sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 48 ++++++++
   sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 56 +++++++++
   sandbox/conversion/boost/conversion/boost/interval.hpp | 18 +++
   sandbox/conversion/boost/conversion/boost/optional.hpp | 22 +++
   sandbox/conversion/boost/conversion/boost/rational.hpp | 22 +++
   sandbox/conversion/boost/conversion/boost/tuple.hpp | 44 +++++++
   sandbox/conversion/boost/conversion/convert_to.hpp | 28 +++-
   sandbox/conversion/boost/conversion/std/complex.hpp | 3
   sandbox/conversion/boost/conversion/std/pair.hpp | 7
   sandbox/conversion/boost/conversion/std/string.hpp | 3
   sandbox/conversion/libs/conversion/test/array.cpp | 36 ------
   sandbox/conversion/libs/conversion/test/builtins.cpp | 226 ++++++++++++++++++++--------------------
   sandbox/conversion/libs/conversion/test/complex.cpp | 36 ------
   sandbox/conversion/libs/conversion/test/extrinsec.cpp | 5
   sandbox/conversion/libs/conversion/test/interval.cpp | 12 +-
   sandbox/conversion/libs/conversion/test/optional.cpp | 16 +-
   sandbox/conversion/libs/conversion/test/pair.cpp | 37 ------
   sandbox/conversion/libs/conversion/test/rational.cpp | 12 +-
   sandbox/conversion/libs/conversion/test/tuple.cpp | 19 +-
   20 files changed, 403 insertions(+), 271 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-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -15,10 +15,14 @@
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
 #include <algorithm>
+#include <boost/config.hpp>
+
+#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
 
 namespace boost {
 
- namespace partial_specialization_workaround {
+ #ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
+ namespace conversion { namespace partial_specialization_workaround {
         template < typename T1, typename T2, std::size_t N>
         struct convert_to< array<T1,N>, array<T2,N> > {
             inline static array<T1,N> apply(array<T2,N> const & from)
@@ -39,8 +43,26 @@
                 return to;
             }
         };
+ }}
+ #else
+ template < typename T1, typename T2, std::size_t N>
+ inline static array<T1,N> convert_to(array<T2,N> const & from)
+ {
+ array<T1,N> to;
+ boost::assign_to(to, from);
+ return to;
+ }
 
+ template < typename T1, typename T2, std::size_t N>
+ inline static array<T1,N>& assign_to(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]);
+ //}
+ return to;
     }
+ #endif
 }
 
 #endif

Modified: sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -15,10 +15,12 @@
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
+#include <boost/config.hpp>
+#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
 
 namespace boost {
-
- namespace partial_specialization_workaround {
+ #ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
+ namespace conversion { namespace partial_specialization_workaround {
         template < class Rep, class Period>
         struct convert_to<posix_time::time_duration, chrono::duration<Rep, Period> > {
             inline static posix_time::time_duration apply(chrono::duration<Rep, Period> const & from)
@@ -61,7 +63,49 @@
                 return to;
             }
         };
+ }}
+ #else
+ namespace chrono {
+ template < class Rep, class Period>
+ inline static posix_time::time_duration convert_to(chrono::duration<Rep, Period> const & from)
+ {
+ typedef duration<Rep, Period> src_duration_t;
+ typedef nanoseconds duration_t;
+ typedef duration_t::rep rep_t;
+ rep_t d = chrono::duration_cast<duration_t>(from).count();
+ rep_t sec = d/1000000000;
+ rep_t nsec = d%1000000000;
+ return boost::posix_time::seconds(static_cast<long>(sec))+
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+ boost::posix_time::nanoseconds(nsec);
+#else
+ boost::posix_time::microseconds((nsec+500)/1000);
+#endif
+ }
+
+ template < class Rep, class Period>
+ inline static chrono::duration<Rep, Period> & assign_to(chrono::duration<Rep, Period> & to, const posix_time::time_duration& from)
+ {
+ to = boost::convert_to<duration<Rep, Period> >(from);
+ return to;
+ }
+ }
+
+ namespace posix_time {
+ template < class Rep, class Period>
+ inline static chrono::duration<Rep, Period> convert_to(time_duration const & from)
+ {
+ return chrono::duration_cast<chrono::duration<Rep, Period> >(chrono::nanoseconds(from.total_nanoseconds()));
+ }
+
+ template < class Rep, class Period>
+ inline static time_duration& assign_to(time_duration& to, const chrono::duration<Rep, Period>& from)
+ {
+ to = boost::convert_to<time_duration>(from);
+ return to;
+ }
     }
+ #endif
 }
 
 #endif

Modified: sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -17,10 +17,12 @@
 #include <boost/date_time/posix_time/conversion.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
+#include <boost/config.hpp>
+#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
 
 namespace boost {
-
- namespace partial_specialization_workaround {
+ #ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
+ namespace conversion { namespace partial_specialization_workaround {
         template < class Clock, class Duration>
         struct convert_to<posix_time::ptime, chrono::time_point<Clock, Duration> > {
             inline static posix_time::ptime apply(const chrono::time_point<Clock, Duration>& from)
@@ -68,7 +70,57 @@
                 return to;
             }
         };
+ }}
+ #else
+ namespace chrono {
+ template < class Clock, class Duration>
+ struct convert_to<posix_time::ptime, chrono::time_point<Clock, Duration> > {
+ inline static posix_time::ptime apply(const chrono::time_point<Clock, Duration>& from)
+ {
+ typedef chrono::time_point<Clock, Duration> time_point_t;
+ typedef chrono::nanoseconds duration_t;
+ typedef duration_t::rep rep_t;
+ rep_t d = chrono::duration_cast<duration_t>(from.time_since_epoch()).count();
+ rep_t sec = d/1000000000;
+ rep_t nsec = d%1000000000;
+ return boost::posix_time::from_time_t(0)+
+ boost::posix_time::seconds(static_cast<long>(sec))+
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+ boost::posix_time::nanoseconds(nsec);
+#else
+ boost::posix_time::microseconds((nsec+500)/1000);
+#endif
+ }
+ };
+
+ template < class Clock, class Duration>
+ struct assign_to<chrono::time_point<Clock, Duration>, posix_time::ptime> {
+ inline static chrono::time_point<Clock, Duration>& apply(chrono::time_point<Clock, Duration>& to, const posix_time::ptime& from)
+ {
+ to = boost::convert_to<chrono::time_point<Clock, Duration> >(from);
+ return to;
+ }
+ };
+ }
+ namespace posix_time {
+ template < class Clock, class Duration>
+ inline static chrono::time_point<Clock, Duration> convert_to(const ptime& from)
+ {
+ time_duration const time_since_epoch=from-from_time_t(0);
+ chrono::time_point<Clock, Duration> t=chrono::system_clock::from_time_t(time_since_epoch.total_seconds());
+ long nsec=time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second());
+ return t+chrono::nanoseconds(nsec);
+ }
+
+ template < class Clock, class Duration>
+ inline static ptime& assign_to(ptime& to, const chrono::time_point<Clock, Duration>& from)
+ {
+ to = boost::convert_to<ptime>(from);
+ return to;
+ }
+
     }
+ #endif
 }
 
 #endif

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-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -17,7 +17,8 @@
 
 namespace boost {
 
- namespace partial_specialization_workaround {
+ #if 0
+ namespace conversion { namespace partial_specialization_workaround {
         template < class T, class PT, class U, class PU>
         struct convert_to< numeric::interval<T,PT>, numeric::interval<U,PU> > {
             inline static numeric::interval<T,PT> apply(numeric::interval<U,PU> const & from)
@@ -34,7 +35,22 @@
             }
         };
 
+ }}
+ #else
+ namespace numeric {
+ template < class T, class PT, class U, class PU>
+ inline static interval<T,PT> convert_to(interval<U,PU> const & from)
+ {
+ return interval<T,PT>(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ }
+ template < class T, class PT, class U, class PU>
+ inline static interval<T,PT>& assign_to(interval<T,PT>& to, const interval<U,PU>& from)
+ {
+ to.assign(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ return to;
+ }
     }
+ #endif
 }
 
 #endif

Modified: sandbox/conversion/boost/conversion/boost/optional.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/optional.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/optional.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -16,10 +16,14 @@
 #include <boost/none.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
+#include <boost/config.hpp>
 
-namespace boost {
+#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
 
- namespace partial_specialization_workaround {
+namespace boost {
+
+ #ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
+ namespace conversion { namespace partial_specialization_workaround {
         template < class Target, class Source>
         struct convert_to< optional<Target>, optional<Source> > {
             inline static optional<Target> apply(optional<Source> const & from)
@@ -36,7 +40,21 @@
             }
         };
 
+ }}
+ #else
+ template < class Target, class Source>
+ inline static optional<Target> convert_to(optional<Source> const & from)
+ {
+ return (from?optional<Target>(boost::convert_to<Target>(from.get())):optional<Target>());
+ }
+
+ template < class Target, class Source>
+ inline static optional<Target>& assign_to(optional<Target>& to, const optional<Source>& from)
+ {
+ to = from?boost::convert_to<Target>(from.get()):optional<Target>();
+ return to;
     }
+ #endif
 }
 
 #endif

Modified: sandbox/conversion/boost/conversion/boost/rational.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/rational.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/rational.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -14,10 +14,14 @@
 #include <boost/rational.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
+#include <boost/config.hpp>
+
+#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
 
 namespace boost {
 
- namespace partial_specialization_workaround {
+ #ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
+ namespace conversion { namespace partial_specialization_workaround {
         template < class T, class U>
         struct convert_to< rational<T>, rational<U> > {
             inline static rational<T> apply(rational<U> const & from)
@@ -34,7 +38,23 @@
             }
         };
 
+ }}
+ #else
+ template < class T, class U>
+ inline static rational<T> convert_to(rational<U> const & from)
+ {
+ return rational<T>(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ }
+
+ template < class T, class U>
+ inline static rational<T>& assign_to(rational<T>& to, const rational<U>& from)
+ {
+ to.assign(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ return to;
     }
+ #endif
+
+
 }
 
 #endif

Modified: sandbox/conversion/boost/conversion/boost/tuple.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/tuple.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/tuple.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -14,16 +14,18 @@
 #include <boost/fusion/tuple.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
+#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
 
 namespace boost {
 
- namespace partial_specialization_workaround {
+ #ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
+ namespace conversion { namespace partial_specialization_workaround {
         template < class T1, class T2, class U1, class U2>
         struct convert_to< boost::fusion::tuple<T1,T2>, boost::fusion::tuple<U1,U2> > {
             inline static boost::fusion::tuple<T1,T2> apply(boost::fusion::tuple<U1,U2> const & from)
             {
                 return boost::fusion::tuple<T1,T2>(
- boost::convert_to<T1>(boost::fusion::get<0>(from))
+ boost::convert_to<T1>(boost::fusion::get<0>(from))
                     , boost::convert_to<T2>(boost::fusion::get<1>(from))
                 );
             }
@@ -41,7 +43,7 @@
             inline static boost::fusion::tuple<T1,T2,T3> apply(boost::fusion::tuple<U1,U2,U3> const & from)
             {
                 return boost::fusion::tuple<T1,T2, T3>(
- boost::convert_to<T1>(boost::fusion::get<0>(from))
+ boost::convert_to<T1>(boost::fusion::get<0>(from))
                     , boost::convert_to<T2>(boost::fusion::get<1>(from))
                     , boost::convert_to<T3>(boost::fusion::get<2>(from))
                 );
@@ -56,7 +58,43 @@
             }
         };
 
+ }}
+ #else
+ namespace fusion {
+ template < class T1, class T2, class U1, class U2>
+ inline static tuple<T1,T2> convert_to(tuple<U1,U2> const & from)
+ {
+ return tuple<T1,T2>(
+ boost::convert_to<T1>(boost::fusion::get<0>(from))
+ , boost::convert_to<T2>(boost::fusion::get<1>(from))
+ );
     }
+
+ template < class T1, class T2, class U1, class U2>
+ inline static tuple<T1,T2>& assign_to(tuple<T1,T2>& to, tuple<U1,U2> const & from)
+ {
+ to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
+ return to;
+ }
+
+ template < class T1, class T2, class T3, class U1, class U2, class U3>
+ inline static tuple<T1,T2,T3> convert_to(tuple<U1,U2,U3> const & from)
+ {
+ return boost::fusion::tuple<T1,T2, T3>(
+ boost::convert_to<T1>(boost::fusion::get<0>(from))
+ , boost::convert_to<T2>(boost::fusion::get<1>(from))
+ , boost::convert_to<T3>(boost::fusion::get<2>(from))
+ );
+ }
+
+ template < class T1, class T2, class T3, class U1, class U2, class U3>
+ inline static tuple<T1,T2,T3> assign_to(tuple<T1,T2,T3>& to, boost::fusion::tuple<U1,U2,U3> const & from)
+ {
+ to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
+ return to;
+ }
+ }
+ #endif
 }
 
 #endif

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-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -13,18 +13,18 @@
 
 #include <cstddef> //for std::size_t
 
-namespace boost {
-
+namespace boost { namespace conversion {
+
     template < typename To, typename From >
     To convert_to(const From& val);
 
   namespace partial_specialization_workaround {
     template < typename To, typename From >
     struct convert_to {
- inline static To apply(const From& val)
- {
- return To(val);
- }
+ inline static To apply(const From& val)
+ {
+ return To(val);
+ }
     };
 #if 0
     template < typename To, typename From, std::size_t N >
@@ -46,8 +46,24 @@
   To convert_to(const From& val) {
     return partial_specialization_workaround::convert_to<To,From>::apply(val);
   }
+}}
 
+namespace boost_conversion_impl {
+ template <typename Target, typename Source>
+ Target convert_to_impl(Source const& from) {
+ using namespace boost::conversion;
+ //use boost::conversion::convert_to if ADL fails
+ return convert_to<Target>(from);
+ }
 }
 
+namespace boost {
+ template <typename Target, typename Source>
+ Target convert_to(Source const& from) {
+ return ::boost_conversion_impl::convert_to_impl<Target>(from);
+ }
+}
+
+
 #endif
 

Modified: sandbox/conversion/boost/conversion/std/complex.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/complex.hpp (original)
+++ sandbox/conversion/boost/conversion/std/complex.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -16,6 +16,7 @@
 #include <boost/conversion/assign_to.hpp>
 
 namespace boost {
+namespace conversion {
 
     namespace partial_specialization_workaround {
         template < class T, class U>
@@ -36,7 +37,7 @@
         };
 
     }
-}
+}}
 
 #endif
 

Modified: sandbox/conversion/boost/conversion/std/pair.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/pair.hpp (original)
+++ sandbox/conversion/boost/conversion/std/pair.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -13,10 +13,11 @@
 #define BOOST_CONVERT_TO_PAIR__HPP
 
 #include <utility>
-#include <boost/conversion/convert_to.hpp>
+//#include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
 
-namespace boost {
+namespace boost { namespace conversion {
+
     namespace partial_specialization_workaround {
         template < class T1, class T2, class U1, class U2>
         struct convert_to< std::pair<T1,T2>, std::pair<U1,U2> > {
@@ -35,7 +36,7 @@
             }
         };
     }
-}
+}}
 
 #endif
 

Modified: sandbox/conversion/boost/conversion/std/string.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/string.hpp (original)
+++ sandbox/conversion/boost/conversion/std/string.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -17,6 +17,7 @@
 #include <boost/convert/convert.hpp>
 
 namespace boost {
+namespace conversion {
 
     namespace partial_specialization_workaround {
 
@@ -52,7 +53,7 @@
         };
 
     }
-}
+}}
 
 #endif
 

Modified: sandbox/conversion/libs/conversion/test/array.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/array.cpp (original)
+++ sandbox/conversion/libs/conversion/test/array.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -12,45 +12,11 @@
 #include <boost/conversion/boost/array.hpp>
 #include <iostream>
 #include <boost/test/unit_test.hpp>
+#include "helper.hpp"
 
 using namespace boost;
 using namespace boost::unit_test;
 
-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;
- }
- };
- }
-
-
-}
 void explicit_convert_to() {
     boost::array<B1,3> bs;
     boost::array<A1,3> as;

Modified: sandbox/conversion/libs/conversion/test/builtins.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/builtins.cpp (original)
+++ sandbox/conversion/libs/conversion/test/builtins.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -8,10 +8,10 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-#include <boost/conversion/convert_to.hpp>
-#include <boost/conversion/ca_wrapper.hpp>
 #include <iostream>
 #include <boost/test/unit_test.hpp>
+#include <boost/conversion/ca_wrapper.hpp>
+#include <boost/conversion/convert_to.hpp>
 
 using namespace boost;
 using namespace boost::unit_test;
@@ -29,41 +29,41 @@
     unsigned long ul(l);
     
     c=convert_to<char>(c);
- s=convert_to<short>(c);
- i=convert_to<int>(c);
- l=convert_to<long>(c);
- uc=convert_to<unsigned char>(c);
- us=convert_to<unsigned short>(c);
- ui=convert_to<unsigned int>(c);
- ul=convert_to<unsigned long>(c);
-
-
- c=convert_to<char>(s);
- s=convert_to<short>(s);
- i=convert_to<int>(s);
- l=convert_to<long>(s);
- uc=convert_to<unsigned char>(s);
- us=convert_to<unsigned short>(s);
- ui=convert_to<unsigned int>(s);
- ul=convert_to<unsigned long>(s);
-
- c=convert_to<char>(i);
- s=convert_to<short>(i);
- i=convert_to<int>(i);
- l=convert_to<long>(i);
- uc=convert_to<unsigned char>(i);
- us=convert_to<unsigned short>(i);
- ui=convert_to<unsigned int>(i);
- ul=convert_to<unsigned long>(i);
-
- c=convert_to<char>(l);
- s=convert_to<short>(l);
- i=convert_to<int>(l);
- l=convert_to<long>(l);
- uc=convert_to<unsigned char>(l);
- us=convert_to<unsigned short>(l);
- ui=convert_to<unsigned int>(l);
- ul=convert_to<unsigned long>(l);
+ s=boost::convert_to<short>(c);
+ i=boost::convert_to<int>(c);
+ l=boost::convert_to<long>(c);
+ uc=boost::convert_to<unsigned char>(c);
+ us=boost::convert_to<unsigned short>(c);
+ ui=boost::convert_to<unsigned int>(c);
+ ul=boost::convert_to<unsigned long>(c);
+
+
+ c=boost::convert_to<char>(s);
+ s=boost::convert_to<short>(s);
+ i=boost::convert_to<int>(s);
+ l=boost::convert_to<long>(s);
+ uc=boost::convert_to<unsigned char>(s);
+ us=boost::convert_to<unsigned short>(s);
+ ui=boost::convert_to<unsigned int>(s);
+ ul=boost::convert_to<unsigned long>(s);
+
+ c=boost::convert_to<char>(i);
+ s=boost::convert_to<short>(i);
+ i=boost::convert_to<int>(i);
+ l=boost::convert_to<long>(i);
+ uc=boost::convert_to<unsigned char>(i);
+ us=boost::convert_to<unsigned short>(i);
+ ui=boost::convert_to<unsigned int>(i);
+ ul=boost::convert_to<unsigned long>(i);
+
+ c=boost::convert_to<char>(l);
+ s=boost::convert_to<short>(l);
+ i=boost::convert_to<int>(l);
+ l=boost::convert_to<long>(l);
+ uc=boost::convert_to<unsigned char>(l);
+ us=boost::convert_to<unsigned short>(l);
+ ui=boost::convert_to<unsigned int>(l);
+ ul=boost::convert_to<unsigned long>(l);
 }
 
 
@@ -77,45 +77,45 @@
     unsigned int ui(i);
     unsigned long ul(l);
     
- assign_to(c, 0);
- assign_to(c, c);
- assign_to(c, s);
- assign_to(c, i);
- assign_to(c, l);
- assign_to(c, uc);
- assign_to(c, us);
- assign_to(c, ui);
- assign_to(c, ul);
-
- assign_to(s, 1);
- assign_to(s, c);
- assign_to(s, s);
- assign_to(s, i);
- assign_to(s, l);
- assign_to(s, uc);
- assign_to(s, us);
- assign_to(s, ui);
- assign_to(s, ul);
-
- assign_to(i, 2);
- assign_to(i, c);
- assign_to(i, s);
- assign_to(i, i);
- assign_to(i, l);
- assign_to(i, uc);
- assign_to(i, us);
- assign_to(i, ui);
- assign_to(i, ul);
-
- assign_to(l, 3);
- assign_to(l, c);
- assign_to(l, s);
- assign_to(l, i);
- assign_to(l, l);
- assign_to(l, uc);
- assign_to(l, us);
- assign_to(l, ui);
- assign_to(l, ul);
+ boost::assign_to(c, 0);
+ boost::assign_to(c, c);
+ boost::assign_to(c, s);
+ boost::assign_to(c, i);
+ boost::assign_to(c, l);
+ boost::assign_to(c, uc);
+ boost::assign_to(c, us);
+ boost::assign_to(c, ui);
+ boost::assign_to(c, ul);
+
+ boost::assign_to(s, 1);
+ boost::assign_to(s, c);
+ boost::assign_to(s, s);
+ boost::assign_to(s, i);
+ boost::assign_to(s, l);
+ boost::assign_to(s, uc);
+ boost::assign_to(s, us);
+ boost::assign_to(s, ui);
+ boost::assign_to(s, ul);
+
+ boost::assign_to(i, 2);
+ boost::assign_to(i, c);
+ boost::assign_to(i, s);
+ boost::assign_to(i, i);
+ boost::assign_to(i, l);
+ boost::assign_to(i, uc);
+ boost::assign_to(i, us);
+ boost::assign_to(i, ui);
+ boost::assign_to(i, ul);
+
+ boost::assign_to(l, 3);
+ boost::assign_to(l, c);
+ boost::assign_to(l, s);
+ boost::assign_to(l, i);
+ boost::assign_to(l, l);
+ boost::assign_to(l, uc);
+ boost::assign_to(l, us);
+ boost::assign_to(l, ui);
+ boost::assign_to(l, ul);
 }
 
 void mca_assign_to_with_builtin_types() {
@@ -128,41 +128,41 @@
     unsigned int ui(i);
     unsigned long ul(l);
     
- mca(c) = c;
- mca(c) = s;
- mca(c) = i;
- mca(c) = l;
- mca(c) = uc;
- mca(c) = us;
- mca(c) = ui;
- mca(c) = ul;
-
- mca(s) = c;
- mca(s) = s;
- mca(s) = i;
- mca(s) = l;
- mca(s) = uc;
- mca(s) = us;
- mca(s) = ui;
- mca(s) = ul;
-
- mca(i) = c;
- mca(i) = s;
- mca(i) = i;
- mca(i) = l;
- mca(i) = uc;
- mca(i) = us;
- mca(i) = ui;
- mca(i) = ul;
-
- mca(l) = c;
- mca(l) = s;
- mca(l) = i;
- mca(l) = l;
- mca(l) = uc;
- mca(l) = us;
- mca(l) = ui;
- mca(l) = ul;
+ boost::mca(c) = c;
+ boost::mca(c) = s;
+ boost::mca(c) = i;
+ boost::mca(c) = l;
+ boost::mca(c) = uc;
+ boost::mca(c) = us;
+ boost::mca(c) = ui;
+ boost::mca(c) = ul;
+
+ boost::mca(s) = c;
+ boost::mca(s) = s;
+ boost::mca(s) = i;
+ boost::mca(s) = l;
+ boost::mca(s) = uc;
+ boost::mca(s) = us;
+ boost::mca(s) = ui;
+ boost::mca(s) = ul;
+
+ boost::mca(i) = c;
+ boost::mca(i) = s;
+ boost::mca(i) = i;
+ boost::mca(i) = l;
+ boost::mca(i) = uc;
+ boost::mca(i) = us;
+ boost::mca(i) = ui;
+ boost::mca(i) = ul;
+
+ boost::mca(l) = c;
+ boost::mca(l) = s;
+ boost::mca(l) = i;
+ boost::mca(l) = l;
+ boost::mca(l) = uc;
+ boost::mca(l) = us;
+ boost::mca(l) = ui;
+ boost::mca(l) = ul;
         
 }
 
@@ -170,7 +170,7 @@
     int a=0; int b=0; int c=0;
 
     //assign_to(a, assign_to(b, assign_to(c,1)));
- assign_to(a, assign_to(b, c));
+ boost::assign_to(a, boost::assign_to(b, c));
         
 }
     
@@ -178,7 +178,7 @@
     {
     int a=0; int b=0; int c=0;
 
- mca(a) = mca(b) = mca(b) = 1;
+ boost::mca(a) = boost::mca(b) = boost::mca(b) = 1;
         
     }
 }

Modified: sandbox/conversion/libs/conversion/test/complex.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/complex.cpp (original)
+++ sandbox/conversion/libs/conversion/test/complex.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -12,45 +12,11 @@
 #include <boost/conversion/std/complex.hpp>
 #include <iostream>
 #include <boost/test/unit_test.hpp>
+#include "helper.hpp"
 
 using namespace boost;
 using namespace boost::unit_test;
 
-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;
- }
- };
- }
-
-
-}
 void explicit_convert_to() {
     B1 b1;
     B1 b2;

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-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -19,7 +19,7 @@
 struct A{};
 struct B{};
 
-namespace boost {
+namespace boost { namespace conversion {
   template <>
   A convert_to<A,B>(const B& val) {
     return A();
@@ -30,7 +30,8 @@
     return to;
   }
 
-}
+} }
+
 void explicit_convert_to() {
     B b;
     A a(convert_to<A>(b));

Added: sandbox/conversion/libs/conversion/test/helper.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/libs/conversion/test/helper.hpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,51 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONVERSION_TEST_HELPER__HPP
+#define BOOST_CONVERSION_TEST_HELPER__HPP
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
+
+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 conversion { 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 //BOOST_CONVERSION_TEST_HELPER__HPP

Modified: sandbox/conversion/libs/conversion/test/interval.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/interval.cpp (original)
+++ sandbox/conversion/libs/conversion/test/interval.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -22,18 +22,18 @@
 void explicit_convert_to() {
     B1 b1;
     B1 b2;
- boost::numeric::interval<B1> b;
- boost::numeric::interval<A1> a1(convert_to<boost::numeric::interval<A1> >(b));
- boost::numeric::interval<A1> a2(convert_to<boost::numeric::interval<A1> >(boost::numeric::interval<B1>(b1,b2)));
+ numeric::interval<B1> b;
+ numeric::interval<A1> a1(convert_to<numeric::interval<A1> >(b));
+ numeric::interval<A1> a2(convert_to<numeric::interval<A1> >(numeric::interval<B1>(b1,b2)));
     
 }
 void explicit_assign_to() {
     B1 b1;
     B1 b2;
- boost::numeric::interval<A1> a;
- boost::numeric::interval<B1> b;
+ numeric::interval<A1> a;
+ numeric::interval<B1> b;
     assign_to(a,b);
- assign_to(a,boost::numeric::interval<B1>(b1,b2));
+ assign_to(a,numeric::interval<B1>(b1,b2));
 }
 
 test_suite* init_unit_test_suite(int, char*[])

Modified: sandbox/conversion/libs/conversion/test/optional.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/optional.cpp (original)
+++ sandbox/conversion/libs/conversion/test/optional.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -21,19 +21,19 @@
 
 void explicit_convert_to() {
     B1 b1;
- boost::optional<B1> b;
- boost::optional<A1> a1(convert_to<boost::optional<A1> >(b));
- //boost::optional<A1> a1;
- //a1=convert_to<boost::optional<A1> >(b);
- boost::optional<A1> a2(convert_to<boost::optional<A1> >(boost::optional<B1>(b1)));
+ optional<B1> b;
+ optional<A1> a1(convert_to<optional<A1> >(b));
+ //optional<A1> a1;
+ //a1=convert_to<optional<A1> >(b);
+ optional<A1> a2(convert_to<optional<A1> >(optional<B1>(b1)));
     
 }
 void explicit_assign_to() {
     B1 b1;
- boost::optional<A1> a;
- boost::optional<B1> b;
+ optional<A1> a;
+ optional<B1> b;
     //assign_to(b,a);
- assign_to(a, boost::optional<B1>(b1));
+ assign_to(a, optional<B1>(b1));
 }
 
 test_suite* init_unit_test_suite(int, char*[])

Modified: sandbox/conversion/libs/conversion/test/pair.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/pair.cpp (original)
+++ sandbox/conversion/libs/conversion/test/pair.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -9,48 +9,15 @@
 //////////////////////////////////////////////////////////////////////////////
 
 #include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
 #include <boost/conversion/std/pair.hpp>
 #include <iostream>
 #include <boost/test/unit_test.hpp>
+#include "helper.hpp"
 
 using namespace boost;
 using namespace boost::unit_test;
 
-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;
- }
- };
- }
-
-
-}
 void explicit_convert_to() {
     B1 b1;
     B2 b2;

Modified: sandbox/conversion/libs/conversion/test/rational.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/rational.cpp (original)
+++ sandbox/conversion/libs/conversion/test/rational.cpp 2009-10-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -22,18 +22,18 @@
 void explicit_convert_to() {
     B1 b1;
     B1 b2(2);
- boost::rational<B1> b(1,2);
- boost::rational<A1> a1(convert_to<boost::rational<A1> >(b));
- boost::rational<A1> a2(convert_to<boost::rational<A1> >(boost::rational<B1>(b1,b2)));
+ rational<B1> b(1,2);
+ rational<A1> a1(convert_to<rational<A1> >(b));
+ rational<A1> a2(convert_to<rational<A1> >(rational<B1>(b1,b2)));
     
 }
 void explicit_assign_to() {
     B1 b1;
     B1 b2(2);
- boost::rational<A1> a;
- boost::rational<B1> b(1,2);
+ rational<A1> a;
+ rational<B1> b(1,2);
     assign_to(a, b);
- assign_to(a, boost::rational<B1>(b1,b2));
+ assign_to(a, rational<B1>(b1,b2));
 }
 
 test_suite* init_unit_test_suite(int, char*[])

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-25 13:32:02 EDT (Sun, 25 Oct 2009)
@@ -12,10 +12,12 @@
 #include <boost/conversion/boost/tuple.hpp>
 #include <iostream>
 #include <boost/test/unit_test.hpp>
+#include "helper.hpp"
 
 using namespace boost;
 using namespace boost::unit_test;
 
+#if 0
 struct A1{};
 struct A2{};
 struct B1{};
@@ -51,23 +53,24 @@
 
 
 }
+#endif
 void explicit_convert_to() {
     B1 b1;
     B2 b2;
- boost::fusion::tuple<B1,B2> b;
- boost::fusion::tuple<A1,A2> a1(convert_to<boost::fusion::tuple<A1,A2> >(b));
- boost::fusion::tuple<A1,A2> a2(convert_to<boost::fusion::tuple<A1,A2> >(boost::fusion::tuple<B1,B2>(b1,b2)));
- boost::fusion::tuple<A1,A2> a3(convert_to<boost::fusion::tuple<A1,A2> >(boost::fusion::make_tuple(b1,b2)));
+ fusion::tuple<B1,B2> b;
+ fusion::tuple<A1,A2> a1(convert_to<fusion::tuple<A1,A2> >(b));
+ fusion::tuple<A1,A2> a2(convert_to<fusion::tuple<A1,A2> >(fusion::tuple<B1,B2>(b1,b2)));
+ fusion::tuple<A1,A2> a3(convert_to<fusion::tuple<A1,A2> >(fusion::make_tuple(b1,b2)));
     
 }
 void explicit_assign_to() {
     B1 b1;
     B2 b2;
- boost::fusion::tuple<A1,A2> a;
- boost::fusion::tuple<B1,B2> b;
+ fusion::tuple<A1,A2> a;
+ fusion::tuple<B1,B2> b;
     assign_to(a, b);
- assign_to(a, boost::fusion::tuple<B1,B2>(b1,b2));
- assign_to(a, boost::fusion::make_tuple(b1,b2));
+ assign_to(a, fusion::tuple<B1,B2>(b1,b2));
+ assign_to(a, fusion::make_tuple(b1,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