assign_move.pass.cpp 861 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // <queue>
  10. // queue& operator=(queue&& q);
  11. #include <queue>
  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::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
  27. std::queue<MoveOnly> q2;
  28. q2 = std::move(q);
  29. assert(q2.size() == 5);
  30. assert(q.empty());
  31. return 0;
  32. }