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 // <optional>
     11 
     12 // constexpr const T& optional<T>::value() const;
     13 
     14 #include <experimental/optional>
     15 #include <type_traits>
     16 #include <cassert>
     17 
     18 #if _LIBCPP_STD_VER > 11
     19 
     20 using std::experimental::optional;
     21 
     22 struct X
     23 {
     24     constexpr int test() const {return 3;}
     25     int test() {return 4;}
     26 };
     27 
     28 #endif  // _LIBCPP_STD_VER > 11
     29 
     30 int main()
     31 {
     32 #if _LIBCPP_STD_VER > 11
     33     {
     34         constexpr optional<X> opt;
     35         static_assert(opt.value().test() == 3, "");
     36     }
     37 #else
     38 #error
     39 #endif  // _LIBCPP_STD_VER > 11
     40 }
     41