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