summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities
diff options
context:
space:
mode:
authorCasey Carter <Casey@Carter.net>2017-07-09 17:15:49 +0000
committerCasey Carter <Casey@Carter.net>2017-07-09 17:15:49 +0000
commitf2d571c8acc301b4658cb27feb9fc6b1830e5c5e (patch)
tree17cc811fb465d54153a3db059413d5764bb1979d /libcxx/test/std/utilities
parent4050c77d33a6c13f0c314695c63cd78741de656d (diff)
downloadbcm5719-llvm-f2d571c8acc301b4658cb27feb9fc6b1830e5c5e.tar.gz
bcm5719-llvm-f2d571c8acc301b4658cb27feb9fc6b1830e5c5e.zip
optional: Implement LWG 2900 and P0602
Differential Revision: https://reviews.llvm.org/D32385 llvm-svn: 307505
Diffstat (limited to 'libcxx/test/std/utilities')
-rw-r--r--libcxx/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp30
-rw-r--r--libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp8
-rw-r--r--libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp8
-rw-r--r--libcxx/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp36
4 files changed, 55 insertions, 27 deletions
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
index 3ba261b5246..ed8b433da69 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
@@ -147,27 +147,27 @@ int main()
}
{
struct ThrowsMove {
- ThrowsMove() noexcept {}
- ThrowsMove(ThrowsMove const&) noexcept {}
- ThrowsMove(ThrowsMove &&) noexcept(false) {}
- ThrowsMove& operator=(ThrowsMove const&) noexcept { return *this; }
- ThrowsMove& operator=(ThrowsMove &&) noexcept { return *this; }
+ ThrowsMove() noexcept {}
+ ThrowsMove(ThrowsMove const&) noexcept {}
+ ThrowsMove(ThrowsMove &&) noexcept(false) {}
+ ThrowsMove& operator=(ThrowsMove const&) noexcept { return *this; }
+ ThrowsMove& operator=(ThrowsMove &&) noexcept { return *this; }
};
static_assert(!std::is_nothrow_move_assignable<optional<ThrowsMove>>::value, "");
struct ThrowsMoveAssign {
- ThrowsMoveAssign() noexcept {}
- ThrowsMoveAssign(ThrowsMoveAssign const&) noexcept {}
- ThrowsMoveAssign(ThrowsMoveAssign &&) noexcept {}
- ThrowsMoveAssign& operator=(ThrowsMoveAssign const&) noexcept { return *this; }
- ThrowsMoveAssign& operator=(ThrowsMoveAssign &&) noexcept(false) { return *this; }
+ ThrowsMoveAssign() noexcept {}
+ ThrowsMoveAssign(ThrowsMoveAssign const&) noexcept {}
+ ThrowsMoveAssign(ThrowsMoveAssign &&) noexcept {}
+ ThrowsMoveAssign& operator=(ThrowsMoveAssign const&) noexcept { return *this; }
+ ThrowsMoveAssign& operator=(ThrowsMoveAssign &&) noexcept(false) { return *this; }
};
static_assert(!std::is_nothrow_move_assignable<optional<ThrowsMoveAssign>>::value, "");
struct NoThrowMove {
- NoThrowMove() noexcept(false) {}
- NoThrowMove(NoThrowMove const&) noexcept(false) {}
- NoThrowMove(NoThrowMove &&) noexcept {}
- NoThrowMove& operator=(NoThrowMove const&) noexcept { return *this; }
- NoThrowMove& operator=(NoThrowMove&&) noexcept { return *this; }
+ NoThrowMove() noexcept(false) {}
+ NoThrowMove(NoThrowMove const&) noexcept(false) {}
+ NoThrowMove(NoThrowMove &&) noexcept {}
+ NoThrowMove& operator=(NoThrowMove const&) noexcept { return *this; }
+ NoThrowMove& operator=(NoThrowMove&&) noexcept { return *this; }
};
static_assert(std::is_nothrow_move_assignable<optional<NoThrowMove>>::value, "");
}
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
index 6b4283a2854..0f1fabd0ceb 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -45,10 +45,10 @@ constexpr bool constexpr_test(InitArgs&&... args)
void test_throwing_ctor() {
#ifndef TEST_HAS_NO_EXCEPTIONS
struct Z {
- Z() : count(0) {}
- Z(Z const& o) : count(o.count + 1)
- { if (count == 2) throw 6; }
- int count;
+ Z() : count(0) {}
+ Z(Z const& o) : count(o.count + 1)
+ { if (count == 2) throw 6; }
+ int count;
};
const Z z;
const optional<Z> rhs(z);
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
index 55c2156300f..e73f3747c43 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -55,10 +55,10 @@ constexpr bool constexpr_test(InitArgs&&... args)
void test_throwing_ctor() {
#ifndef TEST_HAS_NO_EXCEPTIONS
struct Z {
- Z() : count(0) {}
- Z(Z&& o) : count(o.count + 1)
- { if (count == 2) throw 6; }
- int count;
+ Z() : count(0) {}
+ Z(Z&& o) : count(o.count + 1)
+ { if (count == 2) throw 6; }
+ int count;
};
Z z;
optional<Z> rhs(std::move(z));
diff --git a/libcxx/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
index fdd0f154f0e..0b9b6e717c3 100644
--- a/libcxx/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
@@ -33,10 +33,38 @@ struct SpecialMemberTest {
"optional<T> is copy assignable if and only if T is both copy "
"constructible and copy assignable.");
static_assert(std::is_move_assignable_v<O> ==
- ((std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>) ||
- (std::is_move_constructible_v<T> && std::is_move_assignable_v<T>)),
- "optional<T> is move assignable if and only if T is both move assignable and "
- "move constructible, or both copy constructible and copy assignable.");
+ ((std::is_move_constructible_v<T> && std::is_move_assignable_v<T>) ||
+ (std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>)),
+ "optional<T> is move assignable if and only if T is both move constructible and "
+ "move assignable, or both copy constructible and copy assignable.");
+
+ // The following tests are for not-yet-standardized behavior (P0602):
+ static_assert(std::is_trivially_destructible_v<O> ==
+ std::is_trivially_destructible_v<T>,
+ "optional<T> is trivially destructible if and only if T is.");
+ static_assert(std::is_trivially_copy_constructible_v<O> ==
+ std::is_trivially_copy_constructible_v<T>,
+ "optional<T> is trivially copy constructible if and only if T is.");
+ static_assert(std::is_trivially_move_constructible_v<O> ==
+ std::is_trivially_move_constructible_v<T> ||
+ (!std::is_move_constructible_v<T> && std::is_trivially_copy_constructible_v<T>),
+ "optional<T> is trivially move constructible if T is trivially move constructible, "
+ "or if T is trivially copy constructible and is not move constructible.");
+ static_assert(std::is_trivially_copy_assignable_v<O> ==
+ (std::is_trivially_destructible_v<T> &&
+ std::is_trivially_copy_constructible_v<T> &&
+ std::is_trivially_copy_assignable_v<T>),
+ "optional<T> is trivially copy assignable if and only if T is trivially destructible, "
+ "trivially copy constructible, and trivially copy assignable.");
+ static_assert(std::is_trivially_move_assignable_v<O> ==
+ (std::is_trivially_destructible_v<T> &&
+ ((std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T>) ||
+ ((!std::is_move_constructible_v<T> || !std::is_move_assignable_v<T>) &&
+ std::is_trivially_copy_constructible_v<T> && std::is_trivially_copy_assignable_v<T>))),
+ "optional<T> is trivially move assignable if T is trivially destructible, and either "
+ "(1) trivially move constructible and trivially move assignable, or "
+ "(2) not move constructible or not move assignable, and "
+ "trivially copy constructible and trivially copy assignable.");
};
template <class ...Args> static void sink(Args&&...) {}
OpenPOWER on IntegriCloud