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
172
173
174
175
176
177
|
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/local_function
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
# error "variadic macros required"
#else
#include <boost/local_function.hpp>
#include <boost/typeof/typeof.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct s;
BOOST_TYPEOF_REGISTER_TYPE(s) // Register before binding `this_` below.
// Compile all local function declaration combinations.
struct s {
void f(double p = 1.23, double q = -1.23) {
{ // Only params.
void BOOST_LOCAL_FUNCTION(int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(l)
l(1);
}
{ // Only const binds.
int a, b;
const int& BOOST_LOCAL_FUNCTION(const bind a,
const bind& b, const bind& p, const bind q) {
return b;
} BOOST_LOCAL_FUNCTION_NAME(l)
l();
const s& BOOST_LOCAL_FUNCTION(const bind this_) {
return *this_;
} BOOST_LOCAL_FUNCTION_NAME(t)
t();
const int BOOST_LOCAL_FUNCTION(const bind a,
const bind& b, const bind& p, const bind q,
const bind this_) {
return a;
} BOOST_LOCAL_FUNCTION_NAME(lt)
lt();
}
{ // Only plain binds.
int c, d;
int& BOOST_LOCAL_FUNCTION(bind c, bind& d,
bind& p, bind& q) {
return d;
} BOOST_LOCAL_FUNCTION_NAME(l)
l();
s& BOOST_LOCAL_FUNCTION(bind this_) {
return *this_;
} BOOST_LOCAL_FUNCTION_NAME(t)
t();
int BOOST_LOCAL_FUNCTION(bind c, bind& d,
bind& p, bind& q, bind this_) {
return c;
} BOOST_LOCAL_FUNCTION_NAME(lt)
lt();
}
{ // Both params and const binds.
int a, b;
void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
const bind& p, const bind q,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(l)
l(1);
void BOOST_LOCAL_FUNCTION(const bind this_,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(t)
t(1);
void BOOST_LOCAL_FUNCTION(const bind a, const bind this_,
const bind& b, const bind& p, const bind q,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(lt)
lt(1);
}
{ // Both params and plain binds.
int c, d;
void BOOST_LOCAL_FUNCTION(bind c, bind& d, bind& p, bind q,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(l)
l(1);
void BOOST_LOCAL_FUNCTION(bind this_,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(t)
t(1);
void BOOST_LOCAL_FUNCTION(bind c, bind& d,
bind& p, bind this_, bind q,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(lt)
lt(1);
}
{ // Both const and plain binds.
int a, b, c, d;
void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
const bind p, bind c, bind& d, bind q) {
} BOOST_LOCAL_FUNCTION_NAME(l)
l();
void BOOST_LOCAL_FUNCTION(const bind this_,
bind c, bind& d, bind q) {
} BOOST_LOCAL_FUNCTION_NAME(ct)
ct();
void BOOST_LOCAL_FUNCTION(const bind this_,
const bind a, const bind& b, const bind p,
bind c, bind& d, bind q) {
} BOOST_LOCAL_FUNCTION_NAME(lct)
lct();
void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
const bind p, bind this_) {
} BOOST_LOCAL_FUNCTION_NAME(pt)
pt();
void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
const bind p, bind c, bind this_, bind& d, bind q) {
} BOOST_LOCAL_FUNCTION_NAME(lpt)
lpt();
}
{ // All params, const binds, and plain binds.
int a, b, c, d;
void BOOST_LOCAL_FUNCTION(
const bind a, const bind& b, const bind& p,
bind c, bind& d, bind& q, int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(l)
l(1);
void BOOST_LOCAL_FUNCTION(const bind this_,
bind c, bind& d, bind& q,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(ct)
ct(1);
void BOOST_LOCAL_FUNCTION(
const bind a, const bind& b, const bind& p,
bind this_, int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(pt)
pt(1);
void BOOST_LOCAL_FUNCTION(const bind a, const bind this_,
const bind& b, const bind& p, bind c, bind& d,
bind& q, int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(lct)
lct(1);
void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
const bind& p, bind c, bind& d, bind this_, bind& q,
int x, int y, default 0) {
} BOOST_LOCAL_FUNCTION_NAME(lpt)
lpt(1);
}
}
};
int main(void) {
s().f();
return 0;
}
#endif // VARIADIC_MACROS
|