Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52363 - in sandbox/synchro/boost/convertion: . boost std
From: vicente.botet_at_[hidden]
Date: 2009-04-12 21:34:02


Author: viboes
Date: 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
New Revision: 52363
URL: http://svn.boost.org/trac/boost/changeset/52363

Log:
0.3.1 : Change from convert_to to conversion

Added:
   sandbox/synchro/boost/convertion/
      - copied from r52161, /sandbox/synchro/boost/convert_to/
   sandbox/synchro/boost/convertion/boost/
   sandbox/synchro/boost/convertion/boost/chrono_posix_time.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/boost/chrono_ptime.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/boost/interval.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/boost/optional.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/boost/rational.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/boost/tuple.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/std/
   sandbox/synchro/boost/convertion/std/complex.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/std/pair.hpp (contents, props changed)
   sandbox/synchro/boost/convertion/std/string.hpp (contents, props changed)
Text files modified:
   sandbox/synchro/boost/convertion/chrono_duration_to_posix_time_duration.hpp | 18 +++++++++++++-----
   sandbox/synchro/boost/convertion/chrono_time_point_to_posix_time_ptime.hpp | 18 +++++++++++++-----
   sandbox/synchro/boost/convertion/convert_to.hpp | 32 ++++++++++++++++++++++++++++++--
   3 files changed, 56 insertions(+), 12 deletions(-)

Added: sandbox/synchro/boost/convertion/boost/chrono_posix_time.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/boost/chrono_posix_time.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,18 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_CHRONO_POSIX_TIME__HPP
+#define BOOST_CONVERT_TO_CHRONO_POSIX_TIME__HPP
+
+#include <boost/conversion/chrono_time_point_to_posix_time_ptime.hpp>
+#include <boost/conversion/chrono_duration_to_posix_time_duration.hpp>
+
+#endif
+

Added: sandbox/synchro/boost/convertion/boost/chrono_ptime.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/boost/chrono_ptime.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,18 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_CHRONO_PTIME__HPP
+#define BOOST_CONVERT_TO_CHRONO_PTIME__HPP
+
+#include <boost/conversion/chrono_time_point_to_posix_time_ptime.hpp>
+#include <boost/conversion/chrono_duration_to_posix_time_duration.hpp>
+
+#endif
+

Added: sandbox/synchro/boost/convertion/boost/interval.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/boost/interval.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_PAIR__HPP
+#define BOOST_CONVERT_TO_PAIR__HPP
+
+#include <boost/interval.hpp>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_workaround {
+ template < class T, class PT, class U, class PU>
+ struct convert_to< interval<T,PT>, interval<U,PU> > {
+ inline static interval<T,PT> apply(interval<U,PU> const & from)
+ {
+ return interval<T,PT>(convert_to<T>(from.lower()), convert_to<T2>(from.upper()));
+ }
+ };
+ template < class T, class PT, class U, class PU>
+ struct assign_to< interval<T,PT>, interval<U,PU> > {
+ struct assign_to< interval<T,PT>, interval<U,PU> > {
+ inline static interval<T,PT>& apply(const interval<U,PU>& from, interval<T,PT>& to)
+ {
+ to.assign(convert_to<T1>(from.lower()), convert_to<T1>(from.upper()));
+ return to;
+ }
+ };
+
+ }
+}
+
+#endif
+

Added: sandbox/synchro/boost/convertion/boost/optional.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/boost/optional.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_OPTIONAL__HPP
+#define BOOST_CONVERT_TO_OPTIONAL__HPP
+
+#include <<boost/optional>
+#include <boost/none.hpp>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_workaround {
+ template < class Target, class Source>
+ struct convert_to< optional<Target>, optional<Source> > {
+ inline static optional<Target> apply(optional<Source> const & from)
+ {
+ return (from?optional<Target>(convert_to<Target>(from)):optional<Target>());
+ }
+ };
+ template < class Target, class Source>
+ struct assign_to< optional<Target>, optional<Source> > {
+ inline static optional<Target>& apply(const optional<Target>& from, optional<Target>& to)
+ {
+ to = from?convert_to<Target>(from):none;
+ }
+ };
+
+ }
+}
+
+#endif
+

Added: sandbox/synchro/boost/convertion/boost/rational.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/boost/rational.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_PAIR__HPP
+#define BOOST_CONVERT_TO_PAIR__HPP
+
+#include <boost/rational.hpp>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_workaround {
+ template < class T, class U>
+ struct convert_to< rational<T>, rational<U> > {
+ inline static rational<T> apply(rational<U> const & from)
+ {
+ return rational<T>(convert_to<T1>(from.numerator()), convert_to<T2>(from.denominator()));
+ }
+ };
+ template < class T, class U>
+ struct assign_to< rational<T>, rational<U> > {
+ inline static rational<T>& apply(const rational<U>& from, rational<T>& to)
+ {
+ to.assign(convert_to<T1>(from.numerator()), convert_to<T1>(from.denominator()));
+ return to;
+ }
+ };
+
+ }
+}
+
+#endif
+

