xref: /llvm-project/libcxx/test/std/utilities/optional/optional.nullops/less_equal.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++98, c++03, c++11, c++14
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 <optional>
17 
18 int main()
19 {
20     using std::optional;
21     using std::nullopt_t;
22     using std::nullopt;
23 
24     {
25     typedef int T;
26     typedef optional<T> O;
27 
28     constexpr O o1;     // disengaged
29     constexpr O o2{1};  // engaged
30 
31     static_assert (  (nullopt <= o1), "" );
32     static_assert (  (nullopt <= o2), "" );
33     static_assert (  (o1 <= nullopt), "" );
34     static_assert ( !(o2 <= nullopt), "" );
35 
36     static_assert (noexcept(nullopt <= o1), "");
37     static_assert (noexcept(o1 <= nullopt), "");
38     }
39 }
40