Commit 62b547b5 by Jonathan Wakely Committed by Paolo Carlini

re PR libstdc++/51183 (pair piecewise_construct_t constructor copies)

2011-12-06  Jonathan Wakely  <jwakely.gcc@gmail.com>
	    Chris Jefferson  <chris@bubblescope.net>

	PR libstdc++/51183
	* include/std/stl_pair.h (pair<>::__cons, pair<>::__do_cons): Remove.
	(pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Only declare.
	(pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)):
	Declare.
	* include/std/tuple (pair<>::__cons, pair<>::__do_cons): Remove.
	(pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)):
	Define.
	(pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Define,
	delegating to the latter.
	* testsuite/20_util/pair/piecewise2.cc: New.

Co-Authored-By: Chris Jefferson <chris@bubblescope.net>

From-SVN: r182054
parent 6232acfe
2011-12-06 Jonathan Wakely <jwakely.gcc@gmail.com>
Chris Jefferson <chris@bubblescope.net>
PR libstdc++/51183
* include/std/stl_pair.h (pair<>::__cons, pair<>::__do_cons): Remove.
(pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Only declare.
(pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)):
Declare.
* include/std/tuple (pair<>::__cons, pair<>::__do_cons): Remove.
(pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)):
Define.
(pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Define,
delegating to the latter.
* testsuite/20_util/pair/piecewise2.cc: New.
2011-12-05 Paolo Carlini <paolo.carlini@oracle.com> 2011-12-05 Paolo Carlini <paolo.carlini@oracle.com>
* libsupc++/initializer_list: Do not declare anything if * libsupc++/initializer_list: Do not declare anything if
......
...@@ -149,11 +149,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -149,11 +149,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: first(std::forward<_U1>(__p.first)), : first(std::forward<_U1>(__p.first)),
second(std::forward<_U2>(__p.second)) { } second(std::forward<_U2>(__p.second)) { }
template<class... _Args1, class... _Args2> template<typename... _Args1, typename... _Args2>
pair(piecewise_construct_t, pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
tuple<_Args1...> __first, tuple<_Args2...> __second)
: first(__cons<first_type>(std::move(__first))),
second(__cons<second_type>(std::move(__second))) { }
pair& pair&
operator=(const pair& __p) operator=(const pair& __p)
...@@ -202,13 +199,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -202,13 +199,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
private: private:
template<typename _Tp, typename... _Args> template<typename... _Args1, std::size_t... _Indexes1,
static _Tp typename... _Args2, std::size_t... _Indexes2>
__cons(tuple<_Args...>&&); pair(tuple<_Args1...>&, tuple<_Args2...>&,
_Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
template<typename _Tp, typename... _Args, std::size_t... _Indexes>
static _Tp
__do_cons(tuple<_Args...>&&, const _Index_tuple<_Indexes...>&);
#endif #endif
}; };
......
...@@ -1057,21 +1057,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1057,21 +1057,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// See stl_pair.h... // See stl_pair.h...
template<class _T1, class _T2> template<class _T1, class _T2>
template<typename _Tp, typename... _Args> template<typename... _Args1, typename... _Args2>
inline _Tp inline
pair<_T1, _T2>::__cons(tuple<_Args...>&& __tuple) pair<_T1, _T2>::
{ pair(piecewise_construct_t,
typedef typename _Build_index_tuple<sizeof...(_Args)>::__type tuple<_Args1...> __first, tuple<_Args2...> __second)
_Indexes; : pair(__first, __second,
return __do_cons<_Tp>(std::move(__tuple), _Indexes()); typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
} typename _Build_index_tuple<sizeof...(_Args2)>::__type())
{ }
template<class _T1, class _T2> template<class _T1, class _T2>
template<typename _Tp, typename... _Args, std::size_t... _Indexes> template<typename... _Args1, std::size_t... _Indexes1,
inline _Tp typename... _Args2, std::size_t... _Indexes2>
pair<_T1, _T2>::__do_cons(tuple<_Args...>&& __tuple, inline
const _Index_tuple<_Indexes...>&) pair<_T1, _T2>::
{ return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); } pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2,
_Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
: first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
{ }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
......
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2011 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <utility>
#include <tuple>
struct NoCon
{
NoCon() = delete;
NoCon(const NoCon&) = delete;
};
struct RefCheck1
{
RefCheck1(NoCon&, NoCon&&) { }
RefCheck1() = delete;
RefCheck1(const RefCheck1&) = delete;
};
struct RefCheck2
{
RefCheck2(const NoCon&, const NoCon&&, NoCon&) { }
RefCheck2() = delete;
RefCheck2(const RefCheck2&) = delete;
};
struct Default
{
Default();
Default(const Default&) = delete;
};
// libstdc++/51183
void test01(std::tuple<NoCon&, NoCon&&> t1,
std::tuple<NoCon&, NoCon&&, NoCon&> t2)
{
std::pair<RefCheck1, RefCheck2>(std::piecewise_construct, t1, t2);
}
void test02(std::tuple<> t1, std::tuple<int> t2)
{
std::pair<Default, int> A(std::piecewise_construct, t1, t2);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment