1// Copyright (C) 2004, 2005, 2009 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 3, or (at your option) 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 15// with this library; see the file COPYING3. If not see 16// <http://www.gnu.org/licenses/>. 17 18#include <map> 19#include <testsuite_hooks.h> 20 21struct T { int i; }; 22 23// T must be LessThanComparable to pass concept-checks 24bool operator<(T l, T r) { return l.i < r.i; } 25 26int swap_calls; 27 28namespace std 29{ 30 template<> 31 void 32 multimap<T, int>::swap(multimap<T, int>&) 33 { ++swap_calls; } 34} 35 36// Should use multimap specialization for swap. 37void test01() 38{ 39 bool test __attribute__((unused)) = true; 40 std::multimap<T, int> A; 41 std::multimap<T, int> B; 42 swap_calls = 0; 43 std::swap(A, B); 44 VERIFY(1 == swap_calls); 45} 46 47// Should use multimap specialization for swap. 48void test02() 49{ 50 bool test __attribute__((unused)) = true; 51 using namespace std; 52 multimap<T, int> A; 53 multimap<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} 66