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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [20_util/] [functional/] [binders/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2005 Free Software Foundation, Inc.
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
// 20.3.6 Binders
20
 
21
// { dg-do compile }
22
 
23
#include <functional>
24
using namespace std;
25
 
26
struct s
27
{
28
  void f_void_int_const(int) const {}
29
  void f_void_int(int) {}
30
  int f_int_int_const(int) const { return 1; }
31
  int f_int_int(int) {return 1; }
32
  void f_void_void_const() const {}
33
  void f_void_void() {}
34
  int f_int_void_const() const { return 1; }
35
  int f_int_void() { return 1; }
36
};
37
 
38
void test01(s& a)
39
{
40
  mem_fun_t<void, s> p1(&s::f_void_void);
41
  mem_fun_t<int, s> p2(&s::f_int_void);
42
  p1(&a);
43
  p2(&a);
44
  mem_fun1_t<void, s, int> q1(&s::f_void_int);
45
  mem_fun1_t<int, s, int> q2(&s::f_int_int);
46
  q1(&a,0);
47
  q2(&a,0);
48
 
49
  (mem_fun(&s::f_void_void))(&a);
50
  (mem_fun(&s::f_void_int))(&a,0);
51
  (mem_fun(&s::f_int_void))(&a);
52
  (mem_fun(&s::f_int_int))(&a,0);
53
 
54
  mem_fun_ref_t<void, s> ref1(&s::f_void_void);
55
  mem_fun_ref_t<int, s> ref2(&s::f_int_void);
56
 
57
  ref1(a);
58
  ref2(a);
59
 
60
  mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int);
61
  mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int);
62
 
63
  ref3(a,0);
64
  ref4(a,0);
65
 
66
  (mem_fun_ref(&s::f_void_void))(a);
67
  (mem_fun_ref(&s::f_void_int))(a, 0);
68
  (mem_fun_ref(&s::f_int_void))(a);
69
  (mem_fun_ref(&s::f_int_int))(a, 0);
70
}
71
 
72
void test02(const s& a)
73
{
74
  const_mem_fun_t<void, s> p1(&s::f_void_void_const);
75
  const_mem_fun_t<int, s> p2(&s::f_int_void_const);
76
  p1(&a);
77
  p2(&a);
78
  const_mem_fun1_t<void, s, int> q1(&s::f_void_int_const);
79
  const_mem_fun1_t<int, s, int> q2(&s::f_int_int_const);
80
  q1(&a,0);
81
  q2(&a,0);
82
 
83
  (mem_fun(&s::f_void_void_const))(&a);
84
  (mem_fun(&s::f_void_int_const))(&a, 0);
85
  (mem_fun(&s::f_int_void_const))(&a);
86
  (mem_fun(&s::f_int_int_const))(&a, 0);
87
 
88
  const_mem_fun_ref_t<void, s> ref1(&s::f_void_void_const);
89
  const_mem_fun_ref_t<int, s> ref2(&s::f_int_void_const);
90
 
91
  ref1(a);
92
  ref2(a);
93
 
94
  const_mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int_const);
95
  const_mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int_const);
96
 
97
  ref3(a,0);
98
  ref4(a,0);
99
 
100
  (mem_fun_ref(&s::f_void_void_const))(a);
101
  (mem_fun_ref(&s::f_void_int_const))(a, 0);
102
  (mem_fun_ref(&s::f_int_void_const))(a);
103
  (mem_fun_ref(&s::f_int_int_const))(a, 0);
104
}

powered by: WebSVN 2.1.0

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