xref: /llvm-project/libcxx/test/std/utilities/optional/optional.nullops/less_equal.pass.cpp (revision 31cbe0f240f660f15602c96b787c58a26f17e179)
1a9e65961SEric Fiselier //===----------------------------------------------------------------------===//
2a9e65961SEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a9e65961SEric Fiselier //
7a9e65961SEric Fiselier //===----------------------------------------------------------------------===//
8a9e65961SEric Fiselier 
9*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11, c++14
10a9e65961SEric Fiselier 
11a9e65961SEric Fiselier // <optional>
12a9e65961SEric Fiselier 
13a9e65961SEric Fiselier // template <class T> constexpr bool operator<=(const optional<T>& x, nullopt_t) noexcept;
14a9e65961SEric Fiselier // template <class T> constexpr bool operator<=(nullopt_t, const optional<T>& x) noexcept;
15a9e65961SEric Fiselier 
16a9e65961SEric Fiselier #include <optional>
17a9e65961SEric Fiselier 
187fc6a556SMarshall Clow #include "test_macros.h"
197fc6a556SMarshall Clow 
main(int,char **)202df59c50SJF Bastien int main(int, char**)
21a9e65961SEric Fiselier {
22a9e65961SEric Fiselier     using std::optional;
23a9e65961SEric Fiselier     using std::nullopt_t;
24a9e65961SEric Fiselier     using std::nullopt;
25a9e65961SEric Fiselier 
26a9e65961SEric Fiselier     {
27a9e65961SEric Fiselier     typedef int T;
28a9e65961SEric Fiselier     typedef optional<T> O;
29a9e65961SEric Fiselier 
30a9e65961SEric Fiselier     constexpr O o1;     // disengaged
31a9e65961SEric Fiselier     constexpr O o2{1};  // engaged
32a9e65961SEric Fiselier 
33a9e65961SEric Fiselier     static_assert (  (nullopt <= o1), "" );
34a9e65961SEric Fiselier     static_assert (  (nullopt <= o2), "" );
35a9e65961SEric Fiselier     static_assert (  (o1 <= nullopt), "" );
36a9e65961SEric Fiselier     static_assert ( !(o2 <= nullopt), "" );
37a9e65961SEric Fiselier 
38a9e65961SEric Fiselier     static_assert (noexcept(nullopt <= o1), "");
39a9e65961SEric Fiselier     static_assert (noexcept(o1 <= nullopt), "");
40a9e65961SEric Fiselier     }
412df59c50SJF Bastien 
422df59c50SJF Bastien   return 0;
43a9e65961SEric Fiselier }
44