+2007-12-30 Paolo Carlini <pcarlini@suse.de>
+
+ * include/std/tuple (_Tuple_impl<>::_Tuple_impl(typename
+ std::remove_reference<>::type&&, typename
+ std::remove_reference<>::type&&...),
+ _Tuple_impl(const _Tuple_impl<>&), _Tuple_impl(_Tuple_impl&&),
+ _Tuple_impl(_Tuple_impl<>&&), operator=(_Tuple_impl&&),
+ operator=(const _Tuple_impl<>&), operator=(_Tuple_impl<>&&)): Add.
+ (tuple<>::tuple(const _Elements&...), tuple(_UElements&&...),
+ tuple(tuple&&), tuple(const tuple<>&), tuple(tuple<>&&),
+ operator=(tuple&&), operator=(const tuple<>&), operator=(tuple<>&&)):
+ Likewise.
+ (tuple<_T1, _T2>::tuple(const _T1&, const _T2&, tuple(_U1&&, _U2&&),
+ tuple(tuple&&), tuple(tuple<>&&), tuple(pair<>&&), operator=(tuple&&),
+ operator=(tuple<>&&), operator=(pair<>&&)): Likewise.
+ (tuple<>::tuple(typename __add_c_ref<_Elements>::type...),
+ tuple<_T1, _T2>::tuple(typename __add_c_ref<>::type,
+ typename __add_c_ref<>::type)): Remove.
+ * testsuite/tr1/6_containers/tuple/creation_functions/tie2.cc: New.
+ * testsuite/20_util/tuple/creation_functions/tie2.cc: Likewise.
+ * testsuite/20_util/tuple/moveable.cc: Likewise.
+
2007-12-29 Gerald Pfeifer <gerald@pfeifer.com>
* config/os/mingw32/error_constants.h: Fix typo in comment.
{ typedef _Tp& type; };
template<int _Idx, typename _Head, bool _IsEmpty>
- struct _Head_base;
-
+ struct _Head_base;
+
template<int _Idx, typename _Head>
struct _Head_base<_Idx, _Head, true>
: public _Head
typename __add_c_ref<_Tail>::type... __tail)
: _Inherited(__tail...), _Base(__head) { }
- template<typename... _UElements>
- _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
- : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
+ template<typename _UHead, typename... _UTail>
+ explicit
+ _Tuple_impl(typename std::remove_reference<_UHead>::type&& __head,
+ typename std::remove_reference<_UTail>::type&&... __tail)
+ : _Inherited(std::forward<_Inherited>(__tail)...),
+ _Base(std::forward<_Base>(__head)) { }
_Tuple_impl(const _Tuple_impl& __in)
: _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
+ _Tuple_impl(_Tuple_impl&& __in)
+ : _Inherited(std::forward<_Inherited>(__in._M_tail())),
+ _Base(std::forward<_Base>(__in._M_head())) { }
+
template<typename... _UElements>
- _Tuple_impl&
- operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
- {
- _M_head() = __in._M_head();
- _M_tail() = __in._M_tail();
- return *this;
- }
+ _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
+ : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
+
+ template<typename... _UElements>
+ _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in)
+ : _Inherited(std::forward<_Inherited>(__in._M_tail())),
+ _Base(std::forward<_Base>(__in._M_head())) { }
_Tuple_impl&
operator=(const _Tuple_impl& __in)
_M_tail() = __in._M_tail();
return *this;
}
+
+ _Tuple_impl&
+ operator=(_Tuple_impl&& __in)
+ {
+ _M_head() = std::move(__in._M_head());
+ _M_tail() = std::move(__in._M_tail());
+ return *this;
+ }
+
+ template<typename... _UElements>
+ _Tuple_impl&
+ operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
+ {
+ _M_head() = __in._M_head();
+ _M_tail() = __in._M_tail();
+ return *this;
+ }
+
+ template<typename... _UElements>
+ _Tuple_impl&
+ operator=(_Tuple_impl<_Idx, _UElements...>&& __in)
+ {
+ _M_head() = std::move(__in._M_head());
+ _M_tail() = std::move(__in._M_tail());
+ return *this;
+ }
};
template<typename... _Elements>
: _Inherited() { }
explicit
- tuple(typename __add_c_ref<_Elements>::type... __elements)
+ tuple(const _Elements&... __elements)
: _Inherited(__elements...) { }
template<typename... _UElements>
- tuple(const tuple<_UElements...>& __in)
- : _Inherited(__in) { }
+ explicit
+ tuple(_UElements&&... __elements)
+ : _Inherited(std::forward<_UElements>(__elements)...) { }
tuple(const tuple& __in)
: _Inherited(__in) { }
+ tuple(tuple&& __in)
+ : _Inherited(std::move(__in)) { }
+
template<typename... _UElements>
- tuple&
- operator=(const tuple<_UElements...>& __in)
- {
- static_cast<_Inherited&>(*this) = __in;
- return *this;
- }
+ tuple(const tuple<_UElements...>& __in)
+ : _Inherited(__in) { }
+
+ template<typename... _UElements>
+ tuple(tuple<_UElements...>&& __in)
+ : _Inherited(std::move(__in)) { }
tuple&
operator=(const tuple& __in)
static_cast<_Inherited&>(*this) = __in;
return *this;
}
+
+ tuple&
+ operator=(tuple&& __in)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
+ template<typename... _UElements>
+ tuple&
+ operator=(const tuple<_UElements...>& __in)
+ {
+ static_cast<_Inherited&>(*this) = __in;
+ return *this;
+ }
+
+ template<typename... _UElements>
+ tuple&
+ operator=(tuple<_UElements...>&& __in)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
};
template<> class tuple<> { };
: _Inherited() { }
explicit
- tuple(typename __add_c_ref<_T1>::type __a1,
- typename __add_c_ref<_T2>::type __a2)
+ tuple(const _T1& __a1, const _T2& __a2)
: _Inherited(__a1, __a2) { }
template<typename _U1, typename _U2>
- tuple(const tuple<_U1, _U2>& __in)
- : _Inherited(__in) { }
+ explicit
+ tuple(_U1&& __a1, _U2&& __a2)
+ : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
tuple(const tuple& __in)
: _Inherited(__in) { }
+ tuple(tuple&& __in)
+ : _Inherited(std::move(__in)) { }
+
+ template<typename _U1, typename _U2>
+ tuple(const tuple<_U1, _U2>& __in)
+ : _Inherited(__in) { }
+
+ template<typename _U1, typename _U2>
+ tuple(tuple<_U1, _U2>&& __in)
+ : _Inherited(std::move(__in)) { }
+
template<typename _U1, typename _U2>
tuple(const pair<_U1, _U2>& __in)
: _Inherited(_Tuple_impl<0,
typename __add_c_ref<_U2>::type>(__in.first,
__in.second))
{ }
-
+
template<typename _U1, typename _U2>
- tuple&
- operator=(const tuple<_U1, _U2>& __in)
- {
- static_cast<_Inherited&>(*this) = __in;
- return *this;
- }
+ tuple(pair<_U1, _U2>&& __in)
+ : _Inherited(_Tuple_impl<0,
+ typename std::remove_reference<_U1>::type&&,
+ typename std::remove_reference<_U2>::type&&>
+ (std::move(__in.first), std::move(__in.second)))
+ { }
tuple&
operator=(const tuple& __in)
return *this;
}
+ tuple&
+ operator=(tuple&& __in)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(const tuple<_U1, _U2>& __in)
+ {
+ static_cast<_Inherited&>(*this) = __in;
+ return *this;
+ }
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(tuple<_U1, _U2>&& __in)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
template<typename _U1, typename _U2>
tuple&
operator=(const pair<_U1, _U2>& __in)
this->_M_tail()._M_head() = __in.second;
return *this;
}
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(pair<_U1, _U2>&& __in)
+ {
+ this->_M_head() = std::move(__in.first);
+ this->_M_tail()._M_head() = std::move(__in.second);
+ return *this;
+ }
};
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on tuple. If the implementation changed
+// this test may begin to fail.
+
+#include <tuple>
+#include <utility>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tuple<int, double> a(1, 2.0), b;
+ b = std::move(a);
+ VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 );
+ VERIFY( std::get<0>(a) == 1 && std::get<1>(a) == 2.0 );
+
+ std::tuple<int, double> c(std::move(b));
+ VERIFY( std::get<0>(c) == 1 && std::get<1>(c) == 2.0 );
+ VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 );
+ return 0;
+}