push_rv.pass.cpp 852 B

123456789101112131415161718192021222324252627282930313233
  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. // <stack>
  10. // void push(value_type&& v);
  11. #include <stack>
  12. #include <cassert>
  13. #include "MoveOnly.h"
  14. int main()
  15. {
  16. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  17. std::stack<MoveOnly> q;
  18. q.push(MoveOnly(1));
  19. assert(q.size() == 1);
  20. assert(q.top() == MoveOnly(1));
  21. q.push(MoveOnly(2));
  22. assert(q.size() == 2);
  23. assert(q.top() == MoveOnly(2));
  24. q.push(MoveOnly(3));
  25. assert(q.size() == 3);
  26. assert(q.top() == MoveOnly(3));
  27. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  28. }