Home | History | Annotate | Download | only in optional.nullopt
      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 // inline constexpr nullopt_t nullopt(unspecified);
     15 
     16 // [optional.nullopt]/2:
     17 //   Type nullopt_t shall not have a default constructor or an initializer-list
     18 //   constructor, and shall not be an aggregate.
     19 
     20 #include <optional>
     21 #include <type_traits>
     22 
     23 using std::nullopt_t;
     24 using std::nullopt;
     25 
     26 constexpr bool test()
     27 {
     28     nullopt_t foo{nullopt};
     29     (void)foo;
     30     return true;
     31 }
     32 
     33 int main()
     34 {
     35     static_assert(std::is_empty_v<nullopt_t>);
     36     static_assert(!std::is_default_constructible_v<nullopt_t>);
     37 
     38     static_assert(std::is_same_v<const nullopt_t, decltype(nullopt)>);
     39     static_assert(test());
     40 }
     41