//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // template struct pair // Test that we properly provide the trivial copy operations by default. // FreeBSD still provides the old ABI for std::pair. // XFAIL: freebsd // ADDITIONAL_COMPILE_FLAGS: -Wno-invalid-offsetof #include #include #include #include #include #include "test_macros.h" template struct HasTrivialABI : std::integral_constant::value && (!std::is_copy_constructible::value || std::is_trivially_copy_constructible::value) > {}; struct TrivialNoAssignment { int arr[4]; TrivialNoAssignment& operator=(const TrivialNoAssignment&) = delete; }; struct TrivialNoConstruction { int arr[4]; TrivialNoConstruction() = default; TrivialNoConstruction(const TrivialNoConstruction&) = delete; TrivialNoConstruction& operator=(const TrivialNoConstruction&) = default; }; void test_trivial() { { typedef std::pair P; static_assert(std::is_copy_constructible

::value, ""); static_assert(HasTrivialABI

::value, ""); } { using P = std::pair; static_assert(std::is_trivially_copy_constructible

::value, ""); static_assert(std::is_trivially_move_constructible

::value, ""); static_assert(std::is_trivially_destructible

::value, ""); } { using P = std::pair; static_assert(!std::is_trivially_copy_assignable

::value, ""); static_assert(!std::is_trivially_move_assignable

::value, ""); static_assert(std::is_trivially_destructible

::value, ""); } } void test_layout() { typedef std::pair, char> PairT; static_assert(sizeof(PairT) == 3, ""); static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), ""); static_assert(offsetof(PairT, first) == 0, ""); } int main(int, char**) { test_trivial(); test_layout(); return 0; }