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 // constexpr explicit optional<T>::operator bool() const noexcept; 14 15 #include <optional> 16 #include <type_traits> 17 #include <cassert> 18 19 #include "test_macros.h" 20 main()21int main() 22 { 23 using std::optional; 24 { 25 const optional<int> opt; ((void)opt); 26 ASSERT_NOEXCEPT(bool(opt)); 27 static_assert(!std::is_convertible<optional<int>, bool>::value, ""); 28 } 29 { 30 constexpr optional<int> opt; 31 static_assert(!opt, ""); 32 } 33 { 34 constexpr optional<int> opt(0); 35 static_assert(opt, ""); 36 } 37 } 38