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 // [optional.nullopt]/2: 17 // Type nullopt_t shall not have a default constructor or an initializer-list constructor. 18 // It shall not be an aggregate and shall be a literal type. 19 // Constant nullopt shall be initialized with an argument of literal type. 20 21 #include <optional> 22 #include <type_traits> 23 24 using std::optional; 25 using std::nullopt_t; 26 using std::nullopt; 27 28 constexpr 29 int test(const nullopt_t &)30test(const nullopt_t&) 31 { 32 return 3; 33 } 34 main()35int main() 36 { 37 static_assert(( std::is_class<nullopt_t>::value), ""); 38 static_assert(( std::is_empty<nullopt_t>::value), ""); 39 static_assert(( std::is_literal_type<nullopt_t>::value), ""); 40 static_assert((!std::is_default_constructible<nullopt_t>::value), ""); 41 42 static_assert(test(nullopt) == 3, ""); 43 } 44