-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++][ABI BREAK] Make std::pair trivially copyable if its members are
- Loading branch information
1 parent
66e1d2c
commit 9a4773d
Showing
4 changed files
with
142 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/trivially_copyable.compile.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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: gcc && (c++11 || c++14 || c++17) | ||
|
||
#include <type_traits> | ||
#include <utility> | ||
|
||
struct trivially_copyable { | ||
int arr[4]; | ||
}; | ||
|
||
struct trivially_copyable_no_assignment { | ||
int arr[4]; | ||
trivially_copyable_no_assignment& operator=(const trivially_copyable_no_assignment&) = delete; | ||
}; | ||
static_assert(std::is_trivially_copyable<trivially_copyable_no_assignment>::value, ""); | ||
|
||
static_assert(std::is_trivially_copy_constructible<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
static_assert(std::is_trivially_move_constructible<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
static_assert(!std::is_trivially_copy_assignable<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
static_assert(!std::is_trivially_move_assignable<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
static_assert(std::is_trivially_destructible<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
|
||
struct trivially_copyable_no_construction { | ||
int arr[4]; | ||
trivially_copyable_no_construction() = default; | ||
trivially_copyable_no_construction(const trivially_copyable_no_construction&) = delete; | ||
trivially_copyable_no_construction& operator=(const trivially_copyable_no_construction&) = default; | ||
}; | ||
static_assert(std::is_trivially_copyable<trivially_copyable_no_construction>::value, ""); | ||
|
||
#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
static_assert(!std::is_trivially_copy_constructible<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(!std::is_trivially_move_constructible<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(std::is_trivially_copy_assignable<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(std::is_trivially_move_assignable<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(std::is_trivially_destructible<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
#else // _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
static_assert(!std::is_trivially_copy_constructible<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(!std::is_trivially_move_constructible<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(!std::is_trivially_copy_assignable<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(!std::is_trivially_move_assignable<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
static_assert(std::is_trivially_destructible<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
#endif // _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
|
||
static_assert(!std::is_trivially_copyable<std::pair<int&, int> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<int, int&> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<int&, int&> >::value, ""); | ||
|
||
#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
static_assert(std::is_trivially_copyable<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_copyable<std::pair<int, char> >::value, ""); | ||
static_assert(std::is_trivially_copyable<std::pair<char, int> >::value, ""); | ||
static_assert(std::is_trivially_copyable<std::pair<std::pair<char, char>, int> >::value, ""); | ||
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable, int> >::value, ""); | ||
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
|
||
static_assert(std::is_trivially_copy_constructible<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_move_constructible<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_copy_assignable<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_move_assignable<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_destructible<std::pair<int, int> >::value, ""); | ||
|
||
#else // _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
static_assert(!std::is_trivially_copyable<std::pair<int, int> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<int, char> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<char, int> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<std::pair<char, char>, int> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable, int> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable_no_assignment, int> >::value, ""); | ||
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable_no_construction, int> >::value, ""); | ||
|
||
static_assert(std::is_trivially_copy_constructible<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_move_constructible<std::pair<int, int> >::value, ""); | ||
static_assert(!std::is_trivially_copy_assignable<std::pair<int, int> >::value, ""); | ||
static_assert(!std::is_trivially_move_assignable<std::pair<int, int> >::value, ""); | ||
static_assert(std::is_trivially_destructible<std::pair<int, int> >::value, ""); | ||
#endif // _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR |