push_rv.pass.cpp 859 B

1234567891011121314151617181920212223242526272829303132333435
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // UNSUPPORTED: c++98, c++03
  9. // <stack>
  10. // void push(value_type&& v);
  11. #include <stack>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #include "MoveOnly.h"
  15. int main(int, char**)
  16. {
  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. return 0;
  28. }