swap.pass.cpp 750 B

123456789101112131415161718192021222324252627282930313233
  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. // <queue>
  9. // priority_queue();
  10. // void swap(priority_queue& q);
  11. #include <queue>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. int main(int, char**)
  15. {
  16. std::priority_queue<int> q1;
  17. std::priority_queue<int> q2;
  18. q1.push(1);
  19. q1.push(3);
  20. q1.push(2);
  21. q1.swap(q2);
  22. assert(q1.empty());
  23. assert(q2.size() == 3);
  24. assert(q2.top() == 3);
  25. return 0;
  26. }