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.
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 COPYING.  If not, write to the Free
16// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17// USA.
18
19#include <set>
20#include <testsuite_hooks.h>
21
22struct T { int i; };
23
24// T must be LessThanComparable to pass concept-checks
25bool operator<(T l, T r) { return l.i < r.i; }
26
27int swap_calls;
28
29namespace std
30{
31  template<>
32    void
33    set<T>::swap(set<T>&)
34    { ++swap_calls; }
35}
36
37// Should use set specialization for swap.
38void test01()
39{
40  bool test __attribute__((unused)) = true;
41  std::set<T> A;
42  std::set<T> B;
43  swap_calls = 0;
44  std::swap(A, B);
45  VERIFY(1 == swap_calls);
46}
47
48// Should use set specialization for swap.
49void test02()
50{
51  bool test __attribute__((unused)) = true;
52  using namespace std;
53  set<T> A;
54  set<T> B;
55  swap_calls = 0;
56  swap(A, B);
57  VERIFY(1 == swap_calls);
58}
59
60// See c++/13658 for background info.
61int main()
62{
63  test01();
64  test02();
65  return 0;
66}
67