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 9 // <stack> 10 11 // template <class T, class Container> 12 // void swap(stack<T, Container>& x, stack<T, Container>& y); 13 14 #include <stack> 15 #include <cassert> 16 17 #include "test_macros.h" 18 19 template <class C> 20 C make(int n)21make(int n) 22 { 23 C c; 24 for (int i = 0; i < n; ++i) 25 c.push(i); 26 return c; 27 } 28 main(int,char **)29int main(int, char**) 30 { 31 std::stack<int> q1 = make<std::stack<int> >(5); 32 std::stack<int> q2 = make<std::stack<int> >(10); 33 std::stack<int> q1_save = q1; 34 std::stack<int> q2_save = q2; 35 swap(q1, q2); 36 assert(q1 == q2_save); 37 assert(q2 == q1_save); 38 39 return 0; 40 } 41