xref: /llvm-project/libcxx/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp (revision a9e659619f592c49b352af16253ec0b79c207956)
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11 // <optional>
12 
13 // struct nullopt_t{see below};
14 // constexpr nullopt_t nullopt(unspecified);
15 
16 #include <optional>
17 #include <type_traits>
18 
19 using std::optional;
20 using std::nullopt_t;
21 using std::nullopt;
22 
23 constexpr
24 int
25 test(const nullopt_t&)
26 {
27     return 3;
28 }
29 
30 int main()
31 {
32     static_assert((std::is_class<nullopt_t>::value), "");
33     static_assert((std::is_empty<nullopt_t>::value), "");
34     static_assert((std::is_literal_type<nullopt_t>::value), "");
35     static_assert((!std::is_default_constructible<nullopt_t>::value), "");
36 
37     static_assert(test(nullopt) == 3, "");
38 }
39