less_equal.pass.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // <optional>
  10. // template <class T> constexpr bool operator<=(const optional<T>& x, nullopt_t) noexcept;
  11. // template <class T> constexpr bool operator<=(nullopt_t, const optional<T>& x) noexcept;
  12. #include <experimental/optional>
  13. #include "test_macros.h"
  14. int main()
  15. {
  16. #if TEST_STD_VER > 11
  17. using std::experimental::optional;
  18. using std::experimental::nullopt_t;
  19. using std::experimental::nullopt;
  20. {
  21. typedef int T;
  22. typedef optional<T> O;
  23. constexpr O o1; // disengaged
  24. constexpr O o2{1}; // engaged
  25. static_assert ( (nullopt <= o1), "" );
  26. static_assert ( (nullopt <= o2), "" );
  27. static_assert ( (o1 <= nullopt), "" );
  28. static_assert ( !(o2 <= nullopt), "" );
  29. static_assert (noexcept(nullopt <= o1), "");
  30. static_assert (noexcept(o1 <= nullopt), "");
  31. }
  32. #endif
  33. }