Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52806 - in sandbox/conversion: boost/conversion/boost libs/conversion/doc libs/conversion/test
From: vicente.botet_at_[hidden]
Date: 2009-05-06 15:35:07


Author: viboes
Date: 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
New Revision: 52806
URL: http://svn.boost.org/trac/boost/changeset/52806

Log:
Boost.Conversion V0.1 : Adding array and tuple
Added:
   sandbox/conversion/boost/conversion/boost/array.hpp (contents, props changed)
   sandbox/conversion/libs/conversion/test/array.cpp (contents, props changed)
   sandbox/conversion/libs/conversion/test/builtins.cpp
      - copied, changed from r52749, /sandbox/conversion/libs/conversion/test/builtings.cpp
   sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp (contents, props changed)
   sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp (contents, props changed)
   sandbox/conversion/libs/conversion/test/tuple.cpp (contents, props changed)
Removed:
   sandbox/conversion/libs/conversion/test/builtings.cpp
Text files modified:
   sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 2
   sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 1
   sandbox/conversion/boost/conversion/boost/tuple.hpp | 38 ++++++----
   sandbox/conversion/libs/conversion/doc/conversion.qbk | 131 +++++++++++++++++++++++++++++++++++++--
   sandbox/conversion/libs/conversion/test/Jamfile.v2 | 26 ++++---
   sandbox/conversion/libs/conversion/test/builtins.cpp | 10 +-
   6 files changed, 165 insertions(+), 43 deletions(-)

Added: sandbox/conversion/boost/conversion/boost/array.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/boost/array.hpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -0,0 +1,46 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_ARRAY__HPP
+#define BOOST_CONVERT_TO_ARRAY__HPP
+
+#include <boost/array.hpp>
+#include <boost/conversion/convert_to.hpp>
+#include <algorithm>
+
+namespace boost {
+
+ 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(from, to);
+ 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<T2,N> const & from, array<T1,N>& to)
+ {
+ std::transform(from.begin(), from.end(), to.begin(), boost::convert_to<T1,T2>);
+ //for (unsigned int i =0; i<N; ++i) {
+ // to[i]=boost::convert_to<T1>(from[i]);
+ //}
+ return to;
+ }
+ };
+
+ }
+}
+
+#endif
+

Modified: sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -49,7 +49,7 @@
         struct convert_to<chrono::duration<Rep, Period>, posix_time::time_duration> {
             inline static chrono::duration<Rep, Period> apply(posix_time::time_duration const & from)
             {
- return chrono::nanoseconds(from.total_nanoseconds());
+ return chrono::duration_cast<chrono::duration<Rep, Period> >(chrono::nanoseconds(from.total_nanoseconds()));
             }
         };
         template < class Rep, class Period>

Modified: sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -14,6 +14,7 @@
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/date_time/posix_time/conversion.hpp>
 #include <boost/conversion/convert_to.hpp>
 
 namespace boost {

Modified: sandbox/conversion/boost/conversion/boost/tuple.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/tuple.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/tuple.hpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -11,40 +11,46 @@
 #ifndef BOOST_CONVERT_TO_PAIR__HPP
 #define BOOST_CONVERT_TO_PAIR__HPP
 
-#include <boost/tr1/tuple>
+#include <boost/fusion/tuple.hpp>
 #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)
+ struct convert_to< boost::fusion::tuple<T1,T2>, boost::fusion::tuple<U1,U2> > {
+ inline static boost::fusion::tuple<T1,T2> apply(boost::fusion::tuple<U1,U2> const & from)
             {
- return std::tr1::tuple<T1,T2>(
- convert_to<T1>(std::tr1::get<0>(from))
- , convert_to<T2>(std::tr1::get<1>(from))
+ return boost::fusion::tuple<T1,T2>(
+ boost::convert_to<T1>(boost::fusion::get<0>(from))
+ , boost::convert_to<T2>(boost::fusion::get<1>(from))
                 );
             }
- inline static std::tr1::tuple<T1,T2>& apply(std::tr1::tuple<U1,U2> const & from, std::tr1::tuple<T1,T2>& to)
+ };
+ template < class T1, class T2, class U1, class U2>
+ struct assign_to< boost::fusion::tuple<T1,T2>, boost::fusion::tuple<U1,U2> > {
+ inline static boost::fusion::tuple<T1,T2>& apply(boost::fusion::tuple<U1,U2> const & from, boost::fusion::tuple<T1,T2>& to)
             {
- to = boost::convert(from);
+ to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
                 return to;
             }
         };
         template < class T1, class T2, class T3, class U1, class U2, class U3>
- 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)
+ struct convert_to< boost::fusion::tuple<T1,T2,T3>, boost::fusion::tuple<U1,U2,U3> > {
+ inline static boost::fusion::tuple<T1,T2,T3> apply(boost::fusion::tuple<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))
+ 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))
                 );
             }
