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 // UNSUPPORTED: c++98, c++03, c++11, c++14 12 // UNSUPPORTED: libcpp-no-deduction-guides 13 14 15 // template<class T> 16 // optional(T) -> optional<T>; 17 18 19 #include <optional> 20 #include <cassert> 21 22 struct A {}; 23 24 int main() 25 { 26 // Test the explicit deduction guides 27 28 // Test the implicit deduction guides 29 { 30 // optional() 31 std::optional opt; // expected-error {{declaration of variable 'opt' with deduced type 'std::optional' requires an initializer}} 32 } 33 34 { 35 // optional(nullopt_t) 36 std::optional opt(std::nullopt); // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with nullopt_t is ill-formed"}} 37 } 38 } 39