]>
Commit | Line | Data |
---|---|---|
f1717362 | 1 | // Copyright (C) 2004-2016 Free Software Foundation, Inc. |
7c9e3513 | 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 | |
6bc9506f | 6 | // Free Software Foundation; either version 3, or (at your option) |
7c9e3513 | 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 | |
6bc9506f | 15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
7c9e3513 | 17 | |
18 | #include <set> | |
19 | #include <testsuite_hooks.h> | |
20 | ||
21 | struct T { int i; }; | |
22 | ||
c0516d21 | 23 | // T must be LessThanComparable to pass concept-checks |
24 | bool operator<(T l, T r) { return l.i < r.i; } | |
25 | ||
7c9e3513 | 26 | int swap_calls; |
27 | ||
28 | namespace std | |
29 | { | |
30 | template<> | |
31 | void | |
32 | multiset<T>::swap(multiset<T>&) | |
33 | { ++swap_calls; } | |
34 | } | |
35 | ||
36 | // Should use multiset specialization for swap. | |
37 | void test01() | |
38 | { | |
39 | bool test __attribute__((unused)) = true; | |
40 | std::multiset<T> A; | |
41 | std::multiset<T> B; | |
42 | swap_calls = 0; | |
43 | std::swap(A, B); | |
44 | VERIFY(1 == swap_calls); | |
45 | } | |
46 | ||
47 | // Should use multiset specialization for swap. | |
48 | void test02() | |
49 | { | |
50 | bool test __attribute__((unused)) = true; | |
51 | using namespace std; | |
52 | multiset<T> A; | |
53 | multiset<T> B; | |
54 | swap_calls = 0; | |
55 | swap(A, B); | |
56 | VERIFY(1 == swap_calls); | |
57 | } | |
58 | ||
59 | // See c++/13658 for background info. | |
60 | int main() | |
61 | { | |
62 | test01(); | |
63 | test02(); | |
64 | return 0; | |
65 | } |