nullopt_t.pass.cpp 972 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. // struct nullopt_t{see below};
  12. // constexpr nullopt_t nullopt(unspecified);
  13. #include <optional>
  14. #include <type_traits>
  15. using std::optional;
  16. using std::nullopt_t;
  17. using std::nullopt;
  18. constexpr
  19. int
  20. test(const nullopt_t&)
  21. {
  22. return 3;
  23. }
  24. int main()
  25. {
  26. static_assert((std::is_class<nullopt_t>::value), "");
  27. static_assert((std::is_empty<nullopt_t>::value), "");
  28. static_assert((std::is_literal_type<nullopt_t>::value), "");
  29. static_assert((!std::is_default_constructible<nullopt_t>::value), "");
  30. static_assert(test(nullopt) == 3, "");
  31. }