//===----------------------------------------------------------------------===// // // 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++98, c++03 // // template struct pair; // pair(pair const&) = default; // pair(pair &&) = default; // pair& operator=(pair const&); // pair& operator=(pair&&); // Test that the copy/move constructors and assignment operators are // correctly defined or deleted based on the properties of `T` and `U`. #include #include #include #include "archetypes.h" #include "test_macros.h" using namespace ImplicitTypes; // Get implicitly archetypes namespace ConstructorTest { template void test() { using P1 = std::pair; using P2 = std::pair; static_assert(std::is_copy_constructible::value == CanCopy, ""); static_assert(std::is_move_constructible::value == CanMove, ""); static_assert(std::is_copy_constructible::value == CanCopy, ""); static_assert(std::is_move_constructible::value == CanMove, ""); }; } // namespace ConstructorTest void test_constructors_exist() { using namespace ConstructorTest; { test(); test(); test(); test(); test(); test(); } { test(); test(); test(); } { test(); test(); test(); } { // Even though CopyOnly has an explicitly deleted move constructor // pair's move constructor is only implicitly deleted and therefore // it doesn't participate in overload resolution. test(); test(); test(); } { test(); test(); test(); } } namespace AssignmentOperatorTest { template void test() { using P1 = std::pair; using P2 = std::pair; static_assert(std::is_copy_assignable::value == CanCopy, ""); static_assert(std::is_move_assignable::value == CanMove, ""); static_assert(std::is_copy_assignable::value == CanCopy, ""); static_assert(std::is_move_assignable::value == CanMove, ""); }; } // namespace AssignmentOperatorTest void test_assignment_operator_exists() { using namespace AssignmentOperatorTest; { test(); test(); test(); test(); test(); test(); } { test(); test(); test(); } { test(); test(); test(); } { test(); test(); test(); } { test(); test(); test(); } } int main(int, char**) { test_constructors_exist(); test_assignment_operator_exists(); return 0; }