Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72324 - in sandbox/conversion/boost/conversion: . boost std
From: vicente.botet_at_[hidden]
Date: 2011-06-01 09:01:11


Author: viboes
Date: 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
New Revision: 72324
URL: http://svn.boost.org/trac/boost/changeset/72324

Log:
Conversion: remove overload_workaround+make CP functors
Text files modified:
   sandbox/conversion/boost/conversion/assign_to.hpp | 60 +++++++++++++--------------
   sandbox/conversion/boost/conversion/boost/array.hpp | 12 ++---
   sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 11 ++--
   sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 12 ++--
   sandbox/conversion/boost/conversion/boost/interval.hpp | 12 ++---
   sandbox/conversion/boost/conversion/boost/optional.hpp | 11 ++--
   sandbox/conversion/boost/conversion/boost/rational.hpp | 13 ++---
   sandbox/conversion/boost/conversion/boost/tuple.hpp | 10 +--
   sandbox/conversion/boost/conversion/convert_to.hpp | 24 +++++------
   sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp | 39 ++++++++----------
   sandbox/conversion/boost/conversion/std/complex.hpp | 10 +--
   sandbox/conversion/boost/conversion/std/pair.hpp | 15 +++---
   sandbox/conversion/boost/conversion/std/string.hpp | 23 ++++------
   sandbox/conversion/boost/conversion/std/vector.hpp | 42 ++++++++++----------
   sandbox/conversion/boost/conversion/try_assign_to.hpp | 84 +++++++++++++++++++--------------------
   sandbox/conversion/boost/conversion/try_convert_to.hpp | 72 ++++++++++++++++-----------------
   16 files changed, 213 insertions(+), 237 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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -31,40 +31,38 @@
 
 namespace boost {
   namespace conversion {
- namespace overload_workaround {
- //! struct used when overloading can not be applied.
- //! @tparam To target type of the conversion.
- //! @tparam From source type of the conversion.
- //! @tparam Enable A dummy parameter that can be used for SFINAE.
- template < typename To, typename From, class Enable = void>
- struct assign_to
+ //! struct used when overloading can not be applied.
+ //! @tparam To target type of the conversion.
+ //! @tparam From source type of the conversion.
+ //! @tparam Enable A dummy parameter that can be used for SFINAE.
+ template < typename To, typename From, class Enable = void>
+ struct assigner
+ {
+ //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator.
+ //! @Throws Whatever the underlying assignment operator of the @c To class throws.
+ To& operator()(To& to, const From& from)
       {
- //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator.
- //! @Throws Whatever the underlying assignment operator of the @c To class throws.
- inline static To& apply(To& to, const From& from)
- {
- to = ::boost::conversion::convert_to<To>(from);
- return to;
- }
- };
-
- //! partial specialization for c-array types.
- template < typename To, typename From, std::size_t N >
- struct assign_to<To[N],From[N],void>
+ to = ::boost::conversion::convert_to<To>(from);
+ return to;
+ }
+ };
+
+ //! partial specialization for c-array types.
+ template < typename To, typename From, std::size_t N >
+ struct assigner<To[N],From[N],void>
+ {
+ //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each one of the array elements.
+ //! @Throws Whatever the underlying assignment operator of the @c To class throws.
+ //! @Basic
+ To*& operator()(To(&to)[N], const From(& from)[N])
       {
- //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each one of the array elements.
- //! @Throws Whatever the underlying assignment operator of the @c To class throws.
- //! @Basic
- inline static To*& apply(To(&to)[N], const From(& from)[N])
+ for (std::size_t i = 0; i < N; ++i)
         {
- for (std::size_t i = 0; i < N; ++i)
- {
- to[i] = ::boost::conversion::convert_to<To>(from[i]);
- }
- return to;
+ to[i] = ::boost::conversion::convert_to<To>(from[i]);
         }
- };
- }
+ return to;
+ }
+ };
   }
 
 #if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