Added: sandbox/synchro/boost/convertion/boost/tuple.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/boost/tuple.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,54 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_PAIR__HPP
+#define BOOST_CONVERT_TO_PAIR__HPP
+
+#include <boost/tr1/tuple>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_workaround {
+ template < class T1, class T2, class U1, class U2>
+ struct convert_to< std::tr1::tuple<T1,T2>, std::tr1::tuple<U1,U2> > {
+ inline static std::tr1::tuple<T1,T2> apply(std::tr1::tuple<U1,U2> const & from)
+ {
+ return std::tr1::tuple<T1,T2>(
+ convert_to<T1>(std::tr1::get<0>(from))
+ , convert_to<T2>(std::tr1::get<1>(from))
+ );
+ }
+ inline static void apply(std::tr1::tuple<U1,U2> const & from, std::tr1::tuple<T1,T2>& to)
+ {
+ to = apply(from);
+ }
+ };
+ template < class T1, class T2, class T3, class U1, class U2, class U3>
+ struct convert_to< std::tr1::tuple<T1,T2,T3>, std::tr1::tuple<U1,U2,U3> > {
+ inline static std::tr1::tuple<T1,T2,T3> apply(std::tr1::tuple<U1,U2,U3> const & from)
+ {
+ return std::tr1::tuple<T1,T2, T3>(
+ convert_to<T1>(std::tr1::get<0>(from))
+ , convert_to<T2>(std::tr1::get<1>(from))
+ , convert_to<T3>(std::tr1::get<2>(from))
+ );
+ }
+ inline static void apply(std::tr1::tuple<U1,U2,U3> const & from, std::tr1::tuple<T1,T2,T3>& to)
+ {
+ to = apply(from);
+ }
+ };
+
+ }
+}
+
+#endif
+

Modified: sandbox/synchro/boost/convertion/chrono_duration_to_posix_time_duration.hpp
==============================================================================
--- /sandbox/synchro/boost/convert_to/chrono_duration_to_posix_time_duration.hpp (original)
+++ sandbox/synchro/boost/convertion/chrono_duration_to_posix_time_duration.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -13,7 +13,7 @@
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <boost/convert_to/convert_to.hpp>
+#include <boost/conversion/convert_to.hpp>
 
 namespace boost {
 
@@ -35,9 +35,13 @@
                         boost::posix_time::microseconds((nsec+500)/1000);
 #endif
             }
- inline static void apply(const chrono::duration<Rep, Period>& from, posix_time::time_duration& to)
+ };
+ template < class Rep, class Period>
+ struct assign_to<posix_time::time_duration, chrono::duration<Rep, Period> > {
+ inline static posix_time::time_duration& apply(const chrono::duration<Rep, Period>& from, posix_time::time_duration& to)
             {
- to = apply(from);
+ to = boost::convert_to<posix_time::time_duration>(from);
+ return to;
             }
         };
 
@@ -47,9 +51,13 @@
             {
                 return chrono::nanoseconds(from.total_nanoseconds());
             }
- inline static void apply(const posix_time::time_duration& from, chrono::duration<Rep, Period> & to)
+ };
+ template < class Rep, class Period>
+ struct assign_to<chrono::duration<Rep, Period>, posix_time::time_duration> {
+ inline static chrono::duration<Rep, Period> & apply(const posix_time::time_duration& from, chrono::duration<Rep, Period> & to)
             {
- to = apply(from);
+ to = boost::convert_to<chrono::duration<Rep, Period> >(from);
+ return to;
             }
         };
     }

Modified: sandbox/synchro/boost/convertion/chrono_time_point_to_posix_time_ptime.hpp
==============================================================================
--- /sandbox/synchro/boost/convert_to/chrono_time_point_to_posix_time_ptime.hpp (original)
+++ sandbox/synchro/boost/convertion/chrono_time_point_to_posix_time_ptime.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -13,7 +13,7 @@
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <boost/convert_to/convert_to.hpp>
+#include <boost/conversion/convert_to.hpp>
 
 namespace boost {
 
@@ -36,9 +36,13 @@
                         boost::posix_time::microseconds((nsec+500)/1000);
 #endif
             }
- inline static void apply(const chrono::time_point<Clock, Duration>& from, posix_time::ptime& to)
+ };
+ template < class Clock, class Duration>
+ struct assign_to<posix_time::ptime, chrono::time_point<Clock, Duration> > {
+ inline static posix_time::ptime& apply(const chrono::time_point<Clock, Duration>& from, posix_time::ptime& to)
             {
- to = apply(from);
+ to = boost::convert_to<posix_time::ptime>(from);
+ return to;
             }
         };
         
