ignore.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. // <tuple>
  10. // constexpr unspecified ignore;
  11. // UNSUPPORTED: c++98, c++03
  12. #include <tuple>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. constexpr bool test_ignore_constexpr()
  16. {
  17. #if TEST_STD_VER > 11
  18. { // Test that std::ignore provides constexpr converting assignment.
  19. auto& res = (std::ignore = 42);
  20. assert(&res == &std::ignore);
  21. }
  22. { // Test that std::ignore provides constexpr copy/move constructors
  23. auto copy = std::ignore;
  24. auto moved = std::move(copy);
  25. ((void)moved);
  26. }
  27. { // Test that std::ignore provides constexpr copy/move assignment
  28. auto copy = std::ignore;
  29. copy = std::ignore;
  30. auto moved = std::ignore;
  31. moved = std::move(copy);
  32. }
  33. #endif
  34. return true;
  35. }
  36. int main() {
  37. {
  38. constexpr auto& ignore_v = std::ignore;
  39. ((void)ignore_v);
  40. }
  41. {
  42. static_assert(test_ignore_constexpr(), "");
  43. }
  44. {
  45. LIBCPP_STATIC_ASSERT(std::is_trivial<decltype(std::ignore)>::value, "");
  46. }
  47. }