//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // template // concept indirectly_copyable; #include #include "MoveOnly.h" #include "test_macros.h" struct CopyOnly { CopyOnly() = default; CopyOnly(CopyOnly const&) = default; CopyOnly& operator=(CopyOnly const&) = default; CopyOnly(CopyOnly&&) = delete; CopyOnly& operator=(CopyOnly&&) = delete; }; // Can copy the underlying objects between pointers. static_assert( std::indirectly_copyable); static_assert( std::indirectly_copyable); // Can't copy if the output pointer is const. static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); // Can copy from a pointer into an array but arrays aren't considered indirectly copyable-from. static_assert( std::indirectly_copyable); static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); // Can't copy between non-pointer types. static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); // Check some less common types. static_assert(!std::indirectly_movable); static_assert(!std::indirectly_movable); static_assert(!std::indirectly_movable); static_assert(!std::indirectly_movable); static_assert(!std::indirectly_movable); // Can't copy move-only objects. static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); static_assert(!std::indirectly_copyable); // Can copy copy-only objects. static_assert( std::indirectly_copyable); static_assert(!std::indirectly_copyable); static_assert( std::indirectly_copyable); static_assert(!std::indirectly_copyable); template struct PointerTo { using value_type = T; T& operator*() const; }; // Can copy through a dereferenceable class. static_assert( std::indirectly_copyable>); static_assert(!std::indirectly_copyable>); static_assert( std::indirectly_copyable, PointerTo>); static_assert(!std::indirectly_copyable, PointerTo>); static_assert( std::indirectly_copyable>); static_assert( std::indirectly_copyable, CopyOnly*>); static_assert( std::indirectly_copyable, PointerTo>);