]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / map / modifiers / swap / 1.cc
CommitLineData
aa118a03 1// Copyright (C) 2004-2014 Free Software Foundation, Inc.
f1c4ca32
BK
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
748086b7 6// Free Software Foundation; either version 3, or (at your option)
f1c4ca32
BK
7// any later version.
8
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.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
f1c4ca32
BK
17
18#include <map>
19#include <testsuite_hooks.h>
20
21struct T { int i; };
22
b2342b54
JW
23// T must be LessThanComparable to pass concept-checks
24bool operator<(T l, T r) { return l.i < r.i; }
25
f1c4ca32
BK
26int swap_calls;
27
28namespace std
29{
30 template<>
31 void
32 map<T, int>::swap(map<T, int>&)
33 { ++swap_calls; }
34}
35
36// Should use map specialization for swap.
37void test01()
38{
39 bool test __attribute__((unused)) = true;
40 std::map<T, int> A;
41 std::map<T, int> B;
42 swap_calls = 0;
43 std::swap(A, B);
44 VERIFY(1 == swap_calls);
45}
46
47// Should use map specialization for swap.
48void test02()
49{
50 bool test __attribute__((unused)) = true;
51 using namespace std;
52 map<T, int> A;
53 map<T, int> B;
54 swap_calls = 0;
55 swap(A, B);
56 VERIFY(1 == swap_calls);
57}
58
59// See c++/13658 for background info.
60int main()
61{
62 test01();
63 test02();
64 return 0;
65}