@@ -78,7 +76,7 @@
     template < typename To, typename From >
     To& assign_to(To& to, const From& from)
     {
- return conversion::overload_workaround::assign_to<To,From>::apply(to, from);
+ return conversion::assigner<To,From>()(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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -26,16 +26,15 @@
 namespace boost {
 
   namespace conversion {
- namespace overload_workaround {
 
       /**
        * Partial specialization of @c convert_to for @c boost::array of the same size
        */
       template < typename T1, typename T2, std::size_t N>
- struct convert_to< array<T1,N>, array<T2,N> >
+ struct converter< array<T1,N>, array<T2,N> >
       {
         //! @Returns the array having as elements the result of the conversion of each one of the source array elements.
- inline static array<T1,N> apply(array<T2,N> const & from)
+ inline array<T1,N> operator()(array<T2,N> const & from)
         {
           array<T1,N> to;
           boost::conversion::assign_to(to, from);
@@ -46,10 +45,10 @@
        * Partial specialization of @c assign_to for @c boost::array of the same size
        */
       template < typename T1, typename T2, std::size_t N>
- struct assign_to< array<T1,N>, array<T2,N> >
+ struct assigner< array<T1,N>, array<T2,N> >
       {
         //! @Effects assign to each one of the target array elements the conversion of the source array element.
- inline static array<T1,N>& apply(array<T1,N>& to, array<T2,N> const & from)
+ array<T1,N>& operator()(array<T1,N>& to, array<T2,N> const & from)
         {
           for (unsigned int i =0; i<N; ++i)
           {
@@ -58,7 +57,6 @@
           return to;
         }
       };
- }
   }
 
   #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
@@ -70,7 +68,7 @@
   inline array<T1,N>& assign_to(array<T1,N>& to, array<T2,N> const & from
   )
   {
- return conversion::overload_workaround::assign_to<array<T1,N>, array<T2,N> >::apply(to, from);
+ return conversion::assigner<array<T1,N>, array<T2,N> >()(to, from);
   }
   #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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -25,13 +25,12 @@
 
 namespace boost {
   namespace conversion {
- namespace overload_workaround {
       //! @brief @c convert_to specialization for conversions from @c boost::chrono::duration<> to @c boost::posix_time::time_duration.
       //!
         template < class Rep, class Period>
- struct convert_to<posix_time::time_duration, chrono::duration<Rep, Period> > {
+ struct converter<posix_time::time_duration, chrono::duration<Rep, Period> > {
           //! @Returns the duration converted to seconds+nanoseconds following the boost::posix_time::time_duration formatting.
- inline static posix_time::time_duration apply(chrono::duration<Rep, Period> const & from)
+ posix_time::time_duration operator()(chrono::duration<Rep, Period> const & from)
             {
                 typedef chrono::duration<Rep, Period> src_duration_t;
                 typedef chrono::nanoseconds duration_t;
@@ -51,14 +50,14 @@
         //!
 
         template < class Rep, class Period>
- struct convert_to<chrono::duration<Rep, Period>, posix_time::time_duration> {
+ struct converter<chrono::duration<Rep, Period>, posix_time::time_duration> {
           //! @Returns the duration cast from a nanoseconds duration initialized to the total number of nanosecond of the @c from parameter.
- inline static chrono::duration<Rep, Period> apply(posix_time::time_duration const & from)
+ chrono::duration<Rep, Period> operator()(posix_time::time_duration const & from)
             {
                 return chrono::duration_cast<chrono::duration<Rep, Period> >(chrono::nanoseconds(from.total_nanoseconds()));
             }
         };
- }
+
   }
 
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING

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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -26,10 +26,10 @@
 #include <boost/config.hpp>
 
 namespace boost {
- namespace conversion { namespace overload_workaround {
+ namespace conversion {
         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)
+ struct converter<posix_time::ptime, chrono::time_point<Clock, Duration> > {
+ posix_time::ptime operator()(const chrono::time_point<Clock, Duration>& from)
             {
                 typedef chrono::time_point<Clock, Duration> time_point_t;
                 typedef chrono::nanoseconds duration_t;
@@ -48,8 +48,8 @@
         };
 
         template < class Clock, class Duration>
- struct convert_to<chrono::time_point<Clock, Duration>, posix_time::ptime> {
- inline static chrono::time_point<Clock, Duration> apply(const posix_time::ptime& from)
+ struct converter<chrono::time_point<Clock, Duration>, posix_time::ptime> {
+ chrono::time_point<Clock, Duration> operator()(const posix_time::ptime& from)
             {
                 posix_time::time_duration const time_since_epoch=from-posix_time::from_time_t(0);
                 chrono::time_point<Clock, Duration> t=chrono::system_clock::from_time_t(time_since_epoch.total_seconds());
@@ -57,7 +57,7 @@
                 return t+chrono::duration_cast<Duration>(chrono::nanoseconds(nsec));
             }
         };
- }}
+ }
 
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     namespace chrono {

Modified: sandbox/conversion/boost/conversion/boost/interval.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/interval.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/interval.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -24,26 +24,24 @@
 namespace boost {
 
     namespace conversion {
- namespace overload_workaround {
         //! @brief @c convert_to specialization for source and target been @c boost::numeric::interval.
         //!
         template < class T, class PT, class U, class PU>
- struct convert_to< numeric::interval<T,PT>, numeric::interval<U,PU> > {
+ struct converter< numeric::interval<T,PT>, numeric::interval<U,PU> > {
           //! @Returns the target interval having as extremes the conversion from the source interval extremes.
- inline static numeric::interval<T,PT> apply(numeric::interval<U,PU> const & from)
+ numeric::interval<T,PT> operator()(numeric::interval<U,PU> const & from)
             {
                 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)
+ struct assigner< numeric::interval<T,PT>, numeric::interval<U,PU> > {
+ numeric::interval<T,PT>& operator()(numeric::interval<T,PT>& to, const numeric::interval<U,PU>& from)
             {
                 to.assign(boost::conversion::convert_to<T>(from.lower()), boost::conversion::convert_to<U>(from.upper()));
                 return to;
             }
         };
- }
     }
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     namespace numeric {
@@ -51,7 +49,7 @@
         inline interval<T,PT>& assign_to(interval<T,PT>& to, const interval<U,PU>& from
         )
         {
- return conversion::overload_workaround::assign_to<interval<T,PT>, interval<U,PU> >::apply(to, from);
+ return conversion::assigner<interval<T,PT>, interval<U,PU> >()(to, from);
         }
     }
 #endif

Modified: sandbox/conversion/boost/conversion/boost/optional.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/optional.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/optional.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -41,16 +41,15 @@
 #endif
 
   namespace conversion {
- namespace overload_workaround {
       /**
        * Partial specialization of @c convert_to for boost::optional
        */
       template < class Target, class Source>
- struct convert_to< optional<Target>, optional<Source> >
+ struct converter< optional<Target>, optional<Source> >
       {
         //! @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.
- inline static optional<Target> apply(optional<Source> const & from)
+ optional<Target> operator()(optional<Source> const & from)
         {
           return (from?optional<Target>(boost::conversion::convert_to<Target>(from.get())):optional<Target>());
         }
@@ -60,12 +59,12 @@
       //!
       //! We can see this specialization as a try_convert_to function.
       template < class Target, class Source>
- struct convert_to< optional<Target>, Source>
+ struct converter< optional<Target>, Source>
       {
         //! @Returns If the source is convertible to the target @c value_type
         //! @c Target initialized to the result of the conversion.
         //! Uninitialized @c Target otherwise.
- inline static optional<Target> apply(Source const & from)
+ optional<Target> operator()(Source const & from)
         {
           try
           {
@@ -78,7 +77,7 @@
         }
       };
 
- }
+
   }
 
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING

Modified: sandbox/conversion/boost/conversion/boost/rational.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/rational.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/rational.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -27,34 +27,33 @@
 namespace boost {
 
   namespace conversion {
- namespace overload_workaround {
       //! @brief @c convert_to specialization for source and target been @c boost::rational.
       //!
       template < class T, class U>
- struct convert_to< rational<T>, rational<U> > {
+ struct converter< rational<T>, rational<U> > {
         //! @Returns the target rational having as numerator and denominator the conversion from the numerator and denominator of the source rational.
- inline static rational<T> apply(rational<U> const & from)
+ rational<T> operator()(rational<U> const & from)
         {
           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)
+ struct assigner< rational<T>, rational<U> >
+ {
+ rational<T>& operator()(rational<T>& to, const rational<U>& from)
         {
           to.assign(boost::conversion::convert_to<T>(from.numerator()), boost::conversion::convert_to<T>(from.denominator()));
           return to;
         }
       };
 
- }
   }
 
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     template < class T, class U>
     inline rational<T>& assign_to(rational<T>& to, const rational<U>& from)
     {
- return conversion::overload_workaround::assign_to<rational<T>, rational<U> >::apply(to, from);
+ return conversion::assigner<rational<T>, rational<U> >()(to, from);
     }
 #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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -24,10 +24,9 @@
 namespace boost {
 
   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)
+ struct converter< fusion::tuple<T1,T2>, fusion::tuple<U1,U2> > {
+ fusion::tuple<T1,T2> operator()(fusion::tuple<U1,U2> const & from)
             {
                 return fusion::tuple<T1,T2>(
                     boost::conversion::convert_to<T1>(fusion::get<0>(from))
@@ -36,8 +35,8 @@
             }
         };
         template < class T1, class T2, class T3, class U1, class U2, class U3>
- struct convert_to< fusion::tuple<T1,T2,T3>, fusion::tuple<U1,U2,U3> > {
- inline static fusion::tuple<T1,T2,T3> apply(fusion::tuple<U1,U2,U3> const & from)
+ struct converter< fusion::tuple<T1,T2,T3>, fusion::tuple<U1,U2,U3> > {
+ fusion::tuple<T1,T2,T3> operator()(fusion::tuple<U1,U2,U3> const & from)
             {
                 return fusion::tuple<T1,T2, T3>(
                       boost::conversion::convert_to<T1>(fusion::get<0>(from))
@@ -47,7 +46,6 @@
             }
         };
 
- }
   }
 
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING

Modified: sandbox/conversion/boost/conversion/convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -58,23 +58,21 @@
     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.
+ //! customization point for @convert_to.
 
       //! @tparam To target type of the conversion.
       //! @tparam From source type of the conversion.
       //! @tparam Enable A dummy parameter that can be used for SFINAE.
 
- template < typename To, typename From, class Enable = void >
- 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.
- //! @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)
- {
- return To((val));
- }
- };
- }
+ template < typename To, typename From, class Enable = void >
+ struct converter {
+ //! @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.
+ To operator()(const From& val)
+ {
+ return To((val));
+ }
+ };
 #if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
     namespace impl_2 {
 
@@ -85,7 +83,7 @@
       //! 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& from, dummy::type_tag<To> const&) {
- return conversion::overload_workaround::convert_to<To,From>::apply(from);
+ return conversion::converter<To,From>()(from);
       }
     }
 

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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -37,28 +37,25 @@
 
 namespace boost {
   namespace conversion {
- 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>
- struct convert_to_or_fallback {
- //!
- //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
- //! @Returns the converted value if the conversion succeeds or the fallback.
- //! @NoThrow
- inline static To apply(const From& val, Fallback const& fallback)
+ //! This struct can be specialized by the user.
+ template < typename To, typename From, typename Fallback>
+ struct converter_or_fallbacker {
+ //!
+ //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
+ //! @Returns the converted value if the conversion succeeds or the fallback.
+ //! @NoThrow
+ To operator()(const From& val, Fallback const& fallback)
+ {
+ try
         {
- try
- {
- return boost::conversion::convert_to<To>(val);
- }
- catch (...)
- {
- return To((fallback));
- }
+ return boost::conversion::convert_to<To>(val);
         }
- };
- }
+ catch (...)
+ {
+ return To((fallback));
+ }
+ }
+ };
 
     #if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
     namespace impl_2 {
@@ -71,7 +68,7 @@
       //! Forwards the call to the overload workaround, 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::overload_workaround::convert_to_or_fallback<To,From,Fallback>::apply(val, fallback);
+ return conversion::converter_or_fallbacker<To,From,Fallback>()(val, fallback);
       }
     }
 

Modified: sandbox/conversion/boost/conversion/std/complex.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/complex.hpp (original)
+++ sandbox/conversion/boost/conversion/std/complex.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -25,13 +25,12 @@
   namespace conversion {
 
     // std namespace can not be overloaded
- namespace overload_workaround {
       /**
        * Partial specialization of @c convert_to for @c std::complex of the same size
        */
       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)
+ struct converter< std::complex<T>, std::complex<U> > {
+ std::complex<T> operator()(std::complex<U> const & from)
         {
           return std::complex<T>(
               boost::conversion::convert_to<T>(from.real()),
@@ -39,8 +38,8 @@
         }
       };
       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)
+ struct assigner< std::complex<T>, std::complex<U> > {
+ std::complex<T>& operator()(std::complex<T>& to, const std::complex<U>& from)
         {
           to.real() = boost::conversion::convert_to<T>(from.real());
           to.imag() = boost::conversion::convert_to<T>(from.imag());
@@ -48,7 +47,6 @@
         }
       };
 
- }
   }
 }
 

Modified: sandbox/conversion/boost/conversion/std/pair.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/pair.hpp (original)
+++ sandbox/conversion/boost/conversion/std/pair.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -21,20 +21,21 @@
 //#include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
 
-namespace boost { namespace conversion {
+namespace boost {
+ namespace conversion {
 
     // std namespace can not be overloaded
- 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)
+ struct converter< std::pair<T1,T2>, std::pair<U1,U2> > {
+ std::pair<T1,T2> operator()(std::pair<U1,U2> const & from)
             {
                 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)
+ struct assigner< std::pair<T1,T2>, std::pair<U1,U2> >
+ {
+ std::pair<T1,T2>& operator()(std::pair<T1,T2>& to, const std::pair<U1,U2>& from)
             {
                 to.first = boost::conversion::convert_to<T1>(from.first);
                 to.second = boost::conversion::convert_to<T2>(from.second);
@@ -42,7 +43,7 @@
             }
         };
     }
-}}
+}
 
 #endif
 

Modified: sandbox/conversion/boost/conversion/std/string.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/string.hpp (original)
+++ sandbox/conversion/boost/conversion/std/string.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Vicente J. Botet Escriba 2009. Distributed under the Boost
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. 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)
 //
@@ -29,11 +29,10 @@
   namespace conversion {
 
     // std namespace can not be overloaded
- namespace overload_workaround {
       
       template<typename T, typename CharT, typename Traits, typename Alloc>
- struct convert_to< std::basic_string<CharT,Traits,Alloc>, T > {
- inline static std::basic_string<CharT,Traits,Alloc> apply(T const & from)
+ struct converter< std::basic_string<CharT,Traits,Alloc>, T > {
+ std::basic_string<CharT,Traits,Alloc> operator()(T const & from)
         {
 #if !defined(BOOST_CONVERSION_USE_CONVERT)
           return lexical_cast<std::basic_string<CharT,Traits,Alloc> >(from);
@@ -43,8 +42,8 @@
         }
       };
       template<typename T, typename CharT, typename Traits, typename Alloc>
- struct convert_to< T, std::basic_string<CharT,Traits,Alloc> > {
- inline static T apply(std::basic_string<CharT,Traits,Alloc> const & from)
+ struct converter< T, std::basic_string<CharT,Traits,Alloc> > {
+ T operator()(std::basic_string<CharT,Traits,Alloc> const & from)
         {
 #if !defined(BOOST_CONVERSION_USE_CONVERT)
           return lexical_cast<T>(from);
@@ -55,18 +54,17 @@
       };
 
       template<typename T, typename CharT, typename Traits, typename Alloc>
- struct assign_to< std::basic_string<CharT,Traits,Alloc>, T > {
- inline static std::basic_string<CharT,Traits,Alloc>&
- apply(std::basic_string<CharT,Traits,Alloc>& to, const T& from)
+ struct assigner< std::basic_string<CharT,Traits,Alloc>, T > {
+ std::basic_string<CharT,Traits,Alloc>&
+ operator()(std::basic_string<CharT,Traits,Alloc>& to, const T& from)
         {
           to = boost::conversion::convert_to<std::basic_string<CharT,Traits,Alloc> >(from);
           return to;
         }
       };
       template<typename T, typename CharT, typename Traits, typename Alloc>
- struct assign_to< T, std::basic_string<CharT,Traits,Alloc> > {
- inline static T&
- apply(T& to, const std::basic_string<CharT,Traits,Alloc>& from)
+ struct assigner< T, std::basic_string<CharT,Traits,Alloc> > {
+ T& operator()(T& to, const std::basic_string<CharT,Traits,Alloc>& from)
         {
           to = boost::conversion::convert_to<T>(from);
           return to;
@@ -74,7 +72,6 @@
       };
 
       
- }
   }
 }
 

Modified: sandbox/conversion/boost/conversion/std/vector.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/vector.hpp (original)
+++ sandbox/conversion/boost/conversion/std/vector.hpp 2011-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Vicente J. Botet Escriba 2009. Distributed under the Boost
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. 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)
 //
@@ -28,40 +28,27 @@
   namespace conversion {
 
     // std namespace can not be overloaded
- 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)
+ struct converter< std::vector<T1,A1>, std::vector<T2,A2> > {
+ std::vector<T1,A1> operator()(std::vector<T2,A2> const & from)
             {
                 std::vector<T1,A1> res;
                 boost::conversion::assign_to(res, from);
                 return res;
             }
         };
- template < class T1, class A1, class T2, class A2>
- struct assign_to< std::vector<T1,A1>, std::vector<T2,A2> > {
- inline static std::vector<T1,A1>& apply(
- std::vector<T1,A1>& to,
- std::vector<T2,A2> const & from)
- {
- to.resize(from.size());
- for (unsigned int i=0; i<from.size(); ++i) {
- boost::conversion::assign_to(to[i], from[i]);
- }
- return to;
- }
- };
 
         template < class T1, class A1, class T2, class A2>
- struct convert_to< std::vector<T1,A1>,
+ struct converter< std::vector<T1,A1>,
                 //~ typename boost::conversion::result_of::pack2<std::vector<T2,A2> const, A1 const>::type
                 //~ boost::fusion::tuple<
                 std::pair<
                     boost::reference_wrapper<std::vector<T2,A2> const>,
                     boost::reference_wrapper<A1 const>
>
- > {
- inline static std::vector<T1,A1> apply(
+ >
+ {
+ std::vector<T1,A1> operator()(
                 typename boost::conversion::result_of::pack2<std::vector<T2,A2> const, A1 const>::type
                 const & pack)
             {
@@ -73,8 +60,21 @@
             }
         };
 
+ template < class T1, class A1, class T2, class A2>
+ struct assigner< std::vector<T1,A1>, std::vector<T2,A2> > {
+ std::vector<T1,A1>& operator()(
+ std::vector<T1,A1>& to,
+ std::vector<T2,A2> const & from)
+ {
+ to.resize(from.size());
+ for (unsigned int i=0; i<from.size(); ++i) {
+ boost::conversion::assign_to(to[i], from[i]);
+ }
+ return to;
+ }
+ };
     }
-}}
+}
 
 #endif
 

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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -37,56 +37,54 @@
 
 namespace boost {
   namespace conversion {
- 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 >
- struct try_assign_to
+ //! This struct can be specialized by the user.
+ template < typename To, typename From >
+ struct try_assigner
+ {
+ //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator.
+ //! @NoThrow
+ //! @Returns the converted value if success or the fallback when conversion fails.
+ bool operator()(To& to, const From& from)
       {
- //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator.
- //! @NoThrow
- //! @Returns the converted value if success or the fallback when conversion fails.
- inline static bool apply(To& to, const From& from)
+ To rollback = to;
+ try
         {
- To rollback = to;
- try
- {
- boost::conversion::assign_to<To>(to , from);
- return true;
- }
- catch (...)
- {
- to = rollback;
- return false;
- }
+ boost::conversion::assign_to<To>(to , from);
+ return true;
+ }
+ catch (...)
+ {
+ to = rollback;
+ return false;
         }
- };
- template < typename To, typename From, std::size_t N >
- struct try_assign_to<To[N],From[N]>
+ }
+ };
+ template < typename To, typename From, std::size_t N >
+ struct try_assigner<To[N],From[N]>
+ {
+ //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each vector element.
+ //! @NoThrow
+ //! @Returns the converted value if success or the fallback when conversion fails.
+ bool operator()(To(&to)[N], const From(& from)[N])
       {
- //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each vector element.
- //! @NoThrow
- //! @Returns the converted value if success or the fallback when conversion fails.
- inline static bool apply(To(&to)[N], const From(& from)[N])
+ To rollback[N];
+ boost::conversion::assign_to<To>(rollback, to);
+ try
         {
- To rollback[N];
- boost::conversion::assign_to<To>(rollback, to);
- try
- {
- for (std::size_t i = 0; i < N; ++i)
- {
- boost::conversion::assign_to<To>(to[i] , from[i]);
- }
- return true;
- }
- catch (...)
+ for (std::size_t i = 0; i < N; ++i)
           {
- boost::conversion::assign_to<To>(to, rollback);
- return false;
+ boost::conversion::assign_to<To>(to[i] , from[i]);
           }
+ return true;
         }
- };
- }
+ catch (...)
+ {
+ boost::conversion::assign_to<To>(to, rollback);
+ return false;
+ }
+ }
+ };
+
   }
 
 #if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
@@ -100,7 +98,7 @@
     template < typename To, typename From >
     bool try_assign_to(To& to, const From& from)
     {
- return conversion::overload_workaround::try_assign_to<To,From>::apply(to, from);
+ return conversion::try_assigner<To,From>()(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-06-01 09:01:09 EDT (Wed, 01 Jun 2011)
@@ -38,50 +38,48 @@
 
 namespace boost {
   namespace conversion {
- 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 >
- struct try_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.
- //! @NoThrow
- //! @Returns A optional<Ratget> uninitialized when conversion fails.
- inline static optional<To> apply(const From& val)
+ //! This struct can be specialized by the user.
+ template < typename To, typename From >
+ struct try_converter {
+ //! @Effects Converts the @c from parameter to an instance of the @c To type, using by default the conversion operator or copy constructor.
+ //! @NoThrow
+ //! @Returns A optional<Ratget> uninitialized when conversion fails.
+ optional<To> operator()(const From& val)
+ {
+ try
         {
- try
- {
- return make_optional(boost::conversion::convert_to<To>(val));
- }
- catch (...)
- {
- return optional<To>();
- }
+ return make_optional(boost::conversion::convert_to<To>(val));
         }
- };
- }
+ catch (...)
+ {
+ return optional<To>();
+ }
+ }
+ };
+
 
 #if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
- namespace impl_2 {
+ namespace impl_2 {
 
- //! @brief Default @c try_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.
- //! @NoThrow
- //! @Returns A optional<Target> uninitialized when conversion fails.
- //! Forwards the call to the overload workaround, 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::overload_workaround::try_convert_to<To,From>::apply(val);
+ //! @brief Default @c try_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.
+ //! @NoThrow
+ //! @Returns A optional<Target> uninitialized when conversion fails.
+ //! Forwards the call to the overload workaround, 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::try_converter<To,From>()(val);
+ }
     }
- }
- namespace impl {
- template <typename Target, typename Source>
- optional<Target> try_convert_to_impl(Source const& from) {
- using namespace boost::conversion::impl_2;
- //use boost::conversion::try_convert_to if ADL fails
- return try_convert_to(from, dummy::type_tag<Target>());
+ namespace impl {
+ template <typename Target, typename Source>
+ optional<Target> try_convert_to_impl(Source const& from) {
+ using namespace boost::conversion::impl_2;
+ //use boost::conversion::try_convert_to if ADL fails
+ return try_convert_to(from, dummy::type_tag<Target>());
+ }
     }
- }
 #endif
 
 


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