ctor_move.pass.cpp 842 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // stack(stack&& q);
  11. #include <stack>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #include "MoveOnly.h"
  15. template <class C>
  16. C
  17. make(int n)
  18. {
  19. C c;
  20. for (int i = 0; i < n; ++i)
  21. c.push_back(MoveOnly(i));
  22. return c;
  23. }
  24. int main(int, char**)
  25. {
  26. std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
  27. std::stack<MoveOnly> q2 = std::move(q);
  28. assert(q2.size() == 5);
  29. assert(q.empty());
  30. return 0;
  31. }