• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <stack>
11 
12 // template <class T, class Container>
13 //   void swap(stack<T, Container>& x, stack<T, Container>& y);
14 
15 #include <stack>
16 #include <cassert>
17 
18 template <class C>
19 C
make(int n)20 make(int n)
21 {
22     C c;
23     for (int i = 0; i < n; ++i)
24         c.push(i);
25     return c;
26 }
27 
main()28 int main()
29 {
30     std::stack<int> q1 = make<std::stack<int> >(5);
31     std::stack<int> q2 = make<std::stack<int> >(10);
32     std::stack<int> q1_save = q1;
33     std::stack<int> q2_save = q2;
34     swap(q1, q2);
35     assert(q1 == q2_save);
36     assert(q2 == q1_save);
37 }
38