// { dg-options "-std=gnu++17" }
// { dg-do compile { target c++17 } }
// Copyright (C) 2017-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
// .
#include
template struct require_same;
template struct require_same { using type = void; };
template
typename require_same::type
check_type(U&) { }
struct MoveOnly
{
MoveOnly() = default;
MoveOnly(MoveOnly&&);
MoveOnly& operator=(MoveOnly&&);
};
void
test00()
{
std::tuple x;
check_type>(x);
std::tuple copy = x;
check_type(copy);
std::tuple move = std::move(x);
check_type(move);
}
void
test01()
{
std::tuple x = 5;
check_type>(x);
int y = 42;
std::tuple x2 = y;
check_type>(x2);
const int z = 666;
std::tuple x3 = z;
check_type>(x3);
std::tuple mo = MoveOnly();
check_type>(mo);
mo = MoveOnly();
std::tuple copy = x;
check_type(copy);
std::tuple move = std::move(mo);
check_type(move);
}
void
test02()
{
std::tuple x{5, 6u};
check_type>(x);
int y = 42;
std::tuple x2{y, 48u};
check_type>(x2);
const int z = 666;
std::tuple x3{z, y};
check_type>(x3);
std::tuple x4{1, x};
check_type>(x4);
std::tuple mo{MoveOnly(), 2l};
check_type>(mo);
mo = {MoveOnly(), 3l};
std::tuple copy = x;
check_type(copy);
std::tuple copy2{x};
check_type(copy2);
std::tuple move = std::move(mo);
check_type(move);
}
void
test03()
{
std::tuple x{5, 6u, '7'};
check_type>(x);
int y = 42;
std::tuple x2{y, 48u, 54l};
check_type>(x2);
const int z = 666;
std::tuple x3{z, y, x};
check_type>(x3);
std::tuple x4{1, x, x2};
check_type>(x4);
std::tuple mo{MoveOnly(), 2l};
check_type>(mo);
mo = {MoveOnly(), 3l};
std::tuple copy = x;
check_type(copy);
std::tuple copy2{x};
check_type(copy2);
std::tuple move = std::move(mo);
check_type(move);
}
void
test04()
{
std::pair p;
std::tuple x = p;
check_type>(x);
int y = 42;
std::tuple x2{p};
check_type>(x2);
const int z = 666;
std::pair p2;
std::tuple x3{p2};
check_type>(x3);
std::pair p3{p.first, p.second};
std::tuple x4{p3};
check_type>(x4);
std::tuple mo = std::pair();
check_type>(mo);
std::tuple copy = x4;
check_type(copy);
std::tuple copy2{x4};
check_type(copy2);
std::tuple move = std::move(mo);
check_type(move);
}
void
test05()
{
std::allocator a;
std::tuple x{std::allocator_arg, a, 1};
check_type>(x);
std::tuple x2{std::allocator_arg, a, 1, '2'};
check_type>(x2);
std::pair p{};
std::tuple x3{std::allocator_arg, a, p};
check_type>(x3);
std::tuple x4{std::allocator_arg, a, std::move(p)};
check_type>(x4);
std::tuple x5{std::allocator_arg, a, x};
check_type(x5);
std::tuple x6{std::allocator_arg, a, std::move(x)};
check_type(x6);
}