Merge from mainline
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / multimap / modifiers / swap.cc
blob76cbe465cc31cabd57faabad9bf874999131c372
1 // Copyright (C) 2004, 2005 Free Software Foundation
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 // USA.
19 #include <map>
20 #include <testsuite_hooks.h>
22 struct T { int i; };
24 // T must be LessThanComparable to pass concept-checks
25 bool operator<(T l, T r) { return l.i < r.i; }
27 int swap_calls;
29 namespace std
31 template<>
32 void
33 multimap<T, int>::swap(multimap<T, int>&)
34 { ++swap_calls; }
37 // Should use multimap specialization for swap.
38 void test01()
40 bool test __attribute__((unused)) = true;
41 std::multimap<T, int> A;
42 std::multimap<T, int> B;
43 swap_calls = 0;
44 std::swap(A, B);
45 VERIFY(1 == swap_calls);
48 // Should use multimap specialization for swap.
49 void test02()
51 bool test __attribute__((unused)) = true;
52 using namespace std;
53 multimap<T, int> A;
54 multimap<T, int> B;
55 swap_calls = 0;
56 swap(A, B);
57 VERIFY(1 == swap_calls);
60 // See c++/13658 for background info.
61 int main()
63 test01();
64 test02();
65 return 0;