Home | History | Annotate | Download | only in optional.nullops
      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 
     11 // <optional>
     12 
     13 // template <class T> constexpr bool operator<(const optional<T>& x, nullopt_t) noexcept;
     14 // template <class T> constexpr bool operator<(nullopt_t, const optional<T>& x) noexcept;
     15 
     16 #include <experimental/optional>
     17 
     18 int main()
     19 {
     20 #if _LIBCPP_STD_VER > 11
     21 	using std::experimental::optional;
     22 	using std::experimental::nullopt_t;
     23 	using std::experimental::nullopt;
     24 
     25     {
     26     typedef int T;
     27     typedef optional<T> O;
     28 
     29     constexpr O o1;     // disengaged
     30     constexpr O o2{1};  // engaged
     31 
     32     static_assert ( !(nullopt < o1), "" );
     33     static_assert (   nullopt < o2 , "" );
     34     static_assert ( !(o1 < nullopt), "" );
     35     static_assert ( !(o2 < nullopt), "" );
     36 
     37     static_assert (noexcept(nullopt < o1), "");
     38     static_assert (noexcept(o1 < nullopt), "");
     39     }
     40 #endif
     41 }
     42