|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72168 - in sandbox/conversion/boost/conversion: . boost fp std
From: vicente.botet_at_[hidden]
Date: 2011-05-25 18:26:24
Author: viboes
Date: 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
New Revision: 72168
URL: http://svn.boost.org/trac/boost/changeset/72168
Log:
Conversion: Moved to conversion namespace+ definition of overloaded convert_to functor factory
Text files modified:
sandbox/conversion/boost/conversion/assign_to.hpp | 17 +++-
sandbox/conversion/boost/conversion/boost/array.hpp | 91 ++++++++++++++++------------
sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 130 ++++++++++++++++++++++++----------------
sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 12 +-
sandbox/conversion/boost/conversion/boost/interval.hpp | 15 ++-
sandbox/conversion/boost/conversion/boost/optional.hpp | 37 ++++++++---
sandbox/conversion/boost/conversion/boost/rational.hpp | 15 ++-
sandbox/conversion/boost/conversion/boost/tuple.hpp | 44 ++++++++-----
sandbox/conversion/boost/conversion/ca_wrapper.hpp | 6
sandbox/conversion/boost/conversion/convert_to.hpp | 106 ++++++++++++++++++++------------
sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp | 8 +-
sandbox/conversion/boost/conversion/convert_to_via.hpp | 2
sandbox/conversion/boost/conversion/fp/convert_to.hpp | 68 +++++++++++++++-----
sandbox/conversion/boost/conversion/std/complex.hpp | 8 +-
sandbox/conversion/boost/conversion/std/pair.hpp | 8 +-
sandbox/conversion/boost/conversion/std/string.hpp | 6
sandbox/conversion/boost/conversion/std/vector.hpp | 10 +-
sandbox/conversion/boost/conversion/try_assign_to.hpp | 12 +-
sandbox/conversion/boost/conversion/try_convert_to.hpp | 17 +++-
19 files changed, 377 insertions(+), 235 deletions(-)
Modified: sandbox/conversion/boost/conversion/assign_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/assign_to.hpp (original)
+++ sandbox/conversion/boost/conversion/assign_to.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -23,7 +23,7 @@
The technique consists in partially specialize on the function @c assign_to on the @c boost::conversion namespace.
For compilers for which we can not partially specialize a function a trick is used:
instead of calling directly to the @c assign_to member function, @c assign_to calls to the static operation apply
-on a class with the same name in the namespace @c partial_specialization_workaround.
+on a class with the same name in the namespace @c overload_workaround.
Thus the user can specialize partially this class.
*/
@@ -36,7 +36,7 @@
namespace boost {
namespace conversion {
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
//! struct used when overloading can not be applied.
template < typename To, typename From >
struct assign_to
@@ -58,13 +58,15 @@
{
for (std::size_t i = 0; i < N; ++i)
{
- to[i] = boost::convert_to<To>(from[i]);
+ to[i] = boost::conversion::convert_to<To>(from[i]);
}
return to;
}
};
}
+ }
+ namespace conversion_2 {
//! @brief Default @c assign_to overload, used when ADL fails.
//!
@@ -74,7 +76,7 @@
template < typename To, typename From >
To& assign_to(To& to, const From& from, dummy::type_tag<To> const&)
{
- return conversion::partial_specialization_workaround::assign_to<To,From>::apply(to, from);
+ return conversion::overload_workaround::assign_to<To,From>::apply(to, from);
}
}
@@ -83,13 +85,15 @@
template <typename Target, typename Source>
Target& assign_to_impl(Target& to, const Source& from)
{
- using namespace boost::conversion;
+ using namespace boost::conversion_2;
//use boost::conversion::assign_to if ADL fails
return assign_to(to, from, boost::dummy::type_tag<Target>());
}
}
#endif
+ namespace conversion {
+
//! @Effects Converts the @c from parameter to the @c to parameter, using by default the assigment operator.
//! @Throws Whatever the underlying the assignment operator of the @c To class throws..
//! This function can be partially specialized on compilers supporting it.
@@ -97,7 +101,8 @@
Target& assign_to(Target& to, const Source& from, boost::dummy::base_tag<Target> const& p =boost::dummy::base_tag<Target>())
{
(void)p;
- return conversion_impl::assign_to_impl<Target, Source>(to, from);
+ return boost::conversion_impl::assign_to_impl<Target, Source>(to, from);
+ }
}
}
Modified: sandbox/conversion/boost/conversion/boost/array.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/array.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/array.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -25,50 +25,63 @@
namespace boost {
- #ifdef BOOST_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)
- {
- array<T1,N> to;
- boost::assign_to(to, from);
- return to;
- }
- };
- template < typename T1, typename T2, std::size_t N>
- struct assign_to< array<T1,N>, array<T2,N> > {
- 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]);
- }
- return to;
- }
- };
- }}
- #else
- template < typename T1, typename T2, std::size_t N>
- inline array<T1,N> convert_to(array<T2,N> const & from
- , boost::dummy::type_tag<array<T1,N> > const&
- )
- {
- array<T1,N> to;
- boost::assign_to(to, from);
- return to;
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace conversion {
+ namespace overload_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)
+ {
+ array<T1,N> to;
+ boost::conversion::assign_to(to, from);
+ return to;
+ }
+ };
+ template < typename T1, typename T2, std::size_t N>
+ struct assign_to< array<T1,N>, array<T2,N> >
+ {
+ 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::conversion::convert_to<T1>(from[i]);
+ }
+ return to;
+ }
+ };
}
+ }
+ #else
+ //! @brief @c convert_to overloading for source and target been @c boost::array of the same size.
+ //!
+ //! @Returns the array having as elements the conversion from the source array.
+ template < typename T1, typename T2, std::size_t N>
+ inline array<T1,N> convert_to(array<T2,N> const & from
+ , boost::dummy::type_tag<array<T1,N> > const&
+ )
+ {
+ array<T1,N> to;
+ boost::conversion::assign_to(to, from);
+ return to;
+ }
- template < typename T1, typename T2, std::size_t N>
- inline array<T1,N>& assign_to(array<T1,N>& to, array<T2,N> const & from
+ //! @brief @c convert_to overloading for source and target been @c boost::array of the same size.
+ //!
+ //! @Effects converts each one of the source array elements and store the result in the corresponding index on the target array.
+ //! @Returns The @c to parameter reference.
+ template < typename T1, typename T2, std::size_t N>
+ inline array<T1,N>& assign_to(array<T1,N>& to, array<T2,N> const & from
, boost::dummy::type_tag<array<T1,N> > const&
- )
+ )
+ {
+ for (unsigned int i =0; i<N; ++i)
{
- for (unsigned int i =0; i<N; ++i) {
- to[i]=boost::convert_to<T1>(from[i]);
- }
- return to;
+ to[i]=boost::conversion::convert_to<T1>(from[i]);
}
- #endif
+ 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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -24,8 +24,9 @@
#include <boost/config.hpp>
namespace boost {
- #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
- namespace conversion { namespace partial_specialization_workaround {
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace conversion {
+ namespace overload_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)
@@ -37,18 +38,18 @@
rep_t sec = d/1000000000;
rep_t nsec = d%1000000000;
return posix_time::seconds(static_cast<long long>(sec))+
-#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+ #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
posix_time::nanoseconds(nsec);
-#else
+ #else
posix_time::microseconds((nsec+500)/1000);
-#endif
+ #endif
}
};
template < class Rep, class Period>
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 = boost::conversion::convert_to<posix_time::time_duration>(from);
return to;
}
};
@@ -64,60 +65,85 @@
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 = boost::conversion::convert_to<chrono::duration<Rep, Period> >(from);
return to;
}
};
}}
- #else
- namespace chrono {
- template < class Rep, class Period>
- inline posix_time::time_duration convert_to(chrono::duration<Rep, Period> const & from
- , boost::dummy::type_tag<posix_time::time_duration> const&)
- {
- 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 posix_time::seconds(static_cast<long long>(sec))+
-#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
- posix_time::nanoseconds(nsec);
-#else
- posix_time::microseconds((nsec+500)/1000);
-#endif
- }
-
- template < class Rep, class Period>
- inline chrono::duration<Rep, Period> & assign_to(chrono::duration<Rep, Period> & to, const posix_time::time_duration& from
- , boost::dummy::type_tag<chrono::duration<Rep, Period> > const&
- )
-
- {
- to = boost::convert_to<duration<Rep, Period> >(from);
- return to;
- }
+ template < class Rep, class Period>
+ inline time_duration& assign_to(time_duration& to, const chrono::duration<Rep, Period>& from
+ , boost::dummy::type_tag<posix_time::time_duration> const&
+ )
+ {
+ to = boost::conversion::convert_to<time_duration>(from);
+ return to;
+ }
+ #else
+ namespace chrono {
+ //! @brief @c convert_to overloading for conversions from @c boost::chrono::duration<> to @c boost::posix_time::time_duration.
+ //!
+ //! @Returns the duration converted to seconds+nanoseconds following the boost::posix_time::time_duration formatting.
+
+ template < class Rep, class Period>
+ inline posix_time::time_duration convert_to(chrono::duration<Rep, Period> const & from
+ , boost::dummy::type_tag<posix_time::time_duration> const&)
+ {
+ 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 posix_time::seconds(static_cast<long long>(sec))+
+ #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+ posix_time::nanoseconds(nsec);
+ #else
+ posix_time::microseconds((nsec+500)/1000);
+ #endif
}
+ //! @brief @c assign_to overloading for conversions from @c boost::chrono::duration<> to @c boost::posix_time::time_duration.
+ //!
+ //! @Effects As if <c>to = boost::conversion::convert_to<duration<Rep, Period>>(from)</c>.
+ //! @Returns The @c to parameter reference.
+
+ template < class Rep, class Period>
+ inline chrono::duration<Rep, Period> & assign_to(chrono::duration<Rep, Period> & to, const posix_time::time_duration& from
+ , boost::dummy::type_tag<chrono::duration<Rep, Period> > const&
+ )
+
+ {
+ to = boost::conversion::convert_to<duration<Rep, Period> >(from);
+ return to;
+ }
+ }
- namespace posix_time {
- template < class Duration>
- inline Duration convert_to(time_duration const & from
- , boost::dummy::type_tag<Duration> const&)
- {
- return chrono::duration_cast<Duration>(chrono::nanoseconds(from.total_nanoseconds()));
- }
+ namespace posix_time {
+ //! @brief @c convert_to overloading for conversions from @c boost::posix_time::time_duration to @c boost::chrono::duration<>.
+ //!
+ //! @Returns the duration cast from a nanoseconds duration initialized to the total number of nanosecond of the @c from parameter.
+
+ template < class Duration>
+ inline Duration convert_to(time_duration const & from
+ , boost::dummy::type_tag<Duration> const&)
+ {
+ return chrono::duration_cast<Duration>(chrono::nanoseconds(from.total_nanoseconds()));
+ }
- template < class Rep, class Period>
- inline time_duration& assign_to(time_duration& to, const chrono::duration<Rep, Period>& from
- , boost::dummy::type_tag<posix_time::time_duration> const&
- )
- {
- to = boost::convert_to<time_duration>(from);
- return to;
- }
+ //! @brief @c assign_to overloading for conversions from @c boost::posix_time::time_duration to @c boost::chrono::duration<>.
+ //!
+ //! @Effects As if <c>to = boost::conversion::convert_to<time_duration>(from)</c>.
+ //! @Returns The @c to parameter reference.
+ template < class Rep, class Period>
+ inline time_duration& assign_to(time_duration& to, const chrono::duration<Rep, Period>& from
+ , boost::dummy::type_tag<posix_time::time_duration> const&
+ )
+ {
+ to = boost::conversion::convert_to<time_duration>(from);
+ return to;
}
- #endif
+ }
+
+ #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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -26,8 +26,8 @@
#include <boost/config.hpp>
namespace boost {
- #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
- namespace conversion { namespace partial_specialization_workaround {
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace conversion { namespace overload_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)
@@ -51,7 +51,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 = boost::conversion::convert_to<posix_time::ptime>(from);
return to;
}
};
@@ -70,7 +70,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 = boost::conversion::convert_to<chrono::time_point<Clock, Duration> >(from);
return to;
}
};
@@ -102,7 +102,7 @@
, boost::dummy::type_tag<chrono::time_point<Clock, Duration> > const&
)
{
- to = boost::convert_to<chrono::time_point<Clock, Duration> >(from);
+ to = boost::conversion::convert_to<chrono::time_point<Clock, Duration> >(from);
return to;
}
@@ -125,7 +125,7 @@
, boost::dummy::type_tag<posix_time::ptime> const&
)
{
- to = boost::convert_to<ptime>(from);
+ to = boost::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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -23,20 +23,20 @@
namespace boost {
- #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
- namespace conversion { namespace partial_specialization_workaround {
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace conversion { namespace overload_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)
{
- return numeric::interval<T,PT>(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ return numeric::interval<T,PT>(boost::conversion::convert_to<T>(from.lower()), boost::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(boost::conversion::convert_to<T>(from.lower()), boost::conversion::convert_to<U>(from.upper()));
return to;
}
};
@@ -44,18 +44,21 @@
}}
#else
namespace numeric {
+ //! @brief @c convert_to overloading for source and target been @c boost::numeric::interval.
+ //!
+ //! @Returns the target interval having as extremes the conversion from the source interval extremes.
template < class T, class PT, class U, class PU>
inline interval<T,PT> convert_to(interval<U,PU> const & from
, boost::dummy::type_tag<interval<T,PT> > const&)
{
- return interval<T,PT>(boost::convert_to<T>(from.lower()), boost::convert_to<U>(from.upper()));
+ return interval<T,PT>(boost::conversion::convert_to<T>(from.lower()), boost::conversion::convert_to<U>(from.upper()));
}
template < class T, class PT, class U, class PU>
inline interval<T,PT>& assign_to(interval<T,PT>& to, const interval<U,PU>& from
, boost::dummy::type_tag<interval<T,PT> > const&
)
{
- to.assign(boost::convert_to<T>(from.lower()),boost::convert_to<U>(from.upper()));
+ to.assign(boost::conversion::convert_to<T>(from.lower()),boost::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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -26,14 +26,15 @@
namespace boost {
- #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
namespace conversion {
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
template < class Target, class Source>
- struct convert_to< optional<Target>, optional<Source> > {
+ 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>(boost::conversion::convert_to<Target>(from.get())):optional<Target>());
}
};
@@ -44,7 +45,7 @@
{
try
{
- return optional<Target>(boost::convert_to<Target>(from));
+ return optional<Target>(boost::conversion::convert_to<Target>(from));
}
catch (...)
{
@@ -54,10 +55,11 @@
};
template < class Target, class Source>
- struct assign_to< optional<Target>, optional<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?optional<Target>(boost::conversion::convert_to<Target>(from.get())):optional<Target>();
return to;
}
};
@@ -65,20 +67,30 @@
}
}
#else
+
+ //! @brief @c convert_to overloading for source and target been @c boost::optional.
+ //!
+ //! @Returns If the optional source is initialized @c boost::optional<Target> initialized to the conversion of the optional value.
+ //! Uninitialized @c boost::optional<Target otherwise.
template < class Target, class Source>
inline optional<Target> convert_to(optional<Source> const & from
, boost::dummy::type_tag<optional<Target> > const&)
{
- return (from?optional<Target>(boost::convert_to<Target>(from.get())):optional<Target>());
+ return (from?optional<Target>(boost::conversion::convert_to<Target>(from.get())):optional<Target>());
}
+ //! @brief @c convert_to overloading to try to convert the source to the target.
+ //!
+ //! We can see this specialization as a try_convert_to function.
+ //! @Returns If the source is convertible to the target @c boost::optional<Target> initialized to the result of the conversion.
+ //! Uninitialized @c boost::optional<Target otherwise.
template < class Target, class Source>
inline optional<Target> convert_to(Source const & from
, boost::dummy::type_tag<optional<Target> > const&)
{
try
{
- return optional<Target>(boost::convert_to<Target>(from));
+ return optional<Target>(boost::conversion::convert_to<Target>(from));
}
catch (...)
{
@@ -86,12 +98,17 @@
}
}
+ //! @brief @c assign_to overloading for source and target been @c boost::optional.
+ //!
+ //! @Effects As if <c>to = boost::conversion::convert_to<optional<Target> >(from)</c>.
+ //! @Returns The @c to parameter reference.
template < class Target, class Source>
inline optional<Target>& assign_to(optional<Target>& to, const optional<Source>& from
, boost::dummy::type_tag<optional<Target> > const&
)
{
- to = from?boost::convert_to<Target>(from.get()):optional<Target>();
+ to = boost::conversion::convert_to<optional<Target> >(from);
+ //to = from?optional<Target>(boost::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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -24,31 +24,34 @@
namespace boost {
- #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
- namespace conversion { namespace partial_specialization_workaround {
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace conversion { namespace overload_workaround {
template < class T, class U>
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>(boost::conversion::convert_to<T>(from.numerator()), boost::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(boost::conversion::convert_to<T>(from.numerator()), boost::conversion::convert_to<T>(from.denominator()));
return to;
}
};
}}
#else
+ //! @brief @c convert_to overloading for source and target been @c boost::rational.
+ //!
+ //! @Returns the target rational having as numerator and denominator the conversion from the numerator and denominator of the source rational.
template < class T, class U>
inline rational<T> convert_to(rational<U> const & from
, boost::dummy::type_tag<rational<T> > const&)
{
- return rational<T>(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ return rational<T>(boost::conversion::convert_to<T>(from.numerator()), boost::conversion::convert_to<T>(from.denominator()));
}
template < class T, class U>
@@ -56,7 +59,7 @@
, boost::dummy::type_tag<rational<T> > const&
)
{
- to.assign(boost::convert_to<T>(from.numerator()), boost::convert_to<T>(from.denominator()));
+ to.assign(boost::conversion::convert_to<T>(from.numerator()), boost::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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -23,15 +23,15 @@
namespace boost {
- #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
- namespace conversion { namespace partial_specialization_workaround {
+ #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING && ! defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace conversion { namespace overload_workaround {
template < class T1, class T2, class U1, class U2>
struct convert_to< fusion::tuple<T1,T2>, fusion::tuple<U1,U2> > {
inline static fusion::tuple<T1,T2> apply(fusion::tuple<U1,U2> const & from)
{
return fusion::tuple<T1,T2>(
- boost::convert_to<T1>(fusion::get<0>(from))
- , boost::convert_to<T2>(fusion::get<1>(from))
+ boost::conversion::convert_to<T1>(fusion::get<0>(from))
+ , boost::conversion::convert_to<T2>(fusion::get<1>(from))
);
}
};
@@ -39,7 +39,7 @@
struct assign_to< fusion::tuple<T1,T2>, fusion::tuple<U1,U2> > {
inline static fusion::tuple<T1,T2>& apply(fusion::tuple<T1,T2>& to, fusion::tuple<U1,U2> const & from)
{
- to = boost::convert_to<fusion::tuple<T1,T2> >(from);
+ to = boost::conversion::convert_to<fusion::tuple<T1,T2> >(from);
return to;
}
};
@@ -48,9 +48,9 @@
inline static fusion::tuple<T1,T2,T3> apply(fusion::tuple<U1,U2,U3> const & from)
{
return fusion::tuple<T1,T2, T3>(
- boost::convert_to<T1>(fusion::get<0>(from))
- , boost::convert_to<T2>(fusion::get<1>(from))
- , boost::convert_to<T3>(fusion::get<2>(from))
+ boost::conversion::convert_to<T1>(fusion::get<0>(from))
+ , boost::conversion::convert_to<T2>(fusion::get<1>(from))
+ , boost::conversion::convert_to<T3>(fusion::get<2>(from))
);
}
};
@@ -58,7 +58,7 @@
struct assign_to< fusion::tuple<T1,T2,T3>, fusion::tuple<U1,U2,U3> > {
inline static fusion::tuple<T1,T2,T3> apply(fusion::tuple<T1,T2,T3>& to, fusion::tuple<U1,U2,U3> const & from)
{
- to = boost::convert_to<fusion::tuple<T1,T2> >(from);
+ to = boost::conversion::convert_to<fusion::tuple<T1,T2> >(from);
return to;
}
};
@@ -66,13 +66,22 @@
}}
#else
namespace fusion {
+#if defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ template < class Target..., class Source...>
+ inline tuple<...Target> convert_to(tuple<...Source> const & from
+ , boost::dummy::type_tag<tuple<...Target> > const&);
+ template < class Target..., class Source...>
+ inline tuple<...Target>& assign_to(tuple<...Target>& to, tuple<...Source> const & from
+ , boost::dummy::type_tag<tuple<...Target> > const&
+ )
+#else
template < class T1, class T2, class U1, class U2>
inline tuple<T1,T2> convert_to(tuple<U1,U2> const & from
, boost::dummy::type_tag<tuple<T1,T2> > const&)
{
return tuple<T1,T2>(
- boost::convert_to<T1>(boost::fusion::get<0>(from))
- , boost::convert_to<T2>(boost::fusion::get<1>(from))
+ boost::conversion::convert_to<T1>(boost::fusion::get<0>(from))
+ , boost::conversion::convert_to<T2>(boost::fusion::get<1>(from))
);
}
@@ -81,7 +90,7 @@
, boost::dummy::type_tag<tuple<T1,T2> > const&
)
{
- to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
+ to = boost::conversion::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
}
@@ -91,9 +100,9 @@
)
{
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))
+ boost::conversion::convert_to<T1>(boost::fusion::get<0>(from))
+ , boost::conversion::convert_to<T2>(boost::fusion::get<1>(from))
+ , boost::conversion::convert_to<T3>(boost::fusion::get<2>(from))
);
}
@@ -102,11 +111,12 @@
, boost::dummy::type_tag<tuple<T1,T2,T3> > const&
)
{
- to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
+ to = boost::conversion::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
}
}
- #endif
+#endif
+#endif
}
#endif
Modified: sandbox/conversion/boost/conversion/ca_wrapper.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/ca_wrapper.hpp (original)
+++ sandbox/conversion/boost/conversion/ca_wrapper.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -42,7 +42,7 @@
//! @Throws Whatever @c convert_to throws.
template <typename U>
operator U() {
- return boost::convert_to<U>(ref_);
+ return boost::conversion::convert_to<U>(ref_);
}
//! Assignement.
@@ -62,7 +62,7 @@
//! @Throws Whatever @c assign_to throws.
template <typename U>
ca_wrapper& operator =(ca_wrapper<U> const& u) {
- boost::assign_to(ref_, u.ref_);
+ boost::conversion::assign_to(ref_, u.ref_);
return *this;
}
@@ -73,7 +73,7 @@
//! @Throws Whatever @c assign_to throws.
template <typename U>
ca_wrapper& operator =(U const& u) {
- boost::assign_to(ref_, u);
+ boost::conversion::assign_to(ref_, u);
return *this;
}
};
Modified: sandbox/conversion/boost/conversion/convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -12,40 +12,56 @@
\brief
Defines the free function @c convert_to.
- The @c convert_to function converts the @c from parameter to a @c To type. The default implementation applies the conversion @c To operator of the @c From class or
+ The @c convert_to function converts the @c from parameter to a @c To type.
+ The default implementation applies the conversion @c To operator of the @c From class or
the copy constructor of the @c To class.
Of course if both exist the conversion is ambiguous.
- A user adapting another type could need to specialize the @c convert_to free function if the default behavior is not satisfactory.
+ A user adapting another type could need to overload the @c convert_to free function if the default behavior is not satisfactory.
The user can add the @c convert_to overloading on any namespace found by ADL from the @c Source or the @c Target.
A trick is used to overload on the return type by adding a dummy parameter having the Target.
But sometimes, as it is the case for the standard classes,
-we can not add new functions on the std namespace, so we need a different technique.
+we can not add new functions on the @c std namespace, so we need a different technique.
-The technique consists in partially specialize on the function @c convert_to on the @c boost::conversion namespace.
-For compilers for which we can not partially specialize a function a trick is used: instead of calling directly to the @c convert_to member function,
-_at_c convert_to calls to the static operation apply on a class with the same name in the namespace @c partial_specialization_workaround.
+Instead of calling directly to the conversion operator, @c convert_to calls to the static operation apply on a class with the same name in the namespace @c boost::conversion::overload_workaround.
Thus the user can specialize partially this class.
*/
#ifndef BOOST_CONVERSION_CONVERT_TO_HPP
#define BOOST_CONVERSION_CONVERT_TO_HPP
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
+
namespace boost {
namespace dummy {
//! base tag used to overload a function returning T.
- template <typename T> struct base_tag { };
- //! base tag used to overload a function returning T that takes precedence respect to &c base_tag<T>.
- template <typename T> struct type_tag : public base_tag<T> {};
+ template <typename T>
+ struct base_tag {
+ typedef T type;
+ };
+ //! tag used to overload a function returning T that takes precedence respect to &c base_tag<T>.
+ //!
+ //! Users overloading the @c convert_to function must use this tag.
+ template <typename T>
+ struct type_tag : public base_tag<T> {
+ typedef T type;
+ };
}
namespace conversion {
- namespace partial_specialization_workaround {
- //! struct used when overloading can not be applied.
+ //! meta-function to state if the parameter is a place_holder
+ //!
+ //! The nested type @c type is a mpl boolean which default to @c mpl::false_. Specific specialization would make this meta-function to be @c mpl::true_.
+ template <typename T, typename Enabled=void>
+ struct enable_functor : mpl::false_ {};
+
+ namespace overload_workaround {
+ //! struct used when overloading of @c convert_to function can not be applied.
template < typename To, typename From >
struct convert_to {
- //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
+ //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
//! @Throws Whatever the underlying conversion @c To operator of the @c From class or the copy constructor of the @c To class throws.
inline static To apply(const From& val)
{
@@ -53,41 +69,51 @@
}
};
}
+#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ namespace impl_2 {
+
+ //! @brief Default @c convert_to overload, used when ADL fails.
+ //!
+ //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
+ //! @Throws Whatever the underlying conversion @c To operator of the @c From class or the copy constructor of the @c To class throws.
+ //! Forwards the call to the overload workaround, which can yet be specialized by the user for standard C++ types.
+ template < typename To, typename From >
+ To convert_to(const From& val, dummy::type_tag<To> const&) {
+ return conversion::overload_workaround::convert_to<To,From>::apply(val);
+ }
+ }
+
+ namespace impl {
+ template <typename Target, typename Source>
+ Target convert_to_impl(Source const& from) {
+ using namespace boost::conversion::impl_2;
+ //use boost::conversion::convert_to if ADL fails
+ return convert_to(from, boost::dummy::type_tag<Target>());
+ }
+ }
+#endif
- //! @brief Default @c convert_to_or_fallback overload, used when ADL fails.
+ //! @brief Extrinsic conversion function.
//!
- //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
+ //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
//! @Throws Whatever the underlying conversion @c To operator of the @c From class or the copy constructor of the @c To class throws.
- //! Forwards the call to the overload workarround, which can yet be specialized by the user for standard C++ types.
- template < typename To, typename From >
- To convert_to(const From& val, dummy::type_tag<To> const&) {
- return conversion::partial_specialization_workaround::convert_to<To,From>::apply(val);
- }
- }
-#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
- namespace conversion_impl {
+ //!
+ //! This function can be overloaded by the user.
+ //! A trick is used to overload on the return type by adding a defaulted dummy parameter
+ //!
+ //! This function doesn't participate on overload resolution when @c conversion::enable_functor<Source>::type.
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(from, boost::dummy::type_tag<Target>());
- }
- }
+#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ typename disable_if<typename conversion::enable_functor<Source>::type, Target>::type
+#else
+ Target
#endif
+ convert_to(Source const& from, boost::dummy::base_tag<Target> const& p=boost::dummy::base_tag<Target>()) {
+ (void)p;
- //!
- //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
- //! @Throws Whatever the underlying conversion @c To operator of the @c From class or the copy constructor of the @c To class throws.
- //!
- //! This function can be partially specialized on compilers supporting it.
- //! A trick is used to partially specialize on the return type by adding a dummy parameter.
- template <typename Target, typename Source>
- Target convert_to(Source const& from
- , boost::dummy::base_tag<Target> const& p=boost::dummy::base_tag<Target>()) {
- (void)p;
- return conversion_impl::convert_to_impl<Target>(from);
+ return boost::conversion::impl::convert_to_impl<Target>(from);
+ }
}
-
}
#endif
Modified: sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -27,7 +27,7 @@
The technique consists in partially specialize on the function @c convert_to_or_fallback on the @c boost::conversion namespace.
For compilers for which we can not partially specialize a function a trick is used: instead of calling directly to the @c convert_to_or_fallback member function,
-_at_c convert_to_or_fallback calls to the static operation apply on a class with the same name in the namespace @c partial_specialization_workaround.
+@c convert_to_or_fallback calls to the static operation apply on a class with the same name in the namespace @c overload_workaround.
Thus the user can specialize partially this class.
*/
@@ -38,7 +38,7 @@
namespace boost {
namespace conversion {
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
//! <c>struct convert_to_or_fallback</c> used when overloading can not be applied.
//! This struct can be specialized by the user.
template < typename To, typename From, typename Fallback>
@@ -51,7 +51,7 @@
{
try
{
- return boost::convert_to<To>(val);
+ return boost::conversion::convert_to<To>(val);
}
catch (...)
{
@@ -69,7 +69,7 @@
//! Forwards the call to the overload workarround, which can yet be specialized by the user for standard C++ types.
template < typename To, typename From, typename Fallback >
To convert_to_or_fallback(const From& val, Fallback const& fallback, dummy::type_tag<To> const&) {
- return conversion::partial_specialization_workaround::convert_to_or_fallback<To,From>::apply(val, fallback);
+ return conversion::overload_workaround::convert_to_or_fallback<To,From>::apply(val, fallback);
}
}
#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -17,7 +17,7 @@
template < typename To, typename Via, typename From >
To convert_to_via(const From& val) {
- boost::convert_to<To>(boost::convert_to<Via>(val));
+ boost::conversion::convert_to<To>(boost::conversion::convert_to<Via>(val));
}
}}
Modified: sandbox/conversion/boost/conversion/fp/convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/fp/convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/fp/convert_to.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -11,22 +11,36 @@
#ifndef BOOST_CONVERSION_FP_CONVERT_TO_HPP
#define BOOST_CONVERSION_FP_CONVERT_TO_HPP
+#include <boost/conversion/convert_to.hpp>
#include <boost/phoenix/core/limits.hpp>
#include <boost/phoenix/core/call.hpp>
#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/core/meta_grammar.hpp>
#include <boost/phoenix/object/detail/target.hpp>
#include <boost/proto/transform/lazy.hpp>
-
+#include <boost/phoenix/core/is_actor.hpp>
+#include <boost/utility/enable_if.hpp>
+
+#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+
BOOST_PHOENIX_DEFINE_EXPRESSION(
- (boost)(conversion)(fp)(convert_to)
+ (boost)(conversion)(convert_to)
, (proto::terminal<boost::phoenix::detail::target<proto::_> >)
(boost::phoenix::meta_grammar)
)
+#endif
+
namespace boost {
namespace conversion {
- namespace fp {
+
+ //! @c enable_functor meta-function specialization for types @c T satisfying @c phoenix::is_actor<T>.
+
+ //! The nested type @ type is @c mpl::true_.
+ template <typename T>
+ struct enable_functor<T, typename enable_if<phoenix::is_actor<T> >::type> : mpl::true_ {};
+
+ namespace detail {
struct convert_to_eval
{
template <typename Sig>
@@ -41,7 +55,7 @@
typename boost::phoenix::detail::result_of::target<Target>::type
operator()(Target, Source const& u, Context const& ctx) const
{
- return boost::convert_to<
+ return boost::conversion::convert_to<
typename boost::phoenix::detail::result_of::target<Target>::type
>(boost::phoenix::eval(u, ctx));
}
@@ -49,26 +63,46 @@
}
}
+#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
namespace phoenix {
+
+ //! specialization of @c phoenix::default_actions::when for the @c convert_to rule.
template <typename Dummy>
- struct default_actions::when<boost::conversion::fp::rule::convert_to, Dummy>
- : call<boost::conversion::fp::convert_to_eval, Dummy>
+ struct default_actions::when<boost::conversion::rule::convert_to, Dummy>
+ : call<boost::conversion::detail::convert_to_eval, Dummy>
{};
}
+#endif
+
namespace conversion {
- namespace fp {
-
- template <typename T, typename U>
- inline
+
+ //! @brief Lazily convert to a type @Target from an arbitrary argument.
+ //!
+ //! This overload of @convert_to is taken in account when the parameter @c Source is a place_holder.
+ //!
+ //! @Returns A unary functor that will call to the convert_to function on its parameter.
+ //! @Throws Whatever the underlying conversion @c To operator of the @c From class or the copy constructor of the @c To class throws.
+ //! @Example
+ //! @code
+ //! boost::conversion::convert_to<int>(_1)(v);
+ //! @endcode
+ //! Creates a functor that when applied to the parameter v, converts it to an @c int.
+ template <typename T, typename U>
+ inline
+#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ typename enable_if<typename boost::conversion::enable_functor<U>::type,
typename expression::convert_to<boost::phoenix::detail::target<T>, U>::type const
- convert_to(U const& u)
- {
- return
- expression::
- convert_to<boost::phoenix::detail::target<T>, U>::
- make(boost::phoenix::detail::target<T>(), u);
- }
+ >::type
+#else
+ typename expression::convert_to<boost::phoenix::detail::target<T>, U>::type const
+#endif
+ convert_to(U const& u)
+ {
+ return
+ expression::
+ convert_to<boost::phoenix::detail::target<T>, U>::
+ make(boost::phoenix::detail::target<T>(), u);
}
}
}
Modified: sandbox/conversion/boost/conversion/std/complex.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/complex.hpp (original)
+++ sandbox/conversion/boost/conversion/std/complex.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -25,20 +25,20 @@
namespace conversion {
// std namespace can not be overloaded
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
template < class T, class U>
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>(boost::conversion::convert_to<T>(from.real()), boost::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() = boost::conversion::convert_to<T>(from.real());
+ to.imag() = boost::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 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -24,20 +24,20 @@
namespace boost { namespace conversion {
// std namespace can not be overloaded
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
template < class T1, class T2, class U1, class U2>
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>(boost::conversion::convert_to<T1>(from.first), boost::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 = boost::conversion::convert_to<T1>(from.first);
+ to.second = boost::conversion::convert_to<T2>(from.second);
return to;
}
};
Modified: sandbox/conversion/boost/conversion/std/string.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/string.hpp (original)
+++ sandbox/conversion/boost/conversion/std/string.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -29,7 +29,7 @@
namespace conversion {
// std namespace can not be overloaded
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
template<typename T, typename CharT, typename Traits, typename Alloc>
struct convert_to< std::basic_string<CharT,Traits,Alloc>, T > {
@@ -59,7 +59,7 @@
inline static std::basic_string<CharT,Traits,Alloc>&
apply(std::basic_string<CharT,Traits,Alloc>& to, const T& from)
{
- to = boost::convert_to<std::basic_string<CharT,Traits,Alloc> >(from);
+ to = boost::conversion::convert_to<std::basic_string<CharT,Traits,Alloc> >(from);
return to;
}
};
@@ -68,7 +68,7 @@
inline static T&
apply(T& to, const std::basic_string<CharT,Traits,Alloc>& from)
{
- to = boost::convert_to<T>(from);
+ to = boost::conversion::convert_to<T>(from);
return to;
}
};
Modified: sandbox/conversion/boost/conversion/std/vector.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/vector.hpp (original)
+++ sandbox/conversion/boost/conversion/std/vector.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -27,13 +27,13 @@
namespace boost { namespace conversion {
// std namespace can not be overloaded
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
template < class T1, class A1, class T2, class A2>
struct convert_to< std::vector<T1,A1>, std::vector<T2,A2> > {
inline static std::vector<T1,A1> apply(std::vector<T2,A2> const & from)
{
std::vector<T1,A1> res;
- boost::assign_to(res, from);
+ boost::conversion::assign_to(res, from);
return res;
}
};
@@ -45,7 +45,7 @@
{
to.resize(from.size());
for (unsigned int i=0; i<from.size(); ++i) {
- boost::assign_to(to[i], from[i]);
+ boost::conversion::assign_to(to[i], from[i]);
}
return to;
}
@@ -65,9 +65,9 @@
const & pack)
{
std::vector<T1,A1> res(fusion::at_c<1>(pack).get());
- boost::assign_to(res, fusion::at_c<0>(pack).get());
+ boost::conversion::assign_to(res, fusion::at_c<0>(pack).get());
//std::vector<T1,A1> res(pack.second.get());
- //boost::assign_to(res, pack.first.get());
+ //boost::conversion::assign_to(res, pack.first.get());
return res;
}
};
Modified: sandbox/conversion/boost/conversion/try_assign_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/try_assign_to.hpp (original)
+++ sandbox/conversion/boost/conversion/try_assign_to.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -23,7 +23,7 @@
The technique consists in partially specialize on the function @c try_assign_to on the @c boost::conversion namespace.
For compilers for which we can not partially specialize a function a trick is used:
instead of calling directly to the @c try_assign_to member function, @c try_assign_to calls to the static operation apply
-on a class with the same name in the namespace @c partial_specialization_workaround.
+on a class with the same name in the namespace @c overload_workaround.
Thus the user can specialize partially this class.
*/
@@ -37,7 +37,7 @@
namespace boost {
namespace conversion {
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
//! <c>struct try_assign_to</c> used when overloading can not be applied.
//! This struct can be specialized by the user.
template < typename To, typename From >
@@ -70,18 +70,18 @@
inline static bool apply(To(&to)[N], const From(& from)[N])
{
To rollback[N];
- boost::assign_to<To>(to, rollback);
+ boost::conversion::assign_to<To>(to, rollback);
try
{
for (std::size_t i = 0; i < N; ++i)
{
- boost::assign_to<To>(to[i] , from[i]);
+ boost::conversion::assign_to<To>(to[i] , from[i]);
}
return true;
}
catch (...)
{
- boost::assign_to<To>(rollback,to);
+ boost::conversion::assign_to<To>(rollback,to);
return false;
}
}
@@ -98,7 +98,7 @@
template < typename To, typename From >
bool try_assign_to(To& to, const From& from, dummy::type_tag<To> const&)
{
- return conversion::partial_specialization_workaround::try_assign_to<To,From>::apply(to, from);
+ return conversion::overload_workaround::try_assign_to<To,From>::apply(to, from);
}
}
Modified: sandbox/conversion/boost/conversion/try_convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/try_convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/try_convert_to.hpp 2011-05-25 18:26:22 EDT (Wed, 25 May 2011)
@@ -27,7 +27,7 @@
The technique consists in partially specialize on the function @c try_convert_to on the @c boost::conversion namespace.
For compilers for which we can not partially specialize a function a trick is used: instead of calling directly to the @c try_convert_to member function,
-_at_c try_convert_to calls to the static operation apply on a class with the same name in the namespace @c partial_specialization_workaround.
+@c try_convert_to calls to the static operation apply on a class with the same name in the namespace @c overload_workaround.
Thus the user can specialize partially this class.
*/
@@ -39,7 +39,7 @@
namespace boost {
namespace conversion {
- namespace partial_specialization_workaround {
+ namespace overload_workaround {
//! <c>struct try_convert_to</c> used when overloading can not be applied.
//! This struct can be specialized by the user.
template < typename To, typename From >
@@ -51,7 +51,7 @@
{
try
{
- return make_optional(boost::convert_to<To>(val));
+ return make_optional(boost::conversion::convert_to<To>(val));
}
catch (...)
{
@@ -60,6 +60,8 @@
}
};
}
+ }
+ namespace conversion_2 {
//! @brief Default @c try_convert_to overload, used when ADL fails.
//!
@@ -69,20 +71,22 @@
//! Forwards the call to the overload workarround, which can yet be specialized by the user for standard C++ types.
template < typename To, typename From >
optional<To> try_convert_to(const From& val, dummy::type_tag<To> const&) {
- return conversion::partial_specialization_workaround::try_convert_to<To,From>::apply(val);
+ return conversion::overload_workaround::try_convert_to<To,From>::apply(val);
}
}
#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
namespace conversion_impl {
template <typename Target, typename Source>
optional<Target> try_convert_to_impl(Source const& from) {
- using namespace boost::conversion;
+ using namespace boost::conversion_2;
//use boost::conversion::try_convert_to if ADL fails
return try_convert_to(from, boost::dummy::type_tag<Target>());
}
}
#endif
+ namespace conversion {
+
//!
//! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
//! @NoThrow
@@ -93,7 +97,8 @@
template <typename Target, typename Source>
optional<Target> try_convert_to(Source const& from, boost::dummy::base_tag<Target> const& p=boost::dummy::base_tag<Target>()) {
(void)p;
- return conversion_impl::try_convert_to_impl<Target>(from);
+ return boost::conversion_impl::try_convert_to_impl<Target>(from);
+ }
}
}
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