Commit 6d1402f0 by Edward Smith-Rowland Committed by Edward Smith-Rowland

Implement the <tuple> part of C++20 p1032 Misc constexpr bits.

2019-11-15  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement the <tuple> part of C++20 p1032 Misc constexpr bits.
	* include/std/tuple (_Head_base, _Tuple_impl(allocator_arg_t,...)
	(_M_assign, tuple(allocator_arg_t,...), _Inherited, operator=, _M_swap)
	(swap, pair(piecewise_construct_t,): Constexpr.
	* (__uses_alloc0::_Sink::operator=, __uses_alloc_t): Constexpr.
	* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: New test.
	* testsuite/20_util/tuple/constexpr_swap.cc : New test.
	* testsuite/20_util/uses_allocator/69293_neg.cc: Extra error for C++20.
	* testsuite/20_util/uses_allocator/cons_neg.cc: : Extra error for C++20.

From-SVN: r278331
parent 97e4a5ee
2019-11-15 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement the <tuple> part of C++20 p1032 Misc constexpr bits.
* include/std/tuple (_Head_base, _Tuple_impl(allocator_arg_t,...)
(_M_assign, tuple(allocator_arg_t,...), _Inherited, operator=, _M_swap)
(swap, pair(piecewise_construct_t,): Constexpr.
* (__uses_alloc0::_Sink::operator=, __uses_alloc_t): Constexpr.
* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: New test.
* testsuite/20_util/tuple/constexpr_swap.cc : New test.
* testsuite/20_util/uses_allocator/69293_neg.cc: Extra error for C++20.
* testsuite/20_util/uses_allocator/cons_neg.cc: : Extra error for C++20.
2019-11-15 Jonathan Wakely <jwakely@redhat.com>
* include/std/stop_token: Reduce header dependencies by including
......
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
//
// Copyright (C) 2019 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 <memory>
#include <tuple>
const std::allocator<int> alloc{};
constexpr bool
test_tuple()
{
auto ok = true;
std::tuple<int, double, double> ta(std::allocator_arg, alloc);
std::tuple<int, double, double> tb(std::allocator_arg, alloc, 0, 3.456, 6.789);
std::tuple<int, double, double> tc(std::allocator_arg, alloc, 0, 3.456f, 6.789f);
std::tuple<int, double, double> td(std::allocator_arg, alloc, tb);
std::tuple<int, double, double> te(std::allocator_arg, alloc, std::move(tb));
std::tuple<int, float, float> tf(std::allocator_arg, alloc, 0, 3.456f, 6.789f);
std::tuple<int, double, double> tg(std::allocator_arg, alloc, tf);
std::tuple<int, double, double> th(std::allocator_arg, alloc, std::move(tf));
std::pair<int, float> pf(12, 3.142f);
std::tuple<int, double> ti(std::allocator_arg, alloc, pf);
std::tuple<int, double> tj(std::allocator_arg, alloc, std::move(pf));
return ok;
}
static_assert(test_tuple());
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
//
// Copyright (C) 2019 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>
constexpr bool
test_tuple()
{
auto ok = true;
std::tuple<int, double, double> t1(1, 3.1415, 2.7182);
std::tuple<int, double, double> t2(1, 4.1234, 3.3333);
t1.swap(t2);
std::swap(t1, t2);
return ok;
}
static_assert(test_tuple());
......@@ -45,4 +45,5 @@ test01()
alloc_type a;
std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed
// { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
// { dg-error "no matching function for call" "" { target c++2a } 0 }
}
......@@ -44,3 +44,4 @@ void test01()
tuple<Type> t(allocator_arg, a, 1);
}
// { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
// { dg-error "no matching function for call" "" { target c++2a } 0 }
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