- inline static std::tr1::tuple<T1,T2,T3> apply(std::tr1::tuple<U1,U2,U3> const & from, std::tr1::tuple<T1,T2,T3>& to)
+ };
+ template < class T1, class T2, class T3, class U1, class U2, class U3>
+ struct assign_to< boost::fusion::tuple<T1,T2,T3>, boost::fusion::tuple<U1,U2,U3> > {
+ inline static boost::fusion::tuple<T1,T2,T3> apply(boost::fusion::tuple<U1,U2,U3> const & from, boost::fusion::tuple<T1,T2,T3>& to)
             {
- to = boost::convert(from);
+ to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
                 return to;
             }
         };

Modified: sandbox/conversion/libs/conversion/doc/conversion.qbk
==============================================================================
--- sandbox/conversion/libs/conversion/doc/conversion.qbk (original)
+++ sandbox/conversion/libs/conversion/doc/conversion.qbk 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -5,8 +5,8 @@
  / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  /]
 
-[library Boost.Conversion
- [quickbook 1.3]
+[article Toward Boost.Conversion
+ [quickbook 1.4]
     [authors [Botet Escriba, Vicente J.]]
     [copyright 2009 Vicente J. Botet Escriba]
     [id boost.conversion]
@@ -22,7 +22,7 @@
 [def __convert_to__ `convert_to`]
 [def __assign_to__ `assign_to`]
 
-[import ../../../boost/conversion/chrono_time_point_to_posix_time_ptime.hpp]
+[import ../../../boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp]
 [import ../../../boost/conversion/std/pair.hpp]
 [import ../../../boost/conversion/boost/optional.hpp]
 
@@ -394,6 +394,8 @@
 [section:complex_hpp Header `<boost/conversion/std/complex.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions between complex of convertible types.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template < class T, class U>
@@ -413,6 +415,8 @@
 [section:pair_hpp Header `<boost/conversion/std/pair.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions between pairs of convertible types.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template < class T1, class T2, class U1, class U2>
@@ -431,6 +435,8 @@
 [section:string_hpp Header `<boost/conversion/std/string.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions to std::string.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template<typename T, typename CharT, typename Traits, typename Alloc>
@@ -459,6 +465,8 @@
 [section:rational_hpp Header `<boost/conversion/boost/rational.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions between rational of convertible types.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template < class T, class U>
@@ -477,6 +485,8 @@
 [section:chrono_posix_time_hpp Header `<boost/conversion/boost/chrono_posix_time.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions between chrono and posix_time time and duration types.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template < class Rep, class Period>
@@ -535,6 +545,8 @@
 [section:interval_hpp Header `<boost/conversion/boost/interval.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions between intervals of convertible types.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template < class T, class PT, class U, class PU>
@@ -555,6 +567,8 @@
 [section:optional_hpp Header `<boost/conversion/boost/optional.hpp>`]
 [/==========================================================================================]
 
+Include this file when using conversions between optional of convertible types.
+
     namespace boost {
         namespace partial_specialization_workaround {
             template < class Target, class Source>
@@ -571,6 +585,53 @@
     }
 
 [endsect]
+
+[/==========================================================================================]
+[section:array_hpp Header `<boost/conversion/boost/array.hpp>`]
+[/==========================================================================================]
+
+Include this file when using conversions between arrays of convertible types.
+
+ namespace boost {
+
+ 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);
+ };
+ 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<T2,N> const & from, array<T1,N>& to);
+ };
+ }
+ }
+
+
+[endsect]
+
+[/==========================================================================================]
+[section:tuple_hpp Header `<boost/conversion/boost/tuple.hpp>`]
+[/==========================================================================================]
+
+Include this file when using conversions between fusion::tuple of convertible types.
+
+ namespace boost {
+ namespace partial_specialization_workaround {
+ template < class T1, ..., class Tn, class U1, ..., class Un>
+ struct convert_to< boost::fusion::tuple<T1,...,T3>, boost::fusion::tuple<U1,...,U3> > {
+ inline static boost::fusion::tuple<T1,...,T3>
+ apply(boost::fusion::tuple<U1,...,U3> const & from);
+ };
+ template < class T1, ..., class Tn, class U1, ..., class Un>
+ struct assign_to< boost::fusion::tuple<T1,...,T3>, boost::fusion::tuple<U1,...,U3> > {
+ inline static boost::fusion::tuple<T1,...,T3>
+ apply(boost::fusion::tuple<U1,...,U3> const & from, boost::fusion::tuple<T1,...,T3>& to);
+ };
+
+ }
+ }
+
+[endsect]
 [endsect]
 
 [section Examples]
@@ -592,8 +653,17 @@
 [section Appendices]
 [/=================]
 [section:history Appendix A: History]
+[section [*Version 0.2.0, Mai 16, 2009] ['Adding]]
+
+[*New Features:]
+
+* conversion between boost::array of explicitly convertible types.
+* conversion between Boost.Fusion sequences of explicitly convertible types.
+
+[endsect]
 [section [*Version 0.1.0, April 16, 2009] ['Announcement of Conversions]]
 
+
 [*Features:]
 
 * a generic convert_to function which can be specialized by the user to make explict conversion between unrelated types.
@@ -616,13 +686,56 @@
 
 [section:rationale Appendix B: Rationale]
 
+[heading Mathematical background]
+
+Let be
+
+ A a,a2;
+ B b;
+ C c;
+
+* Reflexive: A is convertible to A if it is CopyConstructible
+
+* Symetric : A convertible to B implies B convertible to C
+
+* Loss of precission: Conversions can loss precission but not at infinitum
+
+Two convertible types don't loss precission if
+
+ b = convert_to<B>(a);
+ a2 = convert_to<A>(b);
+ assert(a==a2);
+
+If they can loss precission they satisfy
+
+ b = convert_to<B>(a)
+ a2 = convert_to<A>(b)
+ assert(a==a2 || ct(a2)==b
+
+* Transitive: A convertible to B && B convertible to C implies A convertible to C
+
+The implementation could use a intermediary B b to make the conversion or make the conversion directly.
+
+ template <>
+ convert_to<C,A>(const C& c) {
+ return convert_to<A>(convert_to<B>(c));
+ }
+
+
+
 [heading Why use partial function specialization and not ADL?]
 
+
 [endsect]
 
 [section:implementation Appendix C: Implementation Notes]
 
-TBC
+[heading Why `convert_to` between tuples is not be implemented using `boost::fusion::transform`?]
+
+`convert_to<T>` is a kind of transaformation, so the natural implementation of convert_to for homegeneus containers could be to use the transform function.
+
+This can not be applied to heterogeneus containers as tuples because the function change with the type.
+
 
 [endsect]
 [section:acknowledgements Appendix D: Acknowledgements]
@@ -632,11 +745,11 @@
 [endsect]
 [section Appendix E: Tests]
 
-[section Builtings]
+[section Builtins]
 [table
     [[Name] [kind] [Description] [Result] [Ticket]]
- [[convert_to_with_builting_types] [run] [check convert_to works for builting types] [Pass] [#]]
- [[assign_to_with_builting_types] [run] [check assign_to works for builting types] [Pass] [#]]
+ [[convert_to_with_builtin_types] [run] [check convert_to works for builting types] [Pass] [#]]
+ [[assign_to_with_builtin_types] [run] [check assign_to works for builting types] [Pass] [#]]
 ]
 [endsect]
 
@@ -681,6 +794,8 @@
     [[convert_to_ptime] [run] [check convert_to ptime from time_point works] [Pass] [#]]
     [[convert_to_duration] [run] [check convert_to duration from time_duration works] [Pass] [#]]
     [[convert_to_time_duration] [run] [check convert_to time_duration from duration works] [Pass] [#]]
+ [[convert_to_array] [run] [check convert_to array works when the parameters are convertible] [Pass] [#]]
+ [[convert_to_tuple] [run] [check convert_to tuple works when the parameters are convertible] [Pass] [#]]
 ]
 [endsect]
 
@@ -696,8 +811,6 @@
 [heading Tasks to do before review]
 
 * conversion between std::vector of explicitly convertible types.
-* conversion between boost::array of explicitly convertible types.
-* conversion between Boost.Fusion sequences of explicitly convertible types.
 
 [heading For later releases]
 

Modified: sandbox/conversion/libs/conversion/test/Jamfile.v2
==============================================================================
--- sandbox/conversion/libs/conversion/test/Jamfile.v2 (original)
+++ sandbox/conversion/libs/conversion/test/Jamfile.v2 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -17,34 +17,32 @@
 
 project :
     : requirements
- <include>$(BOOST_ROOT)
+# <include>$BOOST_ROOT
         <include>../../..
         <include>../../../../chrono
         
- <threading>multi
+# <threading>multi
 # <target-os>cygwin
         #<threadapi>pthread
- <variant>debug
+# <variant>debug
         
- #<library>/boost/test//boost_unit_test_framework/<link>static
+# <library>/boost/test//boost_unit_test_framework/<link>static
         #<library>/boost/thread//boost_thread/<link>static
- <library>../../../../chrono/libs/chrono/build//boost_chrono/<link>static
+ <library>/sandbox/chrono/libs/chrono/build//boost_chrono/<link>static
+ <library>/boost_1_39_0/libs/system/build//boost_system/<link>static
+ #<library>/sandbox/chrono/libs/chrono/build//boost_chrono
         
- <library>../../../../../boost_1_38_0/libs/test/build//boost_unit_test_framework/<link>static
-# <library>../../../../../boost_1_38_0/libs/thread/build//boost_thread/<link>static
+ <library>/boost_1_39_0/libs/test/build//boost_unit_test_framework/<link>static
+# <library>/boost_1_39_0/libs/thread/build//boost_thread/<link>static
 # <library>../../../../../boost_1_38_0/libs/system/build//boost_system/<link>static
       
 ;
 
-#exe helpers
-# : ../example/IL_BancAccount.cpp
-# : <define>BOOST_SYNCHRO_DO_NOT_COMPILE
-# ;
 
 
      
 test-suite "conversion" :
- [ run builtings.cpp ]
+ [ run builtins.cpp ]
      [ run intrinsec.cpp ]
      [ run extrinsec.cpp ]
      [ run pair.cpp ]
@@ -52,6 +50,10 @@
      [ run interval.cpp ]
      [ run rational.cpp ]
      [ run optional.cpp ]
+ [ run array.cpp ]
+ [ run tuple.cpp ]
+ [ run chrono_posix_time_time.cpp ]
+ [ run chrono_posix_time_duration.cpp ]
     ;
 
 

Added: sandbox/conversion/libs/conversion/test/array.cpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/libs/conversion/test/array.cpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -0,0 +1,75 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/boost/array.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+struct A1{};
+struct A2{};
+struct B1{};
+struct B2{};
+
+namespace boost {
+ template <>
+ A1 convert_to<A1,B1>(const B1& val) {
+ return A1();
+ }
+
+ template <>
+ A1& assign_to<A1,B1>(const B1& from, A1& to) {
+ return to;
+ }
+
+ namespace partial_specialization_workaround {
+ template <>
+ struct convert_to< A2,B2 > {
+ inline static A2 apply(B2 const & from)
+ {
+ return A2();
+ }
+ };
+ template < >
+ struct assign_to< A2,B2 > {
+ inline static A2& apply(const B2& from, A2& to)
+ {
+ return to;
+ }
+ };
+ }
+
+
+}
+void explicit_convert_to() {
+ boost::array<B1,3> bs;
+ boost::array<A1,3> as;
+ as = convert_to<boost::array<A1,3> >(bs);
+
+}
+void explicit_assign_to() {
+ boost::array<int,3> bs;
+ boost::array<short,3> as;
+ assign_to(bs,as);
+
+
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("array");
+ test->add(BOOST_TEST_CASE(&explicit_convert_to));
+ test->add(BOOST_TEST_CASE(&explicit_assign_to));
+ return test;
+}
+

Deleted: sandbox/conversion/libs/conversion/test/builtings.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/builtings.cpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
+++ (empty file)
@@ -1,125 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/conversion/convert_to.hpp>
-#include <iostream>
-#include <boost/test/unit_test.hpp>
-
-using namespace boost;
-using namespace boost::unit_test;
-
-
-
-void convert_to_with_builting_types() {
- char c=0;
- short s=1;
- int i=2;
- long l=3;
- unsigned char uc(c);
- unsigned short us(s);
- unsigned int ui(i);
- unsigned long ul(l);
-
- c=convert_to<char>(c);
- s=convert_to<short>(c);
- i=convert_to<int>(c);
- l=convert_to<long>(c);
- uc=convert_to<unsigned char>(c);
- us=convert_to<unsigned short>(c);
- ui=convert_to<unsigned int>(c);
- ul=convert_to<unsigned long>(c);
-
-
- c=convert_to<char>(s);
- s=convert_to<short>(s);
- i=convert_to<int>(s);
- l=convert_to<long>(s);
- uc=convert_to<unsigned char>(s);
- us=convert_to<unsigned short>(s);
- ui=convert_to<unsigned int>(s);
- ul=convert_to<unsigned long>(s);
-
- c=convert_to<char>(i);
- s=convert_to<short>(i);
- i=convert_to<int>(i);
- l=convert_to<long>(i);
- uc=convert_to<unsigned char>(i);
- us=convert_to<unsigned short>(i);
- ui=convert_to<unsigned int>(i);
- ul=convert_to<unsigned long>(i);
-
- c=convert_to<char>(l);
- s=convert_to<short>(l);
- i=convert_to<int>(l);
- l=convert_to<long>(l);
- uc=convert_to<unsigned char>(l);
- us=convert_to<unsigned short>(l);
- ui=convert_to<unsigned int>(l);
- ul=convert_to<unsigned long>(l);
-}
-
-
-void assign_to_with_builting_types() {
- char c=0;
- short s=1;
- int i=2;
- long l=3;
- unsigned char uc(c);
- unsigned short us(s);
- unsigned int ui(i);
- unsigned long ul(l);
-
- assign_to(c,c);
- assign_to(c, s);
- assign_to(c, i);
- assign_to(c, l);
- assign_to(c, uc);
- assign_to(c, us);
- assign_to(c, ui);
- assign_to(c, ul);
-
- assign_to(s,c);
- assign_to(s, s);
- assign_to(s, i);
- assign_to(s, l);
- assign_to(s, uc);
- assign_to(s, us);
- assign_to(s, ui);
- assign_to(s, ul);
-
- assign_to(i,c);
- assign_to(i, s);
- assign_to(i, i);
- assign_to(i, l);
- assign_to(i, uc);
- assign_to(i, us);
- assign_to(i, ui);
- assign_to(i, ul);
-
- assign_to(l,c);
- assign_to(l, s);
- assign_to(l, i);
- assign_to(l, l);
- assign_to(l, uc);
- assign_to(l, us);
- assign_to(l, ui);
- assign_to(l, ul);
-
-
-}
-
-test_suite* init_unit_test_suite(int, char*[])
-{
- test_suite* test = BOOST_TEST_SUITE("builtings");
- test->add(BOOST_TEST_CASE(&convert_to_with_builting_types));
- test->add(BOOST_TEST_CASE(&assign_to_with_builting_types));
- return test;
-}
-

Copied: sandbox/conversion/libs/conversion/test/builtins.cpp (from r52749, /sandbox/conversion/libs/conversion/test/builtings.cpp)
==============================================================================
--- /sandbox/conversion/libs/conversion/test/builtings.cpp (original)
+++ sandbox/conversion/libs/conversion/test/builtins.cpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -17,7 +17,7 @@
 
 
 
-void convert_to_with_builting_types() {
+void convert_to_with_builtin_types() {
     char c=0;
     short s=1;
     int i=2;
@@ -66,7 +66,7 @@
 }
 
 
-void assign_to_with_builting_types() {
+void assign_to_with_builtin_types() {
     char c=0;
     short s=1;
     int i=2;
@@ -117,9 +117,9 @@
 
 test_suite* init_unit_test_suite(int, char*[])
 {
- test_suite* test = BOOST_TEST_SUITE("builtings");
- test->add(BOOST_TEST_CASE(&convert_to_with_builting_types));
- test->add(BOOST_TEST_CASE(&assign_to_with_builting_types));
+ test_suite* test = BOOST_TEST_SUITE("builtins");
+ test->add(BOOST_TEST_CASE(&convert_to_with_builtin_types));
+ test->add(BOOST_TEST_CASE(&assign_to_with_builtin_types));
   return test;
 }
 

Added: sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/boost/chrono_posix_time.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+typedef int A1;
+typedef short B1;
+
+void explicit_convert_to() {
+ chrono::seconds a(3);
+ posix_time::time_duration b(convert_to<posix_time::time_duration >(a));
+ chrono::seconds c(convert_to<chrono::seconds>(b));
+
+}
+void explicit_assign_to() {
+ chrono::seconds a(3);
+ posix_time::time_duration b;
+ assign_to(a, b);
+ chrono::seconds c;
+ assign_to(b,c);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("duration");
+ test->add(BOOST_TEST_CASE(&explicit_convert_to));
+ test->add(BOOST_TEST_CASE(&explicit_assign_to));
+ return test;
+}
+

Added: sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/boost/chrono_posix_time.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+typedef int A1;
+typedef short B1;
+
+void explicit_convert_to() {
+ chrono::system_clock::time_point a=chrono::system_clock::now();
+ posix_time::ptime b(convert_to<posix_time::ptime >(a));
+ chrono::system_clock::time_point c(convert_to<chrono::system_clock::time_point>(b));
+
+}
+void explicit_assign_to() {
+ chrono::system_clock::time_point a=chrono::system_clock::now();
+ posix_time::ptime b;
+ assign_to(a, b);
+ chrono::system_clock::time_point c;
+ assign_to(b,c);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("time");
+ test->add(BOOST_TEST_CASE(&explicit_convert_to));
+ test->add(BOOST_TEST_CASE(&explicit_assign_to));
+ return test;
+}
+

Added: sandbox/conversion/libs/conversion/test/tuple.cpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/libs/conversion/test/tuple.cpp 2009-05-06 15:35:06 EDT (Wed, 06 May 2009)
@@ -0,0 +1,81 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/boost/tuple.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+struct A1{};
+struct A2{};
+struct B1{};
+struct B2{};
+
+namespace boost {
+ template <>
+ A1 convert_to<A1,B1>(const B1& val) {
+ return A1();
+ }
+
+ template <>
+ A1& assign_to<A1,B1>(const B1& from, A1& to) {
+ return to;
+ }
+
+ namespace partial_specialization_workaround {
+ template <>
+ struct convert_to< A2,B2 > {
+ inline static A2 apply(B2 const & from)
+ {
+ return A2();
+ }
+ };
+ template < >
+ struct assign_to< A2,B2 > {
+ inline static A2& apply(const B2& from, A2& to)
+ {
+ return to;
+ }
+ };
+ }
+
+
+}
+void explicit_convert_to() {
+ B1 b1;
+ B2 b2;
+ boost::fusion::tuple<B1,B2> b;
+ boost::fusion::tuple<A1,A2> a1(convert_to<boost::fusion::tuple<A1,A2> >(b));
+ boost::fusion::tuple<A1,A2> a2(convert_to<boost::fusion::tuple<A1,A2> >(boost::fusion::tuple<B1,B2>(b1,b2)));
+ boost::fusion::tuple<A1,A2> a3(convert_to<boost::fusion::tuple<A1,A2> >(boost::fusion::make_tuple(b1,b2)));
+
+}
+void explicit_assign_to() {
+ B1 b1;
+ B2 b2;
+ boost::fusion::tuple<A1,A2> a;
+ boost::fusion::tuple<B1,B2> b;
+ assign_to(b,a);
+ assign_to(boost::fusion::tuple<B1,B2>(b1,b2),a);
+ assign_to(boost::fusion::make_tuple(b1,b2),a);
+
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("tuple");
+ test->add(BOOST_TEST_CASE(&explicit_convert_to));
+ test->add(BOOST_TEST_CASE(&explicit_assign_to));
+ return test;
+}
+


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