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 // <optional>
     11 
     12 // struct nullopt_t{see below};
     13 // constexpr nullopt_t nullopt(unspecified);
     14 
     15 #include <experimental/optional>
     16 #include <type_traits>
     17 
     18 #if _LIBCPP_STD_VER > 11
     19 
     20 using std::experimental::optional;
     21 using std::experimental::nullopt_t;
     22 using std::experimental::nullopt;
     23 
     24 constexpr
     25 int
     26 test(const nullopt_t&)
     27 {
     28     return 3;
     29 }
     30 
     31 #endif
     32 
     33 int main()
     34 {
     35 #if _LIBCPP_STD_VER > 11
     36     static_assert((std::is_class<nullopt_t>::value), "");
     37     static_assert((std::is_empty<nullopt_t>::value), "");
     38     static_assert((std::is_literal_type<nullopt_t>::value), "");
     39     static_assert((!std::is_default_constructible<nullopt_t>::value), "");
     40 
     41     static_assert(test(nullopt) == 3, "");
     42 #endif
     43 }
     44