|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57168 - in sandbox/conversion: boost/conversion boost/conversion/boost boost/conversion/std libs/conversion/test
From: vicente.botet_at_[hidden]
Date: 2009-10-27 04:46:51
Author: viboes
Date: 2009-10-27 04:46:48 EDT (Tue, 27 Oct 2009)
New Revision: 57168
URL: http://svn.boost.org/trac/boost/changeset/57168
Log:
TBoost.conversion: v0.4 Changing the namespaces to get ADL
Added:
sandbox/conversion/boost/conversion/assign_to.hpp (contents, props changed)
Text files modified:
sandbox/conversion/boost/conversion/boost/array.hpp | 20 +-
sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 21 ++-
sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 37 +++---
sandbox/conversion/boost/conversion/boost/interval.hpp | 10
sandbox/conversion/boost/conversion/boost/optional.hpp | 14 +-
sandbox/conversion/boost/conversion/boost/rational.hpp | 12 +-
sandbox/conversion/boost/conversion/boost/tuple.hpp | 37 +++--
sandbox/conversion/boost/conversion/ca_wrapper.hpp | 8
sandbox/conversion/boost/conversion/convert_to.hpp | 68 +++++------
sandbox/conversion/boost/conversion/convert_to_via.hpp | 9
sandbox/conversion/boost/conversion/std/complex.hpp | 6
sandbox/conversion/boost/conversion/std/pair.hpp | 6
sandbox/conversion/libs/conversion/test/array.cpp | 4
sandbox/conversion/libs/conversion/test/builtins.cpp | 228 ++++++++++++++++++++--------------------
sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp | 16 +-
sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp | 8
sandbox/conversion/libs/conversion/test/complex.cpp | 8
sandbox/conversion/libs/conversion/test/extrinsec.cpp | 8
sandbox/conversion/libs/conversion/test/helper.hpp | 8
sandbox/conversion/libs/conversion/test/interval.cpp | 15 +-
sandbox/conversion/libs/conversion/test/intrinsec.cpp | 18 +-
sandbox/conversion/libs/conversion/test/optional.cpp | 24 ++-
sandbox/conversion/libs/conversion/test/pair.cpp | 12 +-
sandbox/conversion/libs/conversion/test/rational.cpp | 16 +-
sandbox/conversion/libs/conversion/test/tuple.cpp | 12 +-
25 files changed, 319 insertions(+), 306 deletions(-)
Added: sandbox/conversion/boost/conversion/assign_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/assign_to.hpp 2009-10-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -0,0 +1,70 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 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_ASSIGN_TO__HPP
+#define BOOST_CONVERSION_ASSIGN_TO__HPP
+
+#include <cstddef> //for std::size_t
+#include <boost/conversion/convert_to.hpp>
+#include <boost/swap.hpp>
+
+namespace boost {
+ namespace conversion {
+ namespace partial_specialization_workaround {
+ template < typename To, typename From >
+ struct assign_to {
+ inline static To& apply(To& to, const From& from)
+ {
+ to = from;
+ return to;
+ }
+ };
+ template < typename To, typename From, std::size_t N >
+ struct assign_to<To[N],From[N]> {
+ inline static To*& apply(To(&to)[N], const From(& from)[N])
+ {
+ for (std::size_t i = 0; i < N; ++i)
+ {
+ to[i] = boost::conversion::convert_to(from[i], boost::dummy::type_tag<To>());
+ }
+ return to;
+ }
+ };
+ }
+ }
+
+ namespace conversion_default {
+ template < typename To, typename From >
+ To& assign_to(To& to, const From& from) {
+ return conversion::partial_specialization_workaround::assign_to<To,From>::apply(to, from);
+ }
+ }
+
+ namespace conversion_impl {
+ template <typename Target, typename Source>
+ Target& assign_to_impl(Target& to, const Source& from) {
+ using namespace boost::conversion_default;
+ //use boost::conversion::assign_to if ADL fails
+ return assign_to(to, from);
+ }
+ }
+
+ namespace conversion {
+ template <typename Target, typename Source>
+ Target& assign_to(Target& to, const Source& from) {
+ return conversion_impl::assign_to_impl<Target, Source>(to, from);
+ }
+ }
+}
+
+
+
+#endif
+
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -17,7 +17,7 @@
#include <algorithm>
#include <boost/config.hpp>
-#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
+//#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
namespace boost {
@@ -28,7 +28,7 @@
inline static array<T1,N> apply(array<T2,N> const & from)
{
array<T1,N> to;
- boost::assign_to(to, from);
+ conversion::assign_to(to, from);
return to;
}
};
@@ -37,7 +37,7 @@
inline static array<T1,N>& apply(array<T1,N>& to, array<T2,N> const & from)
{
for (unsigned int i =0; i<N; ++i) {
- to[i]=boost::convert_to<T1>(from[i]);
+ to[i]=conversion::convert_to<T1>(from[i]);
}
return to;
}
@@ -45,20 +45,20 @@
}}
#else
template < typename T1, typename T2, std::size_t N>
- inline static array<T1,N> convert_to(array<T2,N> const & from)
+ inline array<T1,N> convert_to(array<T2,N> const & from
+ , boost::dummy::type_tag<array<T1,N> >)
{
array<T1,N> to;
- boost::assign_to(to, from);
+ conversion::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)
+ inline 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]);
- //}
+ for (unsigned int i =0; i<N; ++i) {
+ to[i]=conversion::convert_to<T1>(from[i]);
+ }
return to;
}
#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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -16,7 +16,8 @@
#include <boost/conversion/convert_to.hpp>
#include <boost/conversion/assign_to.hpp>
#include <boost/config.hpp>
-#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
+
+//#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
namespace boost {
#ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
@@ -43,7 +44,7 @@
struct assign_to<posix_time::time_duration, chrono::duration<Rep, Period> > {
inline static posix_time::time_duration& apply(posix_time::time_duration& to, const chrono::duration<Rep, Period>& from)
{
- to = boost::convert_to<posix_time::time_duration>(from);
+ to = conversion::convert_to<posix_time::time_duration>(from);
return to;
}
};
@@ -59,7 +60,7 @@
struct assign_to<chrono::duration<Rep, Period>, posix_time::time_duration> {
inline static chrono::duration<Rep, Period> & apply(chrono::duration<Rep, Period> & to, const posix_time::time_duration& from)
{
- to = boost::convert_to<chrono::duration<Rep, Period> >(from);
+ to = conversion::convert_to<chrono::duration<Rep, Period> >(from);
return to;
}
};
@@ -67,7 +68,8 @@
#else
namespace chrono {
template < class Rep, class Period>
- inline static posix_time::time_duration convert_to(chrono::duration<Rep, Period> const & from)
+ inline posix_time::time_duration convert_to(chrono::duration<Rep, Period> const & from
+ , boost::dummy::type_tag<posix_time::time_duration>)
{
typedef duration<Rep, Period> src_duration_t;
typedef nanoseconds duration_t;
@@ -84,24 +86,25 @@
}
template < class Rep, class Period>
- inline static chrono::duration<Rep, Period> & assign_to(chrono::duration<Rep, Period> & to, const posix_time::time_duration& from)
+ inline 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);
+ to = conversion::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)
+ inline chrono::duration<Rep, Period> convert_to(time_duration const & from
+ , boost::dummy::type_tag<chrono::duration<Rep, Period> >)
{
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)
+ inline time_duration& assign_to(time_duration& to, const chrono::duration<Rep, Period>& from)
{
- to = boost::convert_to<time_duration>(from);
+ to = conversion::convert_to<time_duration>(from);
return to;
}
}
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -18,7 +18,8 @@
#include <boost/conversion/convert_to.hpp>
#include <boost/conversion/assign_to.hpp>
#include <boost/config.hpp>
-#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
+
+//#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
namespace boost {
#ifdef BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING
@@ -46,7 +47,7 @@
struct assign_to<posix_time::ptime, chrono::time_point<Clock, Duration> > {
inline static posix_time::ptime& apply(posix_time::ptime& to, const chrono::time_point<Clock, Duration>& from)
{
- to = boost::convert_to<posix_time::ptime>(from);
+ to = conversion::convert_to<posix_time::ptime>(from);
return to;
}
};
@@ -66,7 +67,7 @@
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);
+ to = conversion::convert_to<chrono::time_point<Clock, Duration> >(from);
return to;
}
};
@@ -74,9 +75,9 @@
#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)
- {
+ inline posix_time::ptime convert_to(const chrono::time_point<Clock, Duration>& from
+ , boost::dummy::type_tag<posix_time::ptime>)
+ {
typedef chrono::time_point<Clock, Duration> time_point_t;
typedef chrono::nanoseconds duration_t;
typedef duration_t::rep rep_t;
@@ -90,21 +91,21 @@
#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;
- }
- };
+ inline chrono::time_point<Clock, Duration>& assign_to(chrono::time_point<Clock, Duration>& to, const posix_time::ptime& from)
+ {
+ to = conversion::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)
+ inline chrono::time_point<Clock, Duration> convert_to(const ptime& from
+ , boost::dummy::type_tag<chrono::time_point<Clock, Duration> >)
{
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());
@@ -113,9 +114,9 @@
}
template < class Clock, class Duration>
- inline static ptime& assign_to(ptime& to, const chrono::time_point<Clock, Duration>& from)
+ inline ptime& assign_to(ptime& to, const chrono::time_point<Clock, Duration>& from)
{
- to = boost::convert_to<ptime>(from);
+ to = conversion::convert_to<ptime>(from);
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -23,14 +23,14 @@
struct convert_to< numeric::interval<T,PT>, numeric::interval<U,PU> > {
inline static numeric::interval<T,PT> apply(numeric::interval<U,PU> const & from)
{
- return numeric::interval<T,PT>(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ return numeric::interval<T,PT>(conversion::convert_to<T>(from.lower()), conversion::convert_to<U>(from.upper()));
}
};
template < class T, class PT, class U, class PU>
struct assign_to< numeric::interval<T,PT>, numeric::interval<U,PU> > {
inline static numeric::interval<T,PT>& apply(numeric::interval<T,PT>& to, const numeric::interval<U,PU>& from)
{
- to.assign(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ to.assign(conversion::convert_to<T>(from.lower()), conversion::convert_to<U>(from.upper()));
return to;
}
};
@@ -39,14 +39,14 @@
#else
namespace numeric {
template < class T, class PT, class U, class PU>
- inline static interval<T,PT> convert_to(interval<U,PU> const & from, type_tag<interval<T,PT> >)
+ inline static interval<T,PT> convert_to(interval<U,PU> const & from, boost::dummy::type_tag<interval<T,PT> >)
{
- return interval<T,PT>(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ return interval<T,PT>(conversion::convert_to<T>(from.lower()), conversion::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()));
+ to.assign(conversion::convert_to<T>(from.lower()),conversion::convert_to<U>(from.upper()));
return to;
}
}
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -18,7 +18,7 @@
#include <boost/conversion/assign_to.hpp>
#include <boost/config.hpp>
-#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
+//#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
namespace boost {
@@ -28,14 +28,14 @@
struct convert_to< optional<Target>, optional<Source> > {
inline static optional<Target> apply(optional<Source> const & from)
{
- return (from?optional<Target>(boost::convert_to<Target>(from.get())):optional<Target>());
+ return (from?optional<Target>(conversion::convert_to<Target>(from.get())):optional<Target>());
}
};
template < class Target, class Source>
struct assign_to< optional<Target>, optional<Source> > {
inline static optional<Target>& apply(optional<Target>& to, const optional<Source>& from)
{
- to = from?boost::convert_to<Target>(from.get()):optional<Target>();
+ to = from?conversion::convert_to<Target>(from.get()):optional<Target>();
return to;
}
};
@@ -43,15 +43,15 @@
}}
#else
template < class Target, class Source>
- inline static optional<Target> convert_to(optional<Source> const & from)
+ inline optional<Target> convert_to(optional<Source> const & from, boost::dummy::type_tag<optional<Target> >)
{
- return (from?optional<Target>(boost::convert_to<Target>(from.get())):optional<Target>());
+ return (from?optional<Target>(conversion::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)
+ inline optional<Target>& assign_to(optional<Target>& to, const optional<Source>& from)
{
- to = from?boost::convert_to<Target>(from.get()):optional<Target>();
+ to = from?conversion::convert_to<Target>(from.get()):optional<Target>();
return to;
}
#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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -16,7 +16,7 @@
#include <boost/conversion/assign_to.hpp>
#include <boost/config.hpp>
-#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
+//#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
namespace boost {
@@ -26,14 +26,14 @@
struct convert_to< rational<T>, rational<U> > {
inline static rational<T> apply(rational<U> const & from)
{
- return rational<T>(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ return rational<T>(conversion::convert_to<T>(from.numerator()), conversion::convert_to<T>(from.denominator()));
}
};
template < class T, class U>
struct assign_to< rational<T>, rational<U> > {
inline static rational<T>& apply(rational<T>& to, const rational<U>& from)
{
- to.assign(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ to.assign(conversion::convert_to<T>(from.numerator()), conversion::convert_to<T>(from.denominator()));
return to;
}
};
@@ -41,15 +41,15 @@
}}
#else
template < class T, class U>
- inline static rational<T> convert_to(rational<U> const & from)
+ inline static rational<T> convert_to(rational<U> const & from, boost::dummy::type_tag<rational<T> >)
{
- return rational<T>(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ return rational<T>(conversion::convert_to<T>(from.numerator()), conversion::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()));
+ to.assign(conversion::convert_to<T>(from.numerator()), conversion::convert_to<T>(from.denominator()));
return to;
}
#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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -14,7 +14,8 @@
#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
+
+//#define BOOST_CONVERSION_NO_FUNCTION_TEMPLATE_ORDERING 1
namespace boost {
@@ -25,8 +26,8 @@
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<T2>(boost::fusion::get<1>(from))
+ conversion::convert_to<T1>(boost::fusion::get<0>(from))
+ , conversion::convert_to<T2>(boost::fusion::get<1>(from))
);
}
};
@@ -34,7 +35,7 @@
struct assign_to< boost::fusion::tuple<T1,T2>, boost::fusion::tuple<U1,U2> > {
inline static boost::fusion::tuple<T1,T2>& apply(boost::fusion::tuple<T1,T2>& to, boost::fusion::tuple<U1,U2> const & from)
{
- to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
+ to = conversion::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
}
};
@@ -43,9 +44,9 @@
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<T2>(boost::fusion::get<1>(from))
- , boost::convert_to<T3>(boost::fusion::get<2>(from))
+ conversion::convert_to<T1>(boost::fusion::get<0>(from))
+ , conversion::convert_to<T2>(boost::fusion::get<1>(from))
+ , conversion::convert_to<T3>(boost::fusion::get<2>(from))
);
}
};
@@ -53,7 +54,7 @@
struct assign_to< boost::fusion::tuple<T1,T2,T3>, boost::fusion::tuple<U1,U2,U3> > {
inline static boost::fusion::tuple<T1,T2,T3> apply(boost::fusion::tuple<T1,T2,T3>& to, boost::fusion::tuple<U1,U2,U3> const & from)
{
- to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
+ to = conversion::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
}
};
@@ -62,35 +63,37 @@
#else
namespace fusion {
template < class T1, class T2, class U1, class U2>
- inline static tuple<T1,T2> convert_to(tuple<U1,U2> const & from)
+ inline static tuple<T1,T2> convert_to(tuple<U1,U2> const & from
+ , boost::dummy::type_tag<tuple<T1,T2> >)
{
return tuple<T1,T2>(
- boost::convert_to<T1>(boost::fusion::get<0>(from))
- , boost::convert_to<T2>(boost::fusion::get<1>(from))
+ conversion::convert_to<T1>(boost::fusion::get<0>(from))
+ , conversion::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);
+ to = conversion::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)
+ inline static tuple<T1,T2,T3> convert_to(tuple<U1,U2,U3> const & from
+ , boost::dummy::type_tag<tuple<T1,T2,T3> >)
{
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))
+ conversion::convert_to<T1>(boost::fusion::get<0>(from))
+ , conversion::convert_to<T2>(boost::fusion::get<1>(from))
+ , conversion::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);
+ to = conversion::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
}
}
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -14,7 +14,7 @@
#include <boost/conversion/convert_to.hpp>
#include <boost/conversion/assign_to.hpp>
-namespace boost {
+namespace boost { namespace conversion {
template <typename T>
class ca_wrapper {
@@ -23,11 +23,11 @@
ca_wrapper(T& r) : ref_(r) {}
template <typename U>
operator U() {
- return boost::convert_to<U>(ref_);
+ return boost::conversion::convert_to<U>(ref_);
}
template <typename U>
T& operator =(U const& u) {
- return boost::assign_to(ref_, u);
+ return boost::conversion::assign_to(ref_, u);
}
};
@@ -36,7 +36,7 @@
return ca_wrapper<T>(r);
}
-}
+}}
#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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -14,47 +14,43 @@
#include <cstddef> //for std::size_t
namespace boost {
- template <typename T>
- struct type_tag {};
-
+ namespace dummy {
+ template <typename T>
+ struct type_tag {};
+ }
namespace conversion {
-
- //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 >
- struct convert_to {
- inline static To apply(const From& val)
- {
- return To(val);
+ namespace partial_specialization_workaround {
+ template < typename To, typename From >
+ struct convert_to {
+ inline static To apply(const From& val)
+ {
+ return To(val);
+ }
+ };
}
- };
- }
-
- template < typename To, typename From >
- To convert_to(const From& val, type_tag<To>) {
- 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, Source>(from, boost::type_tag<Target>());
}
-}
-
-namespace boost {
- template <typename Target, typename Source>
- Target convert_to(Source const& from, type_tag<Target> p=type_tag<Target>()) {
- return ::boost_conversion_impl::convert_to_impl<Target>(from);
+ namespace conversion_default {
+ template < typename To, typename From >
+ To convert_to(const From& val, dummy::type_tag<To>) {
+ return conversion::partial_specialization_workaround::convert_to<To,From>::apply(val);
+ }
+ }
+ namespace conversion_impl {
+ template <typename Target, typename Source>
+ Target convert_to_impl(Source const& from) {
+ using namespace boost::conversion_default;
+ //use boost::conversion::convert_to if ADL fails
+ return convert_to(from, boost::dummy::type_tag<Target>());
+ }
}
+ namespace conversion {
+ template <typename Target, typename Source>
+ Target convert_to(Source const& from, boost::dummy::type_tag<Target> p=boost::dummy::type_tag<Target>()) {
+ return conversion_impl::convert_to_impl<Target>(from);
+ }
+
+ }
}
-
#endif
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -13,14 +13,13 @@
#include <boost/conversion/convert_to.hpp>
-namespace boost {
+namespace boost { namespace conversion {
template < typename To, typename Via, typename From >
- To convert_to_via(const From& val, type_tag<To>) {
- boost::convert_to(boost::convert_to(val, type_tag<Via>()), type_tag<To>());
+ To convert_to_via(const From& val) {
+ boost::convert_to<To>(boost::convert_to<Via>(val));
}
-
-}
+}}
#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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -23,15 +23,15 @@
struct convert_to< std::complex<T>, std::complex<U> > {
inline static std::complex<T> apply(std::complex<U> const & from)
{
- return std::complex<T>(boost::convert_to<T>(from.real()), boost::convert_to<T>(from.imag()));
+ return std::complex<T>(conversion::convert_to<T>(from.real()), conversion::convert_to<T>(from.imag()));
}
};
template < class T, class U>
struct assign_to< std::complex<T>, std::complex<U> > {
inline static std::complex<T>& apply(std::complex<T>& to, const std::complex<U>& from)
{
- to.real() = boost::convert_to<T>(from.real());
- to.imag() = boost::convert_to<T>(from.imag());
+ to.real() = conversion::convert_to<T>(from.real());
+ to.imag() = conversion::convert_to<T>(from.imag());
return to;
}
};
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -23,15 +23,15 @@
struct convert_to< std::pair<T1,T2>, std::pair<U1,U2> > {
inline static std::pair<T1,T2> apply(std::pair<U1,U2> const & from)
{
- return std::pair<T1,T2>(boost::convert_to<T1>(from.first), boost::convert_to<T2>(from.second));
+ return std::pair<T1,T2>(conversion::convert_to<T1>(from.first), conversion::convert_to<T2>(from.second));
}
};
template < class T1, class T2, class U1, class U2>
struct assign_to< std::pair<T1,T2>, std::pair<U1,U2> > {
inline static std::pair<T1,T2>& apply(std::pair<T1,T2>& to, const std::pair<U1,U2>& from)
{
- to.first = boost::convert_to<T1>(from.first);
- to.second = boost::convert_to<T2>(from.second);
+ to.first = conversion::convert_to<T1>(from.first);
+ to.second = conversion::convert_to<T2>(from.second);
return to;
}
};
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -20,13 +20,13 @@
void explicit_convert_to() {
boost::array<B1,3> bs;
boost::array<A1,3> as;
- as = convert_to<boost::array<A1,3> >(bs);
+ as = conversion::convert_to<boost::array<A1,3> >(bs);
}
void explicit_assign_to() {
boost::array<int,3> bs;
boost::array<short,3> as;
- assign_to(as,bs);
+ conversion::assign_to(as,bs);
}
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -13,7 +13,7 @@
#include <boost/conversion/ca_wrapper.hpp>
#include <boost/conversion/convert_to.hpp>
-using namespace boost;
+//using namespace boost;
using namespace boost::unit_test;
@@ -28,42 +28,42 @@
unsigned int ui(i);
unsigned long ul(l);
- c=convert_to<char>(c);
- 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);
+ c=boost::conversion::convert_to<char>(c);
+ s=boost::conversion::convert_to<short>(c);
+ i=boost::conversion::convert_to<int>(c);
+ l=boost::conversion::convert_to<long>(c);
+ uc=boost::conversion::convert_to<unsigned char>(c);
+ us=boost::conversion::convert_to<unsigned short>(c);
+ ui=boost::conversion::convert_to<unsigned int>(c);
+ ul=boost::conversion::convert_to<unsigned long>(c);
+
+
+ c=boost::conversion::convert_to<char>(s);
+ s=boost::conversion::convert_to<short>(s);
+ i=boost::conversion::convert_to<int>(s);
+ l=boost::conversion::convert_to<long>(s);
+ uc=boost::conversion::convert_to<unsigned char>(s);
+ us=boost::conversion::convert_to<unsigned short>(s);
+ ui=boost::conversion::convert_to<unsigned int>(s);
+ ul=boost::conversion::convert_to<unsigned long>(s);
+
+ c=boost::conversion::convert_to<char>(i);
+ s=boost::conversion::convert_to<short>(i);
+ i=boost::conversion::convert_to<int>(i);
+ l=boost::conversion::convert_to<long>(i);
+ uc=boost::conversion::convert_to<unsigned char>(i);
+ us=boost::conversion::convert_to<unsigned short>(i);
+ ui=boost::conversion::convert_to<unsigned int>(i);
+ ul=boost::conversion::convert_to<unsigned long>(i);
+
+ c=boost::conversion::convert_to<char>(l);
+ s=boost::conversion::convert_to<short>(l);
+ i=boost::conversion::convert_to<int>(l);
+ l=boost::conversion::convert_to<long>(l);
+ uc=boost::conversion::convert_to<unsigned char>(l);
+ us=boost::conversion::convert_to<unsigned short>(l);
+ ui=boost::conversion::convert_to<unsigned int>(l);
+ ul=boost::conversion::convert_to<unsigned long>(l);
}
@@ -77,45 +77,45 @@
unsigned int ui(i);
unsigned long ul(l);
- 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);
+ boost::conversion::assign_to(c, 0);
+ boost::conversion::assign_to(c, c);
+ boost::conversion::assign_to(c, s);
+ boost::conversion::assign_to(c, i);
+ boost::conversion::assign_to(c, l);
+ boost::conversion::assign_to(c, uc);
+ boost::conversion::assign_to(c, us);
+ boost::conversion::assign_to(c, ui);
+ boost::conversion::assign_to(c, ul);
+
+ boost::conversion::assign_to(s, 1);
+ boost::conversion::assign_to(s, c);
+ boost::conversion::assign_to(s, s);
+ boost::conversion::assign_to(s, i);
+ boost::conversion::assign_to(s, l);
+ boost::conversion::assign_to(s, uc);
+ boost::conversion::assign_to(s, us);
+ boost::conversion::assign_to(s, ui);
+ boost::conversion::assign_to(s, ul);
+
+ boost::conversion::assign_to(i, 2);
+ boost::conversion::assign_to(i, c);
+ boost::conversion::assign_to(i, s);
+ boost::conversion::assign_to(i, i);
+ boost::conversion::assign_to(i, l);
+ boost::conversion::assign_to(i, uc);
+ boost::conversion::assign_to(i, us);
+ boost::conversion::assign_to(i, ui);
+ boost::conversion::assign_to(i, ul);
+
+ boost::conversion::assign_to(l, 3);
+ boost::conversion::assign_to(l, c);
+ boost::conversion::assign_to(l, s);
+ boost::conversion::assign_to(l, i);
+ boost::conversion::assign_to(l, l);
+ boost::conversion::assign_to(l, uc);
+ boost::conversion::assign_to(l, us);
+ boost::conversion::assign_to(l, ui);
+ boost::conversion::assign_to(l, ul);
}
void mca_assign_to_with_builtin_types() {
@@ -128,49 +128,49 @@
unsigned int ui(i);
unsigned long ul(l);
- 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;
+ boost::conversion::mca(c) = c;
+ boost::conversion::mca(c) = s;
+ boost::conversion::mca(c) = i;
+ boost::conversion::mca(c) = l;
+ boost::conversion::mca(c) = uc;
+ boost::conversion::mca(c) = us;
+ boost::conversion::mca(c) = ui;
+ boost::conversion::mca(c) = ul;
+
+ boost::conversion::mca(s) = c;
+ boost::conversion::mca(s) = s;
+ boost::conversion::mca(s) = i;
+ boost::conversion::mca(s) = l;
+ boost::conversion::mca(s) = uc;
+ boost::conversion::mca(s) = us;
+ boost::conversion::mca(s) = ui;
+ boost::conversion::mca(s) = ul;
+
+ boost::conversion::mca(i) = c;
+ boost::conversion::mca(i) = s;
+ boost::conversion::mca(i) = i;
+ boost::conversion::mca(i) = l;
+ boost::conversion::mca(i) = uc;
+ boost::conversion::mca(i) = us;
+ boost::conversion::mca(i) = ui;
+ boost::conversion::mca(i) = ul;
+
+ boost::conversion::mca(l) = c;
+ boost::conversion::mca(l) = s;
+ boost::conversion::mca(l) = i;
+ boost::conversion::mca(l) = l;
+ boost::conversion::mca(l) = uc;
+ boost::conversion::mca(l) = us;
+ boost::conversion::mca(l) = ui;
+ boost::conversion::mca(l) = ul;
}
void assign_to_transitive() {
- int a=0; int b=0; int c=0;
+ int a=0; int b=0; //int c=0;
//assign_to(a, assign_to(b, assign_to(c,1)));
- boost::assign_to(a, boost::assign_to(b, c));
+ boost::conversion::assign_to(a, boost::conversion::assign_to(b, 1));
}
@@ -178,7 +178,7 @@
{
int a=0; int b=0; int c=0;
- boost::mca(a) = boost::mca(b) = boost::mca(b) = 1;
+ boost::conversion::mca(a) = boost::conversion::mca(b) = boost::conversion::mca(c) = 1;
}
}
Modified: sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp (original)
+++ sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp 2009-10-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -20,17 +20,17 @@
typedef short B1;
void explicit_convert_to() {
- chrono::seconds a(3);
- posix_time::time_duration b(convert_to<posix_time::time_duration >(a));
- chrono::seconds c(convert_to<chrono::seconds>(b));
+ boost::chrono::seconds a(3);
+ boost::posix_time::time_duration b(conversion::convert_to<boost::posix_time::time_duration >(a));
+ boost::chrono::seconds c(conversion::convert_to<boost::chrono::seconds>(b));
}
void explicit_assign_to() {
- chrono::seconds a(3);
- posix_time::time_duration b;
- assign_to(b, a);
- chrono::seconds c;
- assign_to(c, b);
+ boost::chrono::seconds a(3);
+ boost::posix_time::time_duration b;
+ conversion::assign_to(b, a);
+ boost::chrono::seconds c;
+ conversion::assign_to(c, b);
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp (original)
+++ sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp 2009-10-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -21,16 +21,16 @@
void explicit_convert_to() {
chrono::system_clock::time_point a=chrono::system_clock::now();
- posix_time::ptime b(convert_to<posix_time::ptime >(a));
- chrono::system_clock::time_point c(convert_to<chrono::system_clock::time_point>(b));
+ posix_time::ptime b(conversion::convert_to<posix_time::ptime >(a));
+ chrono::system_clock::time_point c(conversion::convert_to<chrono::system_clock::time_point>(b));
}
void explicit_assign_to() {
chrono::system_clock::time_point a=chrono::system_clock::now();
posix_time::ptime b;
- assign_to(b, a);
+ conversion::assign_to(b, a);
chrono::system_clock::time_point c;
- assign_to(c, b);
+ conversion::assign_to(c, b);
}
test_suite* init_unit_test_suite(int, char*[])
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -21,8 +21,8 @@
B1 b1;
B1 b2;
std::complex<B1> b;
- std::complex<A1> a1(convert_to<std::complex<A1> >(b));
- std::complex<A1> a2(convert_to<std::complex<A1> >(std::complex<B1>(b1,b2)));
+ std::complex<A1> a1(conversion::convert_to<std::complex<A1> >(b));
+ std::complex<A1> a2(conversion::convert_to<std::complex<A1> >(std::complex<B1>(b1,b2)));
}
void explicit_assign_to() {
@@ -30,8 +30,8 @@
B1 b2;
std::complex<A1> a;
std::complex<B1> b;
- assign_to(a,b);
- assign_to(a,std::complex<B1>(b1,b2));
+ conversion::assign_to(a,b);
+ conversion::assign_to(a,std::complex<B1>(b1,b2));
}
test_suite* init_unit_test_suite(int, char*[])
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -21,7 +21,7 @@
namespace boost { namespace conversion {
template <>
- A convert_to<A,B>(const B& val, type_tag<A>) {
+ A convert_to<A,B>(const B& val, boost::dummy::type_tag<A>) {
return A();
}
@@ -34,14 +34,14 @@
void explicit_convert_to() {
B b;
- A a(convert_to<A>(b));
+ A a(conversion::convert_to<A>(b));
}
void explicit_assign_to() {
B b;
A a;
- assign_to(a, b);
- mca(a)= b;
+ conversion::assign_to(a, b);
+ conversion::mca(a)= b;
}
test_suite* init_unit_test_suite(int, char*[])
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -20,8 +20,9 @@
struct B2{};
namespace boost {
+ namespace conversion {
template <>
- A1 convert_to<A1,B1>(const B1& val, type_tag<A1>) {
+ A1 convert_to<A1,B1>(const B1& val, boost::dummy::type_tag<A1>) {
return A1();
}
@@ -30,7 +31,7 @@
return to;
}
- namespace conversion { namespace partial_specialization_workaround {
+ namespace partial_specialization_workaround {
template <>
struct convert_to< A2,B2 > {
inline static A2 apply(B2 const & from)
@@ -45,7 +46,8 @@
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -22,18 +22,19 @@
void explicit_convert_to() {
B1 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)));
+ boost::numeric::interval<B1> b;
+ boost::numeric::interval<A1> a1(conversion::convert_to<boost::numeric::interval<A1> >(b));
+ boost::numeric::interval<A1> a2(conversion::convert_to<boost::numeric::interval<A1> >(
+ boost::numeric::interval<B1>(b1,b2)));
}
void explicit_assign_to() {
B1 b1;
B1 b2;
- numeric::interval<A1> a;
- numeric::interval<B1> b;
- assign_to(a,b);
- assign_to(a,numeric::interval<B1>(b1,b2));
+ boost::numeric::interval<A1> a;
+ boost::numeric::interval<B1> b;
+ conversion::assign_to(a,b);
+ conversion::assign_to(a,boost::numeric::interval<B1>(b1,b2));
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/intrinsec.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/intrinsec.cpp (original)
+++ sandbox/conversion/libs/conversion/test/intrinsec.cpp 2009-10-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -44,7 +44,7 @@
}
{
B b;
- A a(convert_to<A>(b));
+ A a(conversion::convert_to<A>(b));
}
}
@@ -55,7 +55,7 @@
}
{
B b;
- AE ae(convert_to<AE>(b));
+ AE ae(conversion::convert_to<AE>(b));
}
}
@@ -67,7 +67,7 @@
}
{
C c;
- A a(convert_to<A>(c));
+ A a(conversion::convert_to<A>(c));
}
}
@@ -80,13 +80,13 @@
{
A a(0);
AA aa(0);
- assign_to(aa,a);
+ conversion::assign_to(aa,a);
}
}
void mca_with_assignemet_operator() {
A a(0);
AA aa(0);
- mca(aa) =a;
+ conversion::mca(aa) =a;
}
void assign_to_with_assignemet_operator_and_implicit_constructor() {
@@ -98,13 +98,13 @@
{
B b;
AA aa(1);
- assign_to(aa,b);
+ conversion::assign_to(aa,b);
}
}
void mca_with_assignemet_operator_and_implicit_constructor() {
B b;
AA aa(1);
- mca(aa)=b;
+ conversion::mca(aa)=b;
}
void assign_to_with_assignemet_operator_and_conversion_operator() {
@@ -116,14 +116,14 @@
{
C c;
CC cc(1);
- assign_to(cc,c);
+ conversion::assign_to(cc,c);
}
}
void mca_with_assignemet_operator_and_conversion_operator() {
C c;
CC cc(1);
- mca(cc)=c;
+ conversion::mca(cc)=c;
}
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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -16,24 +16,32 @@
using namespace boost;
using namespace boost::unit_test;
-typedef int A1;
-typedef short B1;
+ struct A1{};
+ struct B1{};
+ A1 convert_to(const B1& val, boost::dummy::type_tag<A1>) {
+ return A1();
+ }
+
+ A1& assign_to(A1& to, const B1& from) {
+ return to;
+ }
+
void explicit_convert_to() {
B1 b1;
- optional<B1> b;
- optional<A1> a1(convert_to<optional<A1> >(b));
+ boost::optional<B1> b;
+ boost::optional<A1> a1(conversion::convert_to<boost::optional<A1> >(b));
//optional<A1> a1;
//a1=convert_to<optional<A1> >(b);
- optional<A1> a2(convert_to<optional<A1> >(optional<B1>(b1)));
+ boost::optional<A1> a2(conversion::convert_to<boost::optional<A1> >(boost::optional<B1>(b1)));
}
void explicit_assign_to() {
B1 b1;
- optional<A1> a;
- optional<B1> b;
+ boost::optional<A1> a;
+ boost::optional<B1> b;
//assign_to(b,a);
- assign_to(a, optional<B1>(b1));
+ conversion::assign_to(a, boost::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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -22,9 +22,9 @@
B1 b1;
B2 b2;
std::pair<B1,B2> b;
- std::pair<A1,A2> a1(convert_to<std::pair<A1,A2> >(b));
- std::pair<A1,A2> a2(convert_to<std::pair<A1,A2> >(std::pair<B1,B2>(b1,b2)));
- std::pair<A1,A2> a3(convert_to<std::pair<A1,A2> >(std::make_pair(b1,b2)));
+ std::pair<A1,A2> a1(conversion::convert_to<std::pair<A1,A2> >(b));
+ std::pair<A1,A2> a2(conversion::convert_to<std::pair<A1,A2> >(std::pair<B1,B2>(b1,b2)));
+ std::pair<A1,A2> a3(conversion::convert_to<std::pair<A1,A2> >(std::make_pair(b1,b2)));
}
void explicit_assign_to() {
@@ -32,9 +32,9 @@
B2 b2;
std::pair<A1,A2> a;
std::pair<B1,B2> b;
- assign_to(a,b);
- assign_to(a, std::pair<B1,B2>(b1,b2));
- assign_to(a, std::make_pair(b1,b2));
+ conversion::assign_to(a,b);
+ conversion::assign_to(a, std::pair<B1,B2>(b1,b2));
+ conversion::assign_to(a, std::make_pair(b1,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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -18,22 +18,22 @@
typedef int A1;
typedef short B1;
-
+
void explicit_convert_to() {
B1 b1;
B1 b2(2);
- rational<B1> b(1,2);
- rational<A1> a1(convert_to<rational<A1> >(b));
- rational<A1> a2(convert_to<rational<A1> >(rational<B1>(b1,b2)));
+ boost::rational<B1> b(1,2);
+ boost::rational<A1> a1(conversion::convert_to<boost::rational<A1> >(b));
+ boost::rational<A1> a2(conversion::convert_to<boost::rational<A1> >(boost::rational<B1>(b1,b2)));
}
void explicit_assign_to() {
B1 b1;
B1 b2(2);
- rational<A1> a;
- rational<B1> b(1,2);
- assign_to(a, b);
- assign_to(a, rational<B1>(b1,b2));
+ boost::rational<A1> a;
+ boost::rational<B1> b(1,2);
+ conversion::assign_to(a, b);
+ conversion::assign_to(a, boost::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-27 04:46:48 EDT (Tue, 27 Oct 2009)
@@ -21,9 +21,9 @@
B1 b1;
B2 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)));
+ fusion::tuple<A1,A2> a1(conversion::convert_to<fusion::tuple<A1,A2> >(b));
+ fusion::tuple<A1,A2> a2(conversion::convert_to<fusion::tuple<A1,A2> >(fusion::tuple<B1,B2>(b1,b2)));
+ fusion::tuple<A1,A2> a3(conversion::convert_to<fusion::tuple<A1,A2> >(fusion::make_tuple(b1,b2)));
}
void explicit_assign_to() {
@@ -31,9 +31,9 @@
B2 b2;
fusion::tuple<A1,A2> a;
fusion::tuple<B1,B2> b;
- assign_to(a, b);
- assign_to(a, fusion::tuple<B1,B2>(b1,b2));
- assign_to(a, fusion::make_tuple(b1,b2));
+ conversion::assign_to(a, b);
+ conversion::assign_to(a, fusion::tuple<B1,B2>(b1,b2));
+ conversion::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