@@ -52,9 +56,13 @@
                 return t+chrono::nanoseconds(nsec);
                 
             }
- inline static void apply(const posix_time::ptime& from, chrono::time_point<Clock, Duration>& to)
+ };
+ template < class Clock, class Duration>
+ struct assign_to<chrono::time_point<Clock, Duration>, posix_time::ptime> {
+ inline static chrono::time_point<Clock, Duration>& apply(const posix_time::ptime& from, chrono::time_point<Clock, Duration>& to)
             {
- to = apply(from);
+ to = boost::convert_to<chrono::time_point<Clock, Duration> >(from);
+ return to;
             }
         };
     }

Modified: sandbox/synchro/boost/convertion/convert_to.hpp
==============================================================================
--- /sandbox/synchro/boost/convert_to/convert_to.hpp (original)
+++ sandbox/synchro/boost/convertion/convert_to.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -11,6 +11,8 @@
 #ifndef BOOST_CONVERT_TO__HPP
 #define BOOST_CONVERT_TO__HPP
 
+#include <cstddef> //for std::size_t
+
 namespace boost {
 
   namespace partial_specialization_workaround {
@@ -20,11 +22,37 @@
       {
         return To(val);
       }
+ };
+ template < typename To, typename From >
+ struct assign_to {
       inline static void apply(const From& from, To& to)
       {
         to = from;
       }
     };
+ template < typename To, typename From, std::size_t N >
+ struct assign_to<To[N],From[N]> {
+ inline static void apply(const From(& from)[N], To (&to)[N])
+ {
+ for (std::size_t i = 0; i < N; ++i)
+ {
+ to[i] = boost::convert(from[i]);
+ }
+ return to;
+ }
+ };
+ template < typename To, typename From, std::size_t N >
+ struct convert_to<To[N],From[N]> {
+ inline static To[N] apply(const From (& val)[N])
+ {
+ To[N] to;
+ for (std::size_t i = 0; i < N; ++i)
+ {
+ to[i] = boost::convert(from[i]);
+ }
+ return to;
+ }
+ };
   }
 
   template < typename To, typename From >
@@ -33,8 +61,8 @@
   }
 
   template < typename To, typename From >
- void convert_to(const From& from, To& to) {
- partial_specialization_workaround::convert_to<To,From>::apply(from, to);
+ void assign_to(const From& from, To& to) {
+ partial_specialization_workaround::assign_to<To,From>::apply(from, to);
   }
 
 

Added: sandbox/synchro/boost/convertion/std/complex.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/std/complex.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_PAIR__HPP
+#define BOOST_CONVERT_TO_PAIR__HPP
+
+#include <complex>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_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>(convert_to<T1>(from.real()), convert_to<T2>(from.imag()));
+ }
+ };
+ template < class T, class U>
+ struct convert_to< std::complex<T>, std::complex<U> > {
+ inline static std::complex<T>& apply(const std::complex<U>& from, std::complex<T>& to)
+ {
+ to.real() = convert_to<T1>(from.real());
+ to.imag() = convert_to<T1>(from.imag());
+ return to;
+ }
+ };
+
+ }
+}
+
+#endif
+

Added: sandbox/synchro/boost/convertion/std/pair.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/std/pair.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_PAIR__HPP
+#define BOOST_CONVERT_TO_PAIR__HPP
+
+#include <<utility>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_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>(convert_to<T1>(from.first), 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(const std::pair<U1,U2>& from, std::pair<T1,T2>& to)
+ {
+ to.first = convert_to<T1>(from.first);
+ to.second = convert_to<T1>(from.second);
+ return to;
+ }
+ };
+
+ }
+}
+
+#endif
+

Added: sandbox/synchro/boost/convertion/std/string.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/convertion/std/string.hpp 2009-04-12 21:34:00 EDT (Sun, 12 Apr 2009)
@@ -0,0 +1,56 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CONVERT_TO_PAIR__HPP
+#define BOOST_CONVERT_TO_PAIR__HPP
+
+#include <string>
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ namespace partial_specialization_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)
+ {
+ return convert<std::basic_string<CharT,Traits,Alloc> >::from(from);
+ }
+ }
+ 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(const T& from, std::basic_string<CharT,Traits,Alloc>& to)
+ {
+ to = convert<std::basic_string<CharT,Traits,Alloc> >::from(from);
+ return to;
+ }
+ };
+ 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)
+ {
+ return convert<T>::from(from);
+ }
+ };
+ template<typename T, typename CharT, typename Traits, typename Alloc>
+ struct assign_to< T, std::basic_string<CharT,Traits,Alloc>> {
+ inline static void apply(const std::basic_string<CharT,Traits,Alloc>& from, T& to)
+ {
+ to = convert<T>::from(from);
+ return to;
+ }
+ };
+
+ }
+}
+
+#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