mirror of git://gcc.gnu.org/git/gcc.git
Avoid endless run-time recursion for copying single-element tuples where the...
Avoid endless run-time recursion for copying single-element tuples where the element type is by-value constructible from any type. * include/std/tuple (_NotSameTuple): New. * include/std/tuple (tuple(_UElements&&...): Use it. * testsuite/20_util/tuple/cons/element_accepts_anything_byval.cc: New. From-SVN: r236025
This commit is contained in:
parent
fc48633e86
commit
fb334765e2
|
|
@ -1,3 +1,12 @@
|
|||
2016-05-09 Ville Voutilainen <ville.voutilainen@gmail.com>
|
||||
|
||||
Avoid endless run-time recursion for copying single-element
|
||||
tuples where the element type is by-value constructible
|
||||
from any type.
|
||||
* include/std/tuple (_NotSameTuple): New.
|
||||
* include/std/tuple (tuple(_UElements&&...): Use it.
|
||||
* testsuite/20_util/tuple/cons/element_accepts_anything_byval.cc: New.
|
||||
|
||||
2016-05-09 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/71004
|
||||
|
|
|
|||
|
|
@ -500,6 +500,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
__not_<is_constructible<_Elements..., _SrcTuple>>
|
||||
>::value;
|
||||
}
|
||||
template<typename... _UElements>
|
||||
static constexpr bool _NotSameTuple()
|
||||
{
|
||||
return __not_<is_same<tuple<_Elements...>,
|
||||
typename remove_const<
|
||||
typename remove_reference<_UElements...>::type
|
||||
>::type>>::value;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... _Elements>
|
||||
|
|
@ -534,6 +542,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
{
|
||||
return true;
|
||||
}
|
||||
template<typename... _UElements>
|
||||
static constexpr bool _NotSameTuple()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/// Primary class template, tuple
|
||||
|
|
@ -611,7 +624,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
_Elements...>;
|
||||
|
||||
template<typename... _UElements, typename
|
||||
enable_if<_TMC<_UElements...>::template
|
||||
enable_if<
|
||||
_TC<sizeof...(_UElements) == 1, _Elements...>::template
|
||||
_NotSameTuple<_UElements...>()
|
||||
&& _TMC<_UElements...>::template
|
||||
_MoveConstructibleTuple<_UElements...>()
|
||||
&& _TMC<_UElements...>::template
|
||||
_ImplicitlyMoveConvertibleTuple<_UElements...>()
|
||||
|
|
@ -621,7 +637,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
: _Inherited(std::forward<_UElements>(__elements)...) { }
|
||||
|
||||
template<typename... _UElements, typename
|
||||
enable_if<_TMC<_UElements...>::template
|
||||
enable_if<
|
||||
_TC<sizeof...(_UElements) == 1, _Elements...>::template
|
||||
_NotSameTuple<_UElements...>()
|
||||
&& _TMC<_UElements...>::template
|
||||
_MoveConstructibleTuple<_UElements...>()
|
||||
&& !_TMC<_UElements...>::template
|
||||
_ImplicitlyMoveConvertibleTuple<_UElements...>()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (C) 2016 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 <tuple>
|
||||
using namespace std;
|
||||
|
||||
struct Something {
|
||||
Something() { }
|
||||
template <typename T> Something(T) { }
|
||||
};
|
||||
|
||||
int main() {
|
||||
tuple<Something> t1;
|
||||
tuple<Something> t2 = t1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue