|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67590 - in branches/release: . boost boost/bimap boost/gil boost/graph boost/icl boost/interprocess boost/intrusive boost/msm boost/numeric/ublas boost/property_tree boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/system boost/tuple boost/tuple/detail boost/typeof boost/unordered boost/uuid boost/variant boost/wave libs libs/array/test libs/bimap libs/graph_parallel libs/icl libs/icl/doc libs/interprocess libs/intrusive libs/math/doc/sf_and_dist libs/mpi/build libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/property_tree libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/static_assert libs/system libs/timer libs/tuple/test libs/unordered libs/utility libs/utility/swap/test libs/uuid libs/wave more status tools tools/bcp tools/regression tools/regression/src tools/release tools/wave
From: steven_at_[hidden]
Date: 2011-01-02 15:25:13
Author: steven_watanabe
Date: 2011-01-02 15:25:11 EST (Sun, 02 Jan 2011)
New Revision: 67590
URL: http://svn.boost.org/trac/boost/changeset/67590
Log:
Merge Tuple from the trunk
Properties modified:
branches/release/ (props changed)
branches/release/INSTALL (props changed)
branches/release/Jamroot (props changed)
branches/release/LICENSE_1_0.txt (props changed)
branches/release/boost/ (props changed)
branches/release/boost-build.jam (props changed)
branches/release/boost.css (props changed)
branches/release/boost.png (props changed)
branches/release/boost/bimap/ (props changed)
branches/release/boost/config.hpp (props changed)
branches/release/boost/gil/ (props changed)
branches/release/boost/graph/ (props changed)
branches/release/boost/icl/ (props changed)
branches/release/boost/interprocess/ (props changed)
branches/release/boost/intrusive/ (props changed)
branches/release/boost/msm/ (props changed)
branches/release/boost/numeric/ublas/ (props changed)
branches/release/boost/property_tree/ (props changed)
branches/release/boost/signals/ (props changed)
branches/release/boost/signals2/ (props changed)
branches/release/boost/signals2.hpp (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (props changed)
branches/release/boost/system/ (props changed)
branches/release/boost/token_functions.hpp (props changed)
branches/release/boost/typeof/register_functions.hpp (props changed)
branches/release/boost/typeof/register_functions_iterate.hpp (props changed)
branches/release/boost/typeof/typeof.hpp (props changed)
branches/release/boost/typeof/unsupported.hpp (props changed)
branches/release/boost/unordered/ (props changed)
branches/release/boost/uuid/ (props changed)
branches/release/boost/variant/ (props changed)
branches/release/boost/wave/ (props changed)
branches/release/bootstrap.bat (props changed)
branches/release/bootstrap.sh (props changed)
branches/release/index.htm (props changed)
branches/release/index.html (props changed)
branches/release/libs/ (props changed)
branches/release/libs/array/test/Jamfile.v2 (props changed)
branches/release/libs/array/test/array0.cpp (props changed)
branches/release/libs/array/test/array2.cpp (props changed)
branches/release/libs/array/test/array6.cpp (props changed)
branches/release/libs/bimap/ (props changed)
branches/release/libs/graph_parallel/ (props changed)
branches/release/libs/icl/ (props changed)
branches/release/libs/icl/doc/ (props changed)
branches/release/libs/interprocess/ (props changed)
branches/release/libs/intrusive/ (props changed)
branches/release/libs/math/doc/sf_and_dist/ (props changed)
branches/release/libs/mpi/build/ (props changed)
branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
branches/release/libs/msm/ (props changed)
branches/release/libs/numeric/ublas/ (props changed)
branches/release/libs/numeric/ublas/doc/ (props changed)
branches/release/libs/property_tree/ (props changed)
branches/release/libs/signals/ (props changed)
branches/release/libs/signals2/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/classic/example/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/example/ (props changed)
branches/release/libs/spirit/phoenix/ (props changed)
branches/release/libs/spirit/test/ (props changed)
branches/release/libs/spirit/test/qi/optional.cpp (props changed)
branches/release/libs/static_assert/ (props changed)
branches/release/libs/system/ (props changed)
branches/release/libs/timer/ (props changed)
branches/release/libs/unordered/ (props changed)
branches/release/libs/utility/swap.html (props changed)
branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
branches/release/libs/utility/value_init_test.cpp (props changed)
branches/release/libs/uuid/ (props changed)
branches/release/libs/wave/ (props changed)
branches/release/more/ (props changed)
branches/release/rst.css (props changed)
branches/release/status/ (props changed)
branches/release/status/explicit-failures-markup.xml (props changed)
branches/release/tools/ (props changed)
branches/release/tools/bcp/ (props changed)
branches/release/tools/regression/ (props changed)
branches/release/tools/regression/src/library_status.cpp (props changed)
branches/release/tools/release/ (props changed)
branches/release/tools/wave/ (props changed)
Text files modified:
branches/release/boost/tuple/detail/tuple_basic.hpp | 321 +++++++++++++++++++++------------------
branches/release/boost/tuple/detail/tuple_basic_no_partial_spec.hpp | 24 ++
branches/release/boost/tuple/tuple_io.hpp | 4
branches/release/libs/tuple/test/io_test.cpp | 7
branches/release/libs/tuple/test/tuple_test_bench.cpp | 21 ++
5 files changed, 230 insertions(+), 147 deletions(-)
Modified: branches/release/boost/tuple/detail/tuple_basic.hpp
==============================================================================
--- branches/release/boost/tuple/detail/tuple_basic.hpp (original)
+++ branches/release/boost/tuple/detail/tuple_basic.hpp 2011-01-02 15:25:11 EST (Sun, 02 Jan 2011)
@@ -37,6 +37,7 @@
#include "boost/type_traits/cv_traits.hpp"
#include "boost/type_traits/function_traits.hpp"
+#include "boost/utility/swap.hpp"
#include "boost/detail/workaround.hpp" // needed for BOOST_WORKAROUND
@@ -86,45 +87,28 @@
template<class T>
class generate_error;
-// - cons getters --------------------------------------------------------
-// called: get_class<N>::get<RETURN_TYPE>(aTuple)
-
-template< int N >
-struct get_class {
- template<class RET, class HT, class TT >
- inline static RET get(const cons<HT, TT>& t)
- {
-#if BOOST_WORKAROUND(__IBMCPP__,==600)
- // vacpp 6.0 is not very consistent regarding the member template keyword
- // Here it generates an error when the template keyword is used.
- return get_class<N-1>::get<RET>(t.tail);
-#else
- return get_class<N-1>::BOOST_NESTED_TEMPLATE get<RET>(t.tail);
-#endif
- }
- template<class RET, class HT, class TT >
- inline static RET get(cons<HT, TT>& t)
- {
-#if BOOST_WORKAROUND(__IBMCPP__,==600)
- return get_class<N-1>::get<RET>(t.tail);
-#else
- return get_class<N-1>::BOOST_NESTED_TEMPLATE get<RET>(t.tail);
-#endif
- }
+template<int N>
+struct drop_front {
+ template<class Tuple>
+ struct apply {
+ typedef BOOST_DEDUCED_TYPENAME drop_front<N-1>::BOOST_NESTED_TEMPLATE
+ apply<Tuple> next;
+ typedef BOOST_DEDUCED_TYPENAME next::type::tail_type type;
+ static const type& call(const Tuple& tup) {
+ return next::call(tup).tail;
+ }
+ };
};
template<>
-struct get_class<0> {
- template<class RET, class HT, class TT>
- inline static RET get(const cons<HT, TT>& t)
- {
- return t.head;
- }
- template<class RET, class HT, class TT>
- inline static RET get(cons<HT, TT>& t)
- {
- return t.head;
- }
+struct drop_front<0> {
+ template<class Tuple>
+ struct apply {
+ typedef Tuple type;
+ static const type& call(const Tuple& tup) {
+ return tup;
+ }
+ };
};
} // end of namespace detail
@@ -140,41 +124,23 @@
template<int N, class T>
struct element
{
-private:
- typedef typename T::tail_type Next;
-public:
- typedef typename element<N-1, Next>::type type;
-};
-template<class T>
-struct element<0,T>
-{
- typedef typename T::head_type type;
+ typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
+ apply<T>::type::head_type type;
};
template<int N, class T>
struct element<N, const T>
{
private:
- typedef typename T::tail_type Next;
- typedef typename element<N-1, Next>::type unqualified_type;
+ typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
+ apply<T>::type::head_type unqualified_type;
public:
#if BOOST_WORKAROUND(__BORLANDC__,<0x600)
typedef const unqualified_type type;
#else
- typedef typename boost::add_const<unqualified_type>::type type;
-#endif
-
-};
-template<class T>
-struct element<0,const T>
-{
-#if BOOST_WORKAROUND(__BORLANDC__,<0x600)
- typedef const typename T::head_type type;
-#else
- typedef typename boost::add_const<typename T::head_type>::type type;
+ typedef BOOST_DEDUCED_TYPENAME boost::add_const<unqualified_type>::type type;
#endif
};
-
#else // def BOOST_NO_CV_SPECIALIZATIONS
namespace detail {
@@ -182,31 +148,16 @@
template<int N, class T, bool IsConst>
struct element_impl
{
-private:
- typedef typename T::tail_type Next;
-public:
- typedef typename element_impl<N-1, Next, IsConst>::type type;
+ typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
+ apply<T>::type::head_type type;
};
template<int N, class T>
struct element_impl<N, T, true /* IsConst */>
{
-private:
- typedef typename T::tail_type Next;
-public:
- typedef const typename element_impl<N-1, Next, true>::type type;
-};
-
-template<class T>
-struct element_impl<0, T, false /* IsConst */>
-{
- typedef typename T::head_type type;
-};
-
-template<class T>
-struct element_impl<0, T, true /* IsConst */>
-{
- typedef const typename T::head_type type;
+ typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
+ apply<T>::type::head_type unqualified_type;
+ typedef const unqualified_type type;
};
} // end of namespace detail
@@ -258,17 +209,10 @@
typename element<N, cons<HT, TT> >::type
>::non_const_type
get(cons<HT, TT>& c BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int, N)) {
-#if BOOST_WORKAROUND(__IBMCPP__,==600 )
- return detail::get_class<N>::
-#else
- return detail::get_class<N>::BOOST_NESTED_TEMPLATE
-#endif
- get<
- typename access_traits<
- typename element<N, cons<HT, TT> >::type
- >::non_const_type,
- HT,TT
- >(c);
+ typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
+ apply<cons<HT, TT> > impl;
+ typedef BOOST_DEDUCED_TYPENAME impl::type cons_element;
+ return const_cast<cons_element&>(impl::call(c)).head;
}
// get function for const cons-lists, returns a const reference to
@@ -279,17 +223,10 @@
typename element<N, cons<HT, TT> >::type
>::const_type
get(const cons<HT, TT>& c BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int, N)) {
-#if BOOST_WORKAROUND(__IBMCPP__,==600)
- return detail::get_class<N>::
-#else
- return detail::get_class<N>::BOOST_NESTED_TEMPLATE
-#endif
- get<
- typename access_traits<
- typename element<N, cons<HT, TT> >::type
- >::const_type,
- HT,TT
- >(c);
+ typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
+ apply<cons<HT, TT> > impl;
+ typedef BOOST_DEDUCED_TYPENAME impl::type cons_element;
+ return impl::call(c).head;
}
// -- the cons template --------------------------------------------------
@@ -663,18 +600,21 @@
// Swallows any assignment (by Doug Gregor)
namespace detail {
+struct swallow_assign;
+typedef void (detail::swallow_assign::*ignore_t)();
struct swallow_assign {
-
+ swallow_assign(ignore_t(*)(ignore_t)) {}
template<typename T>
swallow_assign const& operator=(const T&) const {
return *this;
}
};
+
} // namespace detail
// "ignore" allows tuple positions to be ignored when using "tie".
-detail::swallow_assign const ignore = detail::swallow_assign();
+inline detail::ignore_t ignore(detail::ignore_t) { return 0; }
// ---------------------------------------------------------------------------
// The call_traits for make_tuple
@@ -756,6 +696,10 @@
typedef T& type;
};
+template<>
+struct make_tuple_traits<detail::ignore_t(detail::ignore_t)> {
+ typedef detail::swallow_assign type;
+};
@@ -877,71 +821,154 @@
return t(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9);
}
+namespace detail {
+template<class T>
+struct tie_traits {
+ typedef T& type;
+};
+
+template<>
+struct tie_traits<ignore_t(ignore_t)> {
+ typedef swallow_assign type;
+};
+
+template<>
+struct tie_traits<void> {
+ typedef null_type type;
+};
+
+template <
+ class T0 = void, class T1 = void, class T2 = void,
+ class T3 = void, class T4 = void, class T5 = void,
+ class T6 = void, class T7 = void, class T8 = void,
+ class T9 = void
+>
+struct tie_mapper {
+ typedef
+ tuple<typename tie_traits<T0>::type,
+ typename tie_traits<T1>::type,
+ typename tie_traits<T2>::type,
+ typename tie_traits<T3>::type,
+ typename tie_traits<T4>::type,
+ typename tie_traits<T5>::type,
+ typename tie_traits<T6>::type,
+ typename tie_traits<T7>::type,
+ typename tie_traits<T8>::type,
+ typename tie_traits<T9>::type> type;
+};
+
+}
// Tie function templates -------------------------------------------------
-template<class T1>
-inline tuple<T1&> tie(T1& t1) {
- return tuple<T1&> (t1);
+template<class T0>
+inline typename detail::tie_mapper<T0>::type
+tie(T0& t0) {
+ typedef typename detail::tie_mapper<T0>::type t;
+ return t(t0);
}
-template<class T1, class T2>
-inline tuple<T1&, T2&> tie(T1& t1, T2& t2) {
- return tuple<T1&, T2&> (t1, t2);
+template<class T0, class T1>
+inline typename detail::tie_mapper<T0, T1>::type
+tie(T0& t0, T1& t1) {
+ typedef typename detail::tie_mapper<T0, T1>::type t;
+ return t(t0, t1);
}
-template<class T1, class T2, class T3>
-inline tuple<T1&, T2&, T3&> tie(T1& t1, T2& t2, T3& t3) {
- return tuple<T1&, T2&, T3&> (t1, t2, t3);
+template<class T0, class T1, class T2>
+inline typename detail::tie_mapper<T0, T1, T2>::type
+tie(T0& t0, T1& t1, T2& t2) {
+ typedef typename detail::tie_mapper<T0, T1, T2>::type t;
+ return t(t0, t1, t2);
}
-template<class T1, class T2, class T3, class T4>
-inline tuple<T1&, T2&, T3&, T4&> tie(T1& t1, T2& t2, T3& t3, T4& t4) {
- return tuple<T1&, T2&, T3&, T4&> (t1, t2, t3, t4);
+template<class T0, class T1, class T2, class T3>
+inline typename detail::tie_mapper<T0, T1, T2, T3>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3) {
+ typedef typename detail::tie_mapper<T0, T1, T2, T3>::type t;
+ return t(t0, t1, t2, t3);
}
-template<class T1, class T2, class T3, class T4, class T5>
-inline tuple<T1&, T2&, T3&, T4&, T5&>
-tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) {
- return tuple<T1&, T2&, T3&, T4&, T5&> (t1, t2, t3, t4, t5);
+template<class T0, class T1, class T2, class T3, class T4>
+inline typename detail::tie_mapper<T0, T1, T2, T3, T4>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3,
+ T4& t4) {
+ typedef typename detail::tie_mapper<T0, T1, T2, T3, T4>::type t;
+ return t(t0, t1, t2, t3, t4);
}
-template<class T1, class T2, class T3, class T4, class T5, class T6>
-inline tuple<T1&, T2&, T3&, T4&, T5&, T6&>
-tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6) {
- return tuple<T1&, T2&, T3&, T4&, T5&, T6&> (t1, t2, t3, t4, t5, t6);
+template<class T0, class T1, class T2, class T3, class T4, class T5>
+inline typename detail::tie_mapper<T0, T1, T2, T3, T4, T5>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3,
+ T4& t4, T5& t5) {
+ typedef typename detail::tie_mapper<T0, T1, T2, T3, T4, T5>::type t;
+ return t(t0, t1, t2, t3, t4, t5);
}
-template<class T1, class T2, class T3, class T4, class T5, class T6, class T7>
-inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&>
-tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7) {
- return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&> (t1, t2, t3, t4, t5, t6, t7);
+template<class T0, class T1, class T2, class T3, class T4, class T5, class T6>
+inline typename detail::tie_mapper<T0, T1, T2, T3, T4, T5, T6>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3,
+ T4& t4, T5& t5, T6& t6) {
+ typedef typename detail::tie_mapper
+ <T0, T1, T2, T3, T4, T5, T6>::type t;
+ return t(t0, t1, t2, t3, t4, t5, t6);
+}
+
+template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
+ class T7>
+inline typename detail::tie_mapper<T0, T1, T2, T3, T4, T5, T6, T7>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3,
+ T4& t4, T5& t5, T6& t6, T7& t7) {
+ typedef typename detail::tie_mapper
+ <T0, T1, T2, T3, T4, T5, T6, T7>::type t;
+ return t(t0, t1, t2, t3, t4, t5, t6, t7);
}
-template<class T1, class T2, class T3, class T4, class T5, class T6, class T7,
- class T8>
-inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&>
-tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8) {
- return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&>
- (t1, t2, t3, t4, t5, t6, t7, t8);
+template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
+ class T7, class T8>
+inline typename detail::tie_mapper
+ <T0, T1, T2, T3, T4, T5, T6, T7, T8>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3,
+ T4& t4, T5& t5, T6& t6, T7& t7,
+ T8& t8) {
+ typedef typename detail::tie_mapper
+ <T0, T1, T2, T3, T4, T5, T6, T7, T8>::type t;
+ return t(t0, t1, t2, t3, t4, t5, t6, t7, t8);
}
-template<class T1, class T2, class T3, class T4, class T5, class T6, class T7,
- class T8, class T9>
-inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&>
-tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8,
- T9& t9) {
- return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&>
- (t1, t2, t3, t4, t5, t6, t7, t8, t9);
+template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
+ class T7, class T8, class T9>
+inline typename detail::tie_mapper
+ <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
+tie(T0& t0, T1& t1, T2& t2, T3& t3,
+ T4& t4, T5& t5, T6& t6, T7& t7,
+ T8& t8, T9& t9) {
+ typedef typename detail::tie_mapper
+ <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type t;
+ return t(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9);
}
-template<class T1, class T2, class T3, class T4, class T5, class T6, class T7,
- class T8, class T9, class T10>
-inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&, T10&>
-tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8,
- T9& t9, T10& t10) {
- return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&, T10&>
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
+template <class T0, class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8, class T9>
+void swap(tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& lhs,
+ tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& rhs);
+inline void swap(null_type&, null_type&) {}
+template<class HH>
+inline void swap(cons<HH, null_type>& lhs, cons<HH, null_type>& rhs) {
+ ::boost::swap(lhs.head, rhs.head);
+}
+template<class HH, class TT>
+inline void swap(cons<HH, TT>& lhs, cons<HH, TT>& rhs) {
+ ::boost::swap(lhs.head, rhs.head);
+ ::boost::tuples::swap(lhs.tail, rhs.tail);
+}
+template <class T0, class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8, class T9>
+inline void swap(tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& lhs,
+ tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& rhs) {
+ typedef tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> tuple_type;
+ typedef typename tuple_type::inherited base;
+ ::boost::tuples::swap(static_cast<base&>(lhs), static_cast<base&>(rhs));
}
} // end of namespace tuples
Modified: branches/release/boost/tuple/detail/tuple_basic_no_partial_spec.hpp
==============================================================================
--- branches/release/boost/tuple/detail/tuple_basic_no_partial_spec.hpp (original)
+++ branches/release/boost/tuple/detail/tuple_basic_no_partial_spec.hpp 2011-01-02 15:25:11 EST (Sun, 02 Jan 2011)
@@ -27,6 +27,7 @@
#define BOOST_TUPLE_BASIC_NO_PARTIAL_SPEC_HPP
#include "boost/type_traits.hpp"
+#include "boost/utility/swap.hpp"
#include <utility>
#if defined BOOST_MSVC
@@ -836,6 +837,29 @@
detail::swallow_assign const ignore = detail::swallow_assign();
+template <class T0, class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8, class T9>
+void swap(tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& lhs,
+ tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& rhs);
+inline void swap(null_type&, null_type&) {}
+template<class HH>
+inline void swap(cons<HH, null_type>& lhs, cons<HH, null_type>& rhs) {
+ ::boost::swap(lhs.head, rhs.head);
+}
+template<class HH, class TT>
+inline void swap(cons<HH, TT>& lhs, cons<HH, TT>& rhs) {
+ ::boost::swap(lhs.head, rhs.head);
+ ::boost::tuples::swap(lhs.tail, rhs.tail);
+}
+template <class T0, class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8, class T9>
+inline void swap(tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& lhs,
+ tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>& rhs) {
+ typedef tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> tuple_type;
+ typedef typename tuple_type::inherited base;
+ ::boost::tuples::swap(static_cast<base&>(lhs), static_cast<base&>(rhs));
+}
+
} // namespace tuples
} // namespace boost
#endif // BOOST_TUPLE_BASIC_NO_PARTIAL_SPEC_HPP
Modified: branches/release/boost/tuple/tuple_io.hpp
==============================================================================
--- branches/release/boost/tuple/tuple_io.hpp (original)
+++ branches/release/boost/tuple/tuple_io.hpp 2011-01-02 15:25:11 EST (Sun, 02 Jan 2011)
@@ -384,6 +384,8 @@
if (is.good() && c!=d) {
is.setstate(std::ios::failbit);
}
+ } else {
+ is >> std::ws;
}
return is;
}
@@ -478,6 +480,8 @@
if (is.good() && c!=d) {
is.setstate(std::ios::failbit);
}
+ } else {
+ is >> std::ws;
}
return is;
}
Modified: branches/release/libs/tuple/test/io_test.cpp
==============================================================================
--- branches/release/libs/tuple/test/io_test.cpp (original)
+++ branches/release/libs/tuple/test/io_test.cpp 2011-01-02 15:25:11 EST (Sun, 02 Jan 2011)
@@ -120,6 +120,13 @@
is3 >> set_close(']');
BOOST_CHECK(bool(is3 >> ti2));
+ // Make sure that whitespace between elements
+ // is skipped.
+ useThisIStringStream is4("(100 200 300)");
+
+ BOOST_CHECK(bool(is4 >> std::noskipws >> ti1));
+ BOOST_CHECK(ti1 == make_tuple(100, 200, 300));
+
// Note that strings are problematic:
// writing a tuple on a stream and reading it back doesn't work in
// general. If this is wanted, some kind of a parseable string class
Modified: branches/release/libs/tuple/test/tuple_test_bench.cpp
==============================================================================
--- branches/release/libs/tuple/test/tuple_test_bench.cpp (original)
+++ branches/release/libs/tuple/test/tuple_test_bench.cpp 2011-01-02 15:25:11 EST (Sun, 02 Jan 2011)
@@ -445,6 +445,26 @@
}
+// ----------------------------------------------------------------------------
+// - testing swap -----------------------------------------------------------
+// ----------------------------------------------------------------------------
+void tuple_swap_test()
+{
+ tuple<int, float, double> t1(1, 2.0f, 3.0), t2(4, 5.0f, 6.0);
+ swap(t1, t2);
+ BOOST_CHECK(get<0>(t1) == 4);
+ BOOST_CHECK(get<1>(t1) == 5.0f);
+ BOOST_CHECK(get<2>(t1) == 6.0);
+ BOOST_CHECK(get<0>(t2) == 1);
+ BOOST_CHECK(get<1>(t2) == 2.0f);
+ BOOST_CHECK(get<2>(t2) == 3.0);
+
+ int i = 1,j = 2;
+ boost::tuple<int&> t3(i), t4(j);
+ swap(t3, t4);
+ BOOST_CHECK(i == 2);
+ BOOST_CHECK(j == 1);
+}
@@ -465,6 +485,7 @@
cons_test();
const_tuple_test();
tuple_length_test();
+ tuple_swap_test();
return 0;
}
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