OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [23_containers/] [multimap/] [modifiers/] [swap.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 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 <map>
20
#include <testsuite_hooks.h>
21
 
22
struct T { int i; };
23
 
24
// T must be LessThanComparable to pass concept-checks
25
bool operator<(T l, T r) { return l.i < r.i; }
26
 
27
int swap_calls;
28
 
29
namespace std
30
{
31
  template<>
32
    void
33
    multimap<T, int>::swap(multimap<T, int>&)
34
    { ++swap_calls; }
35
}
36
 
37
// Should use multimap specialization for swap.
38
void test01()
39
{
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);
46
}
47
 
48
// Should use multimap specialization for swap.
49
void test02()
50
{
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);
58
}
59
 
60
// See c++/13658 for background info.
61
int main()
62
{
63
  test01();
64
  test02();
65
  return 0;
66
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.