not_equal.pass.cpp 1.1 KB

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