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 #include "test_macros.h"
     19 
     20 int main()
     21 {
     22 #if TEST_STD_VER > 11
     23     using std::experimental::optional;
     24     using std::experimental::nullopt_t;
     25     using std::experimental::nullopt;
     26 
     27     {
     28     typedef int T;
     29     typedef optional<T> O;
     30 
     31     constexpr O o1;     // disengaged
     32     constexpr O o2{1};  // engaged
     33 
     34     static_assert (  (nullopt <= o1), "" );
     35     static_assert (  (nullopt <= o2), "" );
     36     static_assert (  (o1 <= nullopt), "" );
     37     static_assert ( !(o2 <= nullopt), "" );
     38 
     39     static_assert (noexcept(nullopt <= o1), "");
     40     static_assert (noexcept(o1 <= nullopt), "");
     41     }
     42 #endif
     43 }
     44