// Copyright (C) 2019-2024 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
// .
// { dg-do compile { target c++20 } }
#include
static_assert( std::copyable );
static_assert( std::copyable );
static_assert( ! std::copyable );
static_assert( ! std::copyable );
static_assert( ! std::copyable );
static_assert( ! std::copyable );
static_assert( ! std::copyable );
struct Trivial { };
static_assert( std::copyable );
struct NotTrivial
{
NotTrivial(int) { }
NotTrivial(const NotTrivial&) { }
NotTrivial& operator=(const NotTrivial&) { return *this; }
~NotTrivial() { }
};
static_assert( std::copyable );
namespace N1
{
struct Immovable
{
Immovable() = default;
Immovable(Immovable&&) = delete;
};
}
static_assert( ! std::copyable );
struct Movable
{
Movable() = default;
Movable(Movable&&) = default;
Movable& operator=(Movable&&) = default;
};
static_assert( ! std::copyable );
struct MovableAndCopyAssignable
{
MovableAndCopyAssignable() = default;
MovableAndCopyAssignable(MovableAndCopyAssignable&&) = default;
MovableAndCopyAssignable& operator=(MovableAndCopyAssignable&&) = default;
MovableAndCopyAssignable& operator=(const MovableAndCopyAssignable&) = default;
};
static_assert( ! std::copyable );
struct MovableAndCopyConstructible
{
MovableAndCopyConstructible() = default;
MovableAndCopyConstructible(MovableAndCopyConstructible&&) = default;
MovableAndCopyConstructible(const MovableAndCopyConstructible&) = default;
MovableAndCopyConstructible& operator=(MovableAndCopyConstructible&&) = default;
};
static_assert( ! std::copyable );
namespace N2
{
struct Swappable
{
Swappable() = default;
Swappable(Swappable&&) = default;
friend void swap(Swappable&, Swappable&) { }
};
}
static_assert( ! std::copyable );
struct NotAssignable
{
NotAssignable() = default;
NotAssignable(NotAssignable&&) = default;
NotAssignable& operator=(NotAssignable&&) = default;
NotAssignable(const NotAssignable&) = default;
NotAssignable& operator=(const NotAssignable&) = delete;
friend void swap(NotAssignable&, NotAssignable&) { }
};
static_assert( ! std::copyable );
struct NotSwappable
{
NotSwappable() = default;
NotSwappable(const NotSwappable&) = default;
NotSwappable& operator=(const NotSwappable&) = default;
};
void swap(NotSwappable&, NotSwappable&) = delete;
static_assert( std::copyable ); // ranges::swap still works!