Add one more test for optional

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2018-05-25 02:22:54 +00:00
parent 2fac2d790f
commit 756163dbc1

View File

@@ -25,20 +25,29 @@ int main()
{
// Test the explicit deduction guides
{
// optional(T)
// optional(T)
std::optional opt(5);
static_assert(std::is_same_v<decltype(opt), std::optional<int>>, "");
assert(static_cast<bool>(opt));
assert(*opt == 5);
assert(static_cast<bool>(opt));
assert(*opt == 5);
}
{
// optional(T)
// optional(T)
std::optional opt(A{});
static_assert(std::is_same_v<decltype(opt), std::optional<A>>, "");
assert(static_cast<bool>(opt));
assert(static_cast<bool>(opt));
}
// Test the implicit deduction guides
{
// optional(const optional &);
std::optional<char> source('A');
std::optional opt(source);
static_assert(std::is_same_v<decltype(opt), std::optional<char>>, "");
assert(static_cast<bool>(opt) == static_cast<bool>(source));
assert(*opt == *source);
}
}