|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57065 - in sandbox/conversion: boost boost/conversion boost/conversion/boost boost/conversion/std libs/conversion/test
From: vicente.botet_at_[hidden]
Date: 2009-10-22 09:56:42
Author: viboes
Date: 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
New Revision: 57065
URL: http://svn.boost.org/trac/boost/changeset/57065
Log:
TBoost.STM: v0.3
Incopatibility:
* Changing the order of to and from parameters on assign_to.
* Now boost/conversion/convert_to.hpp and boost/conversion/assign_to.hpp files are separated.
New Features:
* Added <boost/conversion.hpp> global file.
* Added mca() function.
* Added convert_to_via function.
Test:
* Added test for the new features
Added:
sandbox/conversion/boost/conversion.hpp (contents, props changed)
sandbox/conversion/boost/conversion/ca_wrapper.hpp (contents, props changed)
sandbox/conversion/boost/conversion/convert_to_via.hpp (contents, props changed)
Text files modified:
sandbox/conversion/boost/conversion/boost/array.hpp | 5 +-
sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 5 +-
sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 5 +-
sandbox/conversion/boost/conversion/boost/interval.hpp | 3 +
sandbox/conversion/boost/conversion/boost/optional.hpp | 3 +
sandbox/conversion/boost/conversion/boost/rational.hpp | 3 +
sandbox/conversion/boost/conversion/boost/tuple.hpp | 5 +-
sandbox/conversion/boost/conversion/convert_to.hpp | 25 ------------
sandbox/conversion/boost/conversion/std/complex.hpp | 3 +
sandbox/conversion/boost/conversion/std/pair.hpp | 3 +
sandbox/conversion/boost/conversion/std/string.hpp | 5 +-
sandbox/conversion/libs/conversion/test/Jamfile.v2 | 2
sandbox/conversion/libs/conversion/test/array.cpp | 6 +-
sandbox/conversion/libs/conversion/test/builtins.cpp | 79 +++++++++++++++++++++++++++++++++++++--
sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp | 4 +-
sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp | 4 +-
sandbox/conversion/libs/conversion/test/complex.cpp | 8 ++--
sandbox/conversion/libs/conversion/test/extrinsec.cpp | 6 ++-
sandbox/conversion/libs/conversion/test/interval.cpp | 4 +-
sandbox/conversion/libs/conversion/test/intrinsec.cpp | 41 ++++++++++++++++----
sandbox/conversion/libs/conversion/test/optional.cpp | 2
sandbox/conversion/libs/conversion/test/pair.cpp | 10 ++--
sandbox/conversion/libs/conversion/test/rational.cpp | 4 +-
sandbox/conversion/libs/conversion/test/tuple.cpp | 10 ++--
24 files changed, 163 insertions(+), 82 deletions(-)
Added: sandbox/conversion/boost/conversion.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,19 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_CONVERSION__HPP
+#define BOOST_CONVERSION__HPP
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
+#include <boost/conversion/convert_to_via.hpp>
+#include <boost/conversion/ca_wrapper.hpp>
+#endif
+
Modified: sandbox/conversion/boost/conversion/boost/array.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/array.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/array.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -13,6 +13,7 @@
#include <boost/array.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
#include <algorithm>
namespace boost {
@@ -23,13 +24,13 @@
inline static array<T1,N> apply(array<T2,N> const & from)
{
array<T1,N> to;
- boost::assign_to(from, 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<T2,N> const & from, array<T1,N>& to)
+ inline static array<T1,N>& apply(array<T1,N>& to, array<T2,N> const & from)
{
std::transform(from.begin(), from.end(), to.begin(), boost::convert_to<T1,T2>);
//for (unsigned int i =0; i<N; ++i) {
Modified: sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -14,6 +14,7 @@
#include <boost/chrono/chrono.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -38,7 +39,7 @@
};
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)
+ 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);
return to;
@@ -54,7 +55,7 @@
};
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)
+ 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);
return to;
Modified: sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -16,6 +16,7 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -41,7 +42,7 @@
};
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)
+ 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);
return to;
@@ -61,7 +62,7 @@
};
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)
+ inline static chrono::time_point<Clock, Duration>& apply(chrono::time_point<Clock, Duration>& to, const posix_time::ptime& from)
{
to = boost::convert_to<chrono::time_point<Clock, Duration> >(from);
return to;
Modified: sandbox/conversion/boost/conversion/boost/interval.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/interval.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/interval.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -13,6 +13,7 @@
#include <boost/numeric/interval.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -26,7 +27,7 @@
};
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(const numeric::interval<U,PU>& from, numeric::interval<T,PT>& to)
+ 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()));
return to;
Modified: sandbox/conversion/boost/conversion/boost/optional.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/optional.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/optional.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -15,6 +15,7 @@
#include <boost/optional.hpp>
#include <boost/none.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -28,7 +29,7 @@
};
template < class Target, class Source>
struct assign_to< optional<Target>, optional<Source> > {
- inline static optional<Target>& apply(const optional<Source>& from, optional<Target>& to)
+ inline static optional<Target>& apply(optional<Target>& to, const optional<Source>& from)
{
to = from?boost::convert_to<Target>(from.get()):optional<Target>();
return to;
Modified: sandbox/conversion/boost/conversion/boost/rational.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/rational.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/rational.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -13,6 +13,7 @@
#include <boost/rational.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -26,7 +27,7 @@
};
template < class T, class U>
struct assign_to< rational<T>, rational<U> > {
- inline static rational<T>& apply(const rational<U>& from, rational<T>& to)
+ 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()));
return to;
Modified: sandbox/conversion/boost/conversion/boost/tuple.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/tuple.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/tuple.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -13,6 +13,7 @@
#include <boost/fusion/tuple.hpp>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -29,7 +30,7 @@
};
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)
+ inline static boost::fusion::tuple<T1,T2>& apply(boost::fusion::tuple<T1,T2>& to, boost::fusion::tuple<U1,U2> const & from)
{
to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
@@ -48,7 +49,7 @@
};
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)
+ inline static boost::fusion::tuple<T1,T2,T3> apply(boost::fusion::tuple<T1,T2,T3>& to, boost::fusion::tuple<U1,U2,U3> const & from)
{
to = boost::convert_to<boost::fusion::tuple<T1,T2> >(from);
return to;
Added: sandbox/conversion/boost/conversion/ca_wrapper.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/ca_wrapper.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_CA_WRAPPER__HPP
+#define BOOST_CA_WRAPPER__HPP
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
+
+namespace boost {
+
+ template <typename T>
+ class ca_wrapper {
+ T& ref_;
+ public:
+ ca_wrapper(T& r) : ref_(r) {}
+ template <typename U>
+ operator U() {
+ return convert_to<U>(ref_);
+ }
+ template <typename U>
+ T& operator =(U const& u) {
+ return assign_to(ref_, u);
+ }
+ };
+
+ template <typename T>
+ ca_wrapper<T> mca(T& r) {
+ return ca_wrapper<T>(r);
+ }
+
+}
+
+#endif
+
Modified: sandbox/conversion/boost/conversion/convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -26,25 +26,6 @@
return To(val);
}
};
- template < typename To, typename From >
- struct assign_to {
- inline static To& apply(const From& from, To& to)
- {
- to = from;
- return to;
- }
- };
- template < typename To, typename From, std::size_t N >
- struct assign_to<To[N],From[N]> {
- inline static To*& apply(const From(& from)[N], To (&to)[N])
- {
- for (std::size_t i = 0; i < N; ++i)
- {
- to[i] = boost::convert_to(from[i]);
- }
- return to;
- }
- };
#if 0
template < typename To, typename From, std::size_t N >
struct convert_to<To[N],From[N]> {
@@ -66,12 +47,6 @@
return partial_specialization_workaround::convert_to<To,From>::apply(val);
}
- template < typename To, typename From >
- To& assign_to(const From& from, To& to) {
- return partial_specialization_workaround::assign_to<To,From>::apply(from, to);
- }
-
-
}
#endif
Added: sandbox/conversion/boost/conversion/convert_to_via.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/convert_to_via.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_VIA__HPP
+#define BOOST_CONVERT_TO_VIA__HPP
+
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ template < typename To, typename Via, typename From >
+ To convert_to_via(const From& val) {
+ convert_to<To>(convert_to<Via>(val));
+ }
+
+}
+
+#endif
+
Modified: sandbox/conversion/boost/conversion/std/complex.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/complex.hpp (original)
+++ sandbox/conversion/boost/conversion/std/complex.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -13,6 +13,7 @@
#include <complex>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
@@ -26,7 +27,7 @@
};
template < class T, class U>
struct assign_to< std::complex<T>, std::complex<U> > {
- inline static std::complex<T>& apply(const std::complex<U>& from, std::complex<T>& to)
+ 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());
Modified: sandbox/conversion/boost/conversion/std/pair.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/pair.hpp (original)
+++ sandbox/conversion/boost/conversion/std/pair.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -14,6 +14,7 @@
#include <utility>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
namespace boost {
namespace partial_specialization_workaround {
@@ -26,7 +27,7 @@
};
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)
+ 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);
Modified: sandbox/conversion/boost/conversion/std/string.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/string.hpp (original)
+++ sandbox/conversion/boost/conversion/std/string.hpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -13,6 +13,7 @@
#include <string>
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
#include <boost/convert/convert.hpp>
namespace boost {
@@ -28,7 +29,7 @@
}
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)
+ inline static std::basic_string<CharT,Traits,Alloc>& apply(std::basic_string<CharT,Traits,Alloc>& to, const T& from)
{
to = convert<std::basic_string<CharT,Traits,Alloc> >::from(from);
return to;
@@ -43,7 +44,7 @@
};
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)
+ inline static void apply(T& to, const std::basic_string<CharT,Traits,Alloc>& from)
{
to = convert<T>::from(from);
return to;
Modified: sandbox/conversion/libs/conversion/test/Jamfile.v2
==============================================================================
--- sandbox/conversion/libs/conversion/test/Jamfile.v2 (original)
+++ sandbox/conversion/libs/conversion/test/Jamfile.v2 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -54,6 +54,6 @@
test-suite "compile_fail_test" :
-# [ compile-fail ../example/IL_BancAccount.cpp : <define>BOOST_SYNCHRO_DO_NOT_COMPILE : IL_BancAccount_comp_fail ]
+# [ compile-fail ../example/IL_BancAccount.cpp : : <define>BOOST_SYNCHRO_DO_NOT_COMPILE : IL_BancAccount_comp_fail ]
;
Modified: sandbox/conversion/libs/conversion/test/array.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/array.cpp (original)
+++ sandbox/conversion/libs/conversion/test/array.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -28,7 +28,7 @@
}
template <>
- A1& assign_to<A1,B1>(const B1& from, A1& to) {
+ A1& assign_to<A1,B1>(A1& to, const B1& from) {
return to;
}
@@ -42,7 +42,7 @@
};
template < >
struct assign_to< A2,B2 > {
- inline static A2& apply(const B2& from, A2& to)
+ inline static A2& apply(A2& to, const B2& from)
{
return to;
}
@@ -60,7 +60,7 @@
void explicit_assign_to() {
boost::array<int,3> bs;
boost::array<short,3> as;
- assign_to(bs,as);
+ assign_to(as,bs);
}
Modified: sandbox/conversion/libs/conversion/test/builtins.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/builtins.cpp (original)
+++ sandbox/conversion/libs/conversion/test/builtins.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -9,6 +9,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/ca_wrapper.hpp>
#include <iostream>
#include <boost/test/unit_test.hpp>
@@ -76,7 +77,8 @@
unsigned int ui(i);
unsigned long ul(l);
- assign_to(c,c);
+ assign_to(c, 0);
+ assign_to(c, c);
assign_to(c, s);
assign_to(c, i);
assign_to(c, l);
@@ -85,7 +87,8 @@
assign_to(c, ui);
assign_to(c, ul);
- assign_to(s,c);
+ assign_to(s, 1);
+ assign_to(s, c);
assign_to(s, s);
assign_to(s, i);
assign_to(s, l);
@@ -94,7 +97,8 @@
assign_to(s, ui);
assign_to(s, ul);
- assign_to(i,c);
+ assign_to(i, 2);
+ assign_to(i, c);
assign_to(i, s);
assign_to(i, i);
assign_to(i, l);
@@ -103,7 +107,8 @@
assign_to(i, ui);
assign_to(i, ul);
- assign_to(l,c);
+ assign_to(l, 3);
+ assign_to(l, c);
assign_to(l, s);
assign_to(l, i);
assign_to(l, l);
@@ -111,8 +116,71 @@
assign_to(l, us);
assign_to(l, ui);
assign_to(l, ul);
+}
+
+void mca_assign_to_with_builtin_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);
+
+ mca(c) = c;
+ mca(c) = s;
+ mca(c) = i;
+ mca(c) = l;
+ mca(c) = uc;
+ mca(c) = us;
+ mca(c) = ui;
+ mca(c) = ul;
+
+ mca(s) = c;
+ mca(s) = s;
+ mca(s) = i;
+ mca(s) = l;
+ mca(s) = uc;
+ mca(s) = us;
+ mca(s) = ui;
+ mca(s) = ul;
+
+ mca(i) = c;
+ mca(i) = s;
+ mca(i) = i;
+ mca(i) = l;
+ mca(i) = uc;
+ mca(i) = us;
+ mca(i) = ui;
+ mca(i) = ul;
+
+ mca(l) = c;
+ mca(l) = s;
+ mca(l) = i;
+ mca(l) = l;
+ mca(l) = uc;
+ mca(l) = us;
+ mca(l) = ui;
+ mca(l) = ul;
+
+}
+
+void assign_to_transitive() {
+ int a=0; int b=0; int c=0;
+ //assign_to(a, assign_to(b, assign_to(c,1)));
+ assign_to(a, assign_to(b, c));
+
+}
+void mca_assign_to_transitive() {
+ {
+ int a=0; int b=0; int c=0;
+
+ mca(a) = mca(b) = mca(b) = 1;
+
+ }
}
test_suite* init_unit_test_suite(int, char*[])
@@ -120,6 +188,9 @@
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));
+ test->add(BOOST_TEST_CASE(&mca_assign_to_with_builtin_types));
+ test->add(BOOST_TEST_CASE(&assign_to_transitive));
+ test->add(BOOST_TEST_CASE(&mca_assign_to_transitive));
return test;
}
Modified: sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp (original)
+++ sandbox/conversion/libs/conversion/test/chrono_posix_time_duration.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -28,9 +28,9 @@
void explicit_assign_to() {
chrono::seconds a(3);
posix_time::time_duration b;
- assign_to(a, b);
+ assign_to(b, a);
chrono::seconds c;
- assign_to(b,c);
+ assign_to(c, b);
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp (original)
+++ sandbox/conversion/libs/conversion/test/chrono_posix_time_time.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -28,9 +28,9 @@
void explicit_assign_to() {
chrono::system_clock::time_point a=chrono::system_clock::now();
posix_time::ptime b;
- assign_to(a, b);
+ assign_to(b, a);
chrono::system_clock::time_point c;
- assign_to(b,c);
+ assign_to(c, b);
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/complex.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/complex.cpp (original)
+++ sandbox/conversion/libs/conversion/test/complex.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -28,7 +28,7 @@
}
template <>
- A1& assign_to<A1,B1>(const B1& from, A1& to) {
+ A1& assign_to<A1,B1>(A1& to, const B1& from) {
return to;
}
@@ -42,7 +42,7 @@
};
template < >
struct assign_to< A2,B2 > {
- inline static A2& apply(const B2& from, A2& to)
+ inline static A2& apply(A2& to, const B2& from)
{
return to;
}
@@ -64,8 +64,8 @@
B1 b2;
std::complex<A1> a;
std::complex<B1> b;
- assign_to(b,a);
- assign_to(std::complex<B1>(b1,b2),a);
+ assign_to(a,b);
+ assign_to(a,std::complex<B1>(b1,b2));
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/extrinsec.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/extrinsec.cpp (original)
+++ sandbox/conversion/libs/conversion/test/extrinsec.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -9,6 +9,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/ca_wrapper.hpp>
#include <iostream>
#include <boost/test/unit_test.hpp>
@@ -25,7 +26,7 @@
}
template <>
- A& assign_to<A,B>(const B& from, A& to) {
+ A& assign_to<A,B>(A& to, const B& from) {
return to;
}
@@ -38,7 +39,8 @@
void explicit_assign_to() {
B b;
A a;
- assign_to(b,a);
+ assign_to(a, b);
+ mca(a)= b;
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/interval.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/interval.cpp (original)
+++ sandbox/conversion/libs/conversion/test/interval.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -32,8 +32,8 @@
B1 b2;
boost::numeric::interval<A1> a;
boost::numeric::interval<B1> b;
- assign_to(b,a);
- assign_to(boost::numeric::interval<B1>(b1,b2),a);
+ assign_to(a,b);
+ assign_to(a,boost::numeric::interval<B1>(b1,b2));
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/intrinsec.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/intrinsec.cpp (original)
+++ sandbox/conversion/libs/conversion/test/intrinsec.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -9,6 +9,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/ca_wrapper.hpp>
#include <iostream>
#include <boost/test/unit_test.hpp>
@@ -79,10 +80,15 @@
{
A a(0);
AA aa(0);
- assign_to(a,aa);
+ assign_to(aa,a);
}
-
}
+void mca_with_assignemet_operator() {
+ A a(0);
+ AA aa(0);
+ mca(aa) =a;
+}
+
void assign_to_with_assignemet_operator_and_implicit_constructor() {
{
B b;
@@ -91,24 +97,36 @@
}
{
B b;
- AA a(1);
- assign_to(b,a);
+ AA aa(1);
+ assign_to(aa,b);
}
-
+}
+void mca_with_assignemet_operator_and_implicit_constructor() {
+ B b;
+ AA aa(1);
+ mca(aa)=b;
}
+
void assign_to_with_assignemet_operator_and_conversion_operator() {
{
C c;
- CC a(1);
- a=c;
+ CC cc(1);
+ cc=c;
}
{
C c;
CC cc(1);
- assign_to(c,cc);
+ assign_to(cc,c);
}
-
}
+
+void mca_with_assignemet_operator_and_conversion_operator() {
+ C c;
+ CC cc(1);
+ mca(cc)=c;
+}
+
+
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("intrinsec");
@@ -118,6 +136,11 @@
test->add(BOOST_TEST_CASE(&assign_to_with_assignemet_operator));
test->add(BOOST_TEST_CASE(&assign_to_with_assignemet_operator_and_implicit_constructor));
test->add(BOOST_TEST_CASE(&assign_to_with_assignemet_operator_and_conversion_operator));
+ test->add(BOOST_TEST_CASE(&mca_with_assignemet_operator));
+ test->add(BOOST_TEST_CASE(&mca_with_assignemet_operator_and_implicit_constructor));
+ test->add(BOOST_TEST_CASE(&mca_with_assignemet_operator_and_conversion_operator));
+
return test;
+
}
Modified: sandbox/conversion/libs/conversion/test/optional.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/optional.cpp (original)
+++ sandbox/conversion/libs/conversion/test/optional.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -33,7 +33,7 @@
boost::optional<A1> a;
boost::optional<B1> b;
//assign_to(b,a);
- assign_to(boost::optional<B1>(b1),a);
+ assign_to(a, boost::optional<B1>(b1));
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/pair.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/pair.cpp (original)
+++ sandbox/conversion/libs/conversion/test/pair.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -28,7 +28,7 @@
}
template <>
- A1& assign_to<A1,B1>(const B1& from, A1& to) {
+ A1& assign_to<A1,B1>(A1& to, const B1& from) {
return to;
}
@@ -42,7 +42,7 @@
};
template < >
struct assign_to< A2,B2 > {
- inline static A2& apply(const B2& from, A2& to)
+ inline static A2& apply(A2& to, const B2& from)
{
return to;
}
@@ -65,9 +65,9 @@
B2 b2;
std::pair<A1,A2> a;
std::pair<B1,B2> b;
- assign_to(b,a);
- assign_to(std::pair<B1,B2>(b1,b2),a);
- assign_to(std::make_pair(b1,b2),a);
+ assign_to(a,b);
+ assign_to(a, std::pair<B1,B2>(b1,b2));
+ assign_to(a, std::make_pair(b1,b2));
}
Modified: sandbox/conversion/libs/conversion/test/rational.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/rational.cpp (original)
+++ sandbox/conversion/libs/conversion/test/rational.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -32,8 +32,8 @@
B1 b2(2);
boost::rational<A1> a;
boost::rational<B1> b(1,2);
- assign_to(b,a);
- assign_to(boost::rational<B1>(b1,b2),a);
+ assign_to(a, b);
+ assign_to(a, boost::rational<B1>(b1,b2));
}
test_suite* init_unit_test_suite(int, char*[])
Modified: sandbox/conversion/libs/conversion/test/tuple.cpp
==============================================================================
--- sandbox/conversion/libs/conversion/test/tuple.cpp (original)
+++ sandbox/conversion/libs/conversion/test/tuple.cpp 2009-10-22 09:56:38 EDT (Thu, 22 Oct 2009)
@@ -28,7 +28,7 @@
}
template <>
- A1& assign_to<A1,B1>(const B1& from, A1& to) {
+ A1& assign_to<A1,B1>(A1& to, const B1& from) {
return to;
}
@@ -42,7 +42,7 @@
};
template < >
struct assign_to< A2,B2 > {
- inline static A2& apply(const B2& from, A2& to)
+ inline static A2& apply(A2& to, const B2& from)
{
return to;
}
@@ -65,9 +65,9 @@
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);
+ assign_to(a, b);
+ assign_to(a, boost::fusion::tuple<B1,B2>(b1,b2));
+ assign_to(a, boost::fusion::make_tuple(b1,b2));
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk