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