-
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
c8e5ad4
commit b06140e
Showing
2 changed files
with
66 additions
and
6 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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// REQUIRES: c++20 || clang | ||
|
||
#include <type_traits> | ||
#include <utility> | ||
|
||
struct trivially_copyable { | ||
int arr[4]; | ||
}; | ||
|
||
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<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, ""); | ||
|
||
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); |