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