From 057ce49719a82ad05978d0abca9d9dc95a3f4958 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Mon, 5 Oct 2015 12:57:20 +0300 Subject: [PATCH] re PR c++/67844 (Cannot make tuple of class with template constructor) 2015-10-05 Ville Voutilainen PR 67844. * include/std/tuple (_TC::_NonNestedTuple): Eagerly reject conversions from tuple types same as the target tuple. * testsuite/20_util/tuple/67844.cc: New. * testsuite/20_util/tuple/cons/nested_tuple_construct.cc: Add a missing copyright header. From-SVN: r228468 --- libstdc++-v3/ChangeLog | 9 ++++ libstdc++-v3/include/std/tuple | 8 +++- libstdc++-v3/testsuite/20_util/tuple/67844.cc | 43 +++++++++++++++++++ .../tuple/cons/nested_tuple_construct.cc | 17 ++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/20_util/tuple/67844.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index fa18ecea0f2..e29343998c7 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2015-10-05 Ville Voutilainen + + PR 67844. + * include/std/tuple (_TC::_NonNestedTuple): Eagerly reject + conversions from tuple types same as the target tuple. + * testsuite/20_util/tuple/67844.cc: New. + * testsuite/20_util/tuple/cons/nested_tuple_construct.cc: Add + a missing copyright header. + 2015-10-03 Jonathan Wakely * python/libstdcxx/v6/printers.py (StdExpAnyPrinter): Remove support diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 751d7eb97cc..8af01f4756e 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -457,6 +457,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; + template + class tuple; // Concept utility functions, reused in conditionally-explicit // constructors. @@ -490,7 +492,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template static constexpr bool _NonNestedTuple() { - return __and_<__not_>, + return __and_<__not_, + typename remove_cv< + typename remove_reference<_SrcTuple>::type + >::type>>, + __not_>, __not_> >::value; } diff --git a/libstdc++-v3/testsuite/20_util/tuple/67844.cc b/libstdc++-v3/testsuite/20_util/tuple/67844.cc new file mode 100644 index 00000000000..a4efb5ae357 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/67844.cc @@ -0,0 +1,43 @@ +// { dg-do compile } + +// Copyright (C) 2015 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 +// . + +// libstdc++/67844 + +#include + +struct A +{ + template + A(T) + { + } + + A(const A&) = default; + A(A&&) = default; + A& operator=(const A&) = default; + A& operator=(A&&) = default; + ~A() = default; +}; + +int main() +{ + auto x = A{7}; + std::make_tuple(x); +} + diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/nested_tuple_construct.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/nested_tuple_construct.cc index 32ef3cc0259..6085beefe33 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/cons/nested_tuple_construct.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/nested_tuple_construct.cc @@ -1,3 +1,20 @@ +// Copyright (C) 2015 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 +// . + #include #include #include -- 2.30.2