File: memfunptr.cpp

package info (click to toggle)
stlport4.6 4.6.2-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 7,056 kB
  • ctags: 16,390
  • sloc: ansic: 46,190; cpp: 18,805; sh: 266; asm: 93; perl: 58; makefile: 10
file content (171 lines) | stat: -rw-r--r-- 3,184 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// mem_ptr_fun_test.cpp
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Copyright(c) 2001 Meridian'93
//  http://www.meridian93.com
//  mailto:info@meridian93.com
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// STLport regression testsuite component.
// To compile as a separate example, please #define MAIN.

#include <functional>
#include <memory>

#ifdef MAIN
#define mem_ptr_fun_test main
#endif

#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
using namespace std;
#endif

#if defined(_STLP_DONT_RETURN_VOID) && (defined(_STLP_NO_MEMBER_TEMPLATE_CLASSES) && defined(_STLP_NO_CLASS_PARTIAL_SPECIALIZATION))
#  define _STLP_DONT_TEST_RETURN_VOID
#endif /*_STLP_DONT_RETURN_VOID*/
//else there is no workaround for the return void bug

struct S1 { } s1;
struct S2 { } s2;

int f1(S1&);
int f2(S1&, S2&);
int f1c(const S1&);
int f2c(const S1&, const S2&);

void vf1(S1&);
void vf2(S1&, S2&);
void vf1c(const S1&);
void vf2c(const S1&, const S2&);

class Class {
public:
  int f0();
  int f1(const S1&);

  void vf0();
  void vf1(const S1&);

  int f0c() const;
  int f1c(const S1&) const;

  void vf0c() const;
  void vf1c(const S1&) const;
};

int mem_ptr_fun_test(int, char**)
{
  Class obj;
  const Class& objc = obj;

  // ptr_fun

  ptr_fun(f1)(s1);
  ptr_fun(f2)(s1, s2);

  ptr_fun(f1c)(s1);
  ptr_fun(f2c)(s1, s2);

#ifndef _STLP_DONT_TEST_RETURN_VOID
  ptr_fun(vf1)(s1);
  ptr_fun(vf2)(s1, s2);

  ptr_fun(vf1c)(s1);
  ptr_fun(vf2c)(s1, s2);
#endif /* _STLP_DONT_TEST_RETURN_VOID */

  // mem_fun

  mem_fun(&Class::f0)(&obj);
  mem_fun(&Class::f1)(&obj, s1);

#ifndef _STLP_DONT_TEST_RETURN_VOID
  mem_fun(&Class::vf0)(&obj);
  mem_fun(&Class::vf1)(&obj, s1);
#endif /* _STLP_DONT_TEST_RETURN_VOID */

  // mem_fun (const)

  mem_fun(&Class::f0c)(&objc);
  mem_fun(&Class::f1c)(&objc, s1);

#ifndef _STLP_DONT_TEST_RETURN_VOID
  mem_fun(&Class::vf0c)(&objc);
  mem_fun(&Class::vf1c)(&objc, s1);
#endif /* _STLP_DONT_TEST_RETURN_VOID */

  // mem_fun_ref

  mem_fun_ref(&Class::f0)(obj);
  mem_fun_ref(&Class::f1)(obj, s1);

#ifndef _STLP_DONT_TEST_RETURN_VOID
  mem_fun_ref(&Class::vf0)(obj);
  mem_fun_ref(&Class::vf1)(obj, s1);
#endif /* _STLP_DONT_TEST_RETURN_VOID */

  // mem_fun_ref (const)

  mem_fun_ref(&Class::f0c)(objc);
  mem_fun_ref(&Class::f1c)(objc, s1);

#ifndef _STLP_DONT_TEST_RETURN_VOID
  mem_fun_ref(&Class::vf0c)(objc);
  mem_fun_ref(&Class::vf1c)(objc, s1);
#endif /* _STLP_DONT_TEST_RETURN_VOID */

  return 0;
}

int f1(S1&)
{return 1;}

int f2(S1&, S2&)
{return 2;}

int f1c(const S1&)
{return 1;}

int f2c(const S1&, const S2&)
{return 2;}

void vf1(S1&)
{}

void vf2(S1&, S2&)
{}

void vf1c(const S1&)
{}

void vf2c(const S1&, const S2&)
{}

int Class::f0()
{return 0;}

int Class::f1(const S1&)
{return 1;}

void Class::vf0()
{}

void Class::vf1(const S1&)
{}

int Class::f0c() const
{return 0;}

int Class::f1c(const S1&) const
{return 1;}

void Class::vf0c() const
{}

void Class::vf1c(const S1&) const
{}


#ifdef _STLP_DONT_TEST_RETURN_VOID
#  undef _STLP_DONT_TEST_RETURN_VOID
#endif