mirror of
https://github.com/boostorg/bind.git
synced 2026-04-13 13:15:50 +02:00
Compare commits
458 Commits
boost-1.30
...
boost-1.88
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a541a8d5c1 | ||
|
|
e027093c53 | ||
|
|
fac72450f2 | ||
|
|
ac4c6f7c7a | ||
|
|
6d11c8931c | ||
|
|
71393b0d28 | ||
|
|
68a9e0db85 | ||
|
|
96e8802169 | ||
|
|
620ddec3ee | ||
|
|
0e7a2373c1 | ||
|
|
5af56ff9f8 | ||
|
|
a902503477 | ||
|
|
c72cc6f914 | ||
|
|
0de59ef498 | ||
|
|
97776ec7ba | ||
|
|
76c1733f47 | ||
|
|
769479a964 | ||
|
|
cb724dcf57 | ||
|
|
b7edec7300 | ||
|
|
8729fbdbfa | ||
|
|
bdc7a9cfc5 | ||
|
|
2e0c546d64 | ||
|
|
c1bdcd3e9b | ||
|
|
da830bc0eb | ||
|
|
e18818ec06 | ||
|
|
9fbfdcb357 | ||
|
|
ece4b221df | ||
|
|
dded373cc7 | ||
|
|
2b9c6151c3 | ||
|
|
9067a41bae | ||
|
|
57ba559ec8 | ||
|
|
e066884190 | ||
|
|
9d6b7fb86e | ||
|
|
dae3bc7e89 | ||
|
|
a4b8f2b6a0 | ||
|
|
b23df0f222 | ||
|
|
3be7521aa2 | ||
|
|
d4614204e5 | ||
|
|
71f21c757f | ||
|
|
3fa518fe9a | ||
|
|
919c5583dd | ||
|
|
ea7f38833f | ||
|
|
b523bc3042 | ||
|
|
46fbb87bbb | ||
|
|
ebc6107bd6 | ||
|
|
9140f3e793 | ||
|
|
42c7177509 | ||
|
|
52d6b7c2fd | ||
|
|
6a73daa5db | ||
|
|
74308ee223 | ||
|
|
6926dbfc51 | ||
|
|
1d123d6432 | ||
|
|
9b9851a887 | ||
|
|
e391ef6d92 | ||
|
|
5b218046dc | ||
|
|
5cef4e4f78 | ||
|
|
506838badd | ||
|
|
1acf70f920 | ||
|
|
58fee45699 | ||
|
|
56ffdf4c9a | ||
|
|
e41138c7d9 | ||
|
|
e728e25376 | ||
|
|
4767d6243d | ||
|
|
5a68a35866 | ||
|
|
021826f2a9 | ||
|
|
3de992d5c0 | ||
|
|
fcaa213721 | ||
|
|
4584bd9e9d | ||
|
|
defcfd175a | ||
|
|
fe3500804f | ||
|
|
8175753863 | ||
|
|
e16c224c85 | ||
|
|
b193ecc1b0 | ||
|
|
732bc0787c | ||
|
|
645d30d455 | ||
|
|
08e5b5831c | ||
|
|
d9b74619b7 | ||
|
|
6892ffa0a3 | ||
|
|
586d4e1fb0 | ||
|
|
186b9c66de | ||
|
|
55d037093b | ||
|
|
8d945a9733 | ||
|
|
a421c908e3 | ||
|
|
41dda10827 | ||
|
|
9a59a15e28 | ||
|
|
395235f3aa | ||
|
|
f1e32ceb6d | ||
|
|
9493eaccad | ||
|
|
cbd61ba5b9 | ||
|
|
fe0ade9c8f | ||
|
|
b9e32ab23e | ||
|
|
0abab115dd | ||
|
|
20908f71e7 | ||
|
|
3a1b8da4b0 | ||
|
|
edc56d8442 | ||
|
|
57d26f5ab3 | ||
|
|
f50916d0e1 | ||
|
|
a5491d988a | ||
|
|
536721c41d | ||
|
|
f75413b14a | ||
|
|
988a8707b4 | ||
|
|
f6026ae53f | ||
|
|
5599f2210f | ||
|
|
24bd5e7e5b | ||
|
|
b0b2ed2814 | ||
|
|
b719777942 | ||
|
|
5b1fe62dbb | ||
|
|
34a3ee580c | ||
|
|
ebc0c07e96 | ||
|
|
12e2ca325d | ||
|
|
1e3efb361b | ||
|
|
bb50844171 | ||
|
|
ee25007a9f | ||
|
|
c85b31e3d2 | ||
|
|
6c84518748 | ||
|
|
725fc8f73f | ||
|
|
a373d662b4 | ||
|
|
df4e0530e8 | ||
|
|
dbd3d09ede | ||
|
|
f50f42aae9 | ||
|
|
d67c22ff44 | ||
|
|
e41ba84da8 | ||
|
|
9ce9a7ce99 | ||
|
|
1aac698358 | ||
|
|
3cbcd02965 | ||
|
|
8cea63f1c9 | ||
|
|
b601e8924d | ||
|
|
c4fc8e5065 | ||
|
|
ba0ca52695 | ||
|
|
24242b037f | ||
|
|
5340508c16 | ||
|
|
cd32792f0e | ||
|
|
fd4aa77824 | ||
|
|
40f38c9fb5 | ||
|
|
3bdf307707 | ||
|
|
e3cf787dff | ||
|
|
e31c1f77e6 | ||
|
|
d521b5198e | ||
|
|
2797f0dc33 | ||
|
|
5612ee45e5 | ||
|
|
2b33c45769 | ||
|
|
3bdf7e313e | ||
|
|
cb49b5adb8 | ||
|
|
eb7ccfc6d6 | ||
|
|
418b01b85d | ||
|
|
ebd86ec558 | ||
|
|
0eb9e9061b | ||
|
|
66ddaf88e1 | ||
|
|
5c21b6a525 | ||
|
|
d6ac20c4fd | ||
|
|
4c263bff9e | ||
|
|
d051c452ea | ||
|
|
b0f3b3fbab | ||
|
|
be7a2d9212 | ||
|
|
c8973a7027 | ||
|
|
f52ef4b659 | ||
|
|
42fe00190e | ||
|
|
9ded210338 | ||
|
|
bce6f5ff79 | ||
|
|
bd22f0e4de | ||
|
|
98fbd87b9e | ||
|
|
791c3a0b1f | ||
|
|
9d4ca0ede4 | ||
|
|
7a4b89856d | ||
|
|
d67200bd2a | ||
|
|
e9b0d46d0f | ||
|
|
070185914d | ||
|
|
59713eab65 | ||
|
|
c2f03d66a0 | ||
|
|
669898bc14 | ||
|
|
436cc4577f | ||
|
|
90aea45e9b | ||
|
|
6b216514d4 | ||
|
|
bf05a29b56 | ||
|
|
f25070d982 | ||
|
|
05a56f08e3 | ||
|
|
ddfaa05ae4 | ||
|
|
f75d27469a | ||
|
|
e1bba7094b | ||
|
|
e939a651c3 | ||
|
|
6fe48ae184 | ||
|
|
e3d5ee50b6 | ||
|
|
1f240d07d6 | ||
|
|
4771d24ad8 | ||
|
|
d6abae3bd6 | ||
|
|
fe1d62dc41 | ||
|
|
734fca6e12 | ||
|
|
2f9ea82c62 | ||
|
|
7273e1d6d0 | ||
|
|
5856dd356b | ||
|
|
ce4df8a666 | ||
|
|
ecc0e72841 | ||
|
|
b51caf1934 | ||
|
|
2a29af7e4f | ||
|
|
2e23da9630 | ||
|
|
6587f1f05d | ||
|
|
60d3e0f4f3 | ||
|
|
b4ff3ca541 | ||
|
|
209bda011d | ||
|
|
1340966709 | ||
|
|
c61026bb81 | ||
|
|
473155eebe | ||
|
|
a1f6206a49 | ||
|
|
03a25d41da | ||
|
|
808996b70f | ||
|
|
3c56630b54 | ||
|
|
494d2fede7 | ||
|
|
2821b51a50 | ||
|
|
6616add21d | ||
|
|
3d957988d0 | ||
|
|
b3e40992ca | ||
|
|
8bca02ab4d | ||
|
|
cea67e705b | ||
|
|
154f70cf7a | ||
|
|
7a2d6aeaf3 | ||
|
|
ad4ac867ce | ||
|
|
42c1323df9 | ||
|
|
36b157c3e8 | ||
|
|
d6e4fab051 | ||
|
|
4d83ab068f | ||
|
|
5500f3363c | ||
|
|
cb7e7f179b | ||
|
|
679ff6b5ba | ||
|
|
8dbd26692f | ||
|
|
21a6662b35 | ||
|
|
41ba1a07c0 | ||
|
|
59b0379969 | ||
|
|
bf402c726c | ||
|
|
5ac488c223 | ||
|
|
4300db5db8 | ||
|
|
017258c983 | ||
|
|
90bd9b1684 | ||
|
|
20a07a05f7 | ||
|
|
8647ccca80 | ||
|
|
5727d4f46e | ||
|
|
da16abf365 | ||
|
|
2ee272fa8d | ||
|
|
92549594f0 | ||
|
|
37a5201a55 | ||
|
|
6bee84b285 | ||
|
|
cf266d22e4 | ||
|
|
12b976939c | ||
|
|
377014f1a4 | ||
|
|
db56733e4e | ||
|
|
6513a8558a | ||
|
|
0dbd9b908d | ||
|
|
150c4e94e3 | ||
|
|
0aca000b8f | ||
|
|
42b5cef177 | ||
|
|
8e54850ab6 | ||
|
|
46c414606c | ||
|
|
b4881265fb | ||
|
|
6f2879927d | ||
|
|
1a6c2ffff3 | ||
|
|
e9f6ccde39 | ||
|
|
6ac4bef225 | ||
|
|
b2eb0a4ae8 | ||
|
|
32060bf523 | ||
|
|
42069e5103 | ||
|
|
7eac98452a | ||
|
|
360ac7c2b4 | ||
|
|
fa5c928e88 | ||
|
|
1feb7dc796 | ||
|
|
ea54c3875d | ||
|
|
b8e4c378b1 | ||
|
|
f199894060 | ||
|
|
53ff21f0f8 | ||
|
|
30921a3889 | ||
|
|
c89afa6aaa | ||
|
|
f91369d163 | ||
|
|
33a19056dc | ||
|
|
41d7508139 | ||
|
|
89d3d468b1 | ||
|
|
29b1a0d6b9 | ||
|
|
f769d97362 | ||
|
|
1480db5679 | ||
|
|
f53694ef25 | ||
|
|
0afd49b884 | ||
|
|
dd67e3f785 | ||
|
|
c92a49d5c2 | ||
|
|
a6b17d9001 | ||
|
|
ea05f23163 | ||
|
|
fafb6bb650 | ||
|
|
f7e101e928 | ||
|
|
166c4b6be7 | ||
|
|
8414233b9c | ||
|
|
15d6d6ac95 | ||
|
|
ba117db120 | ||
|
|
f5c95610b6 | ||
|
|
ce0fc0f69a | ||
|
|
aa8a94273d | ||
|
|
92ff08b873 | ||
|
|
6315df35d6 | ||
|
|
96fd1e7036 | ||
|
|
7ff6524bd1 | ||
|
|
0f66412487 | ||
|
|
af136e483d | ||
|
|
5b2cf44de5 | ||
|
|
5e2fc717f0 | ||
|
|
9955139c65 | ||
|
|
fa8debfc80 | ||
|
|
da3580cc14 | ||
|
|
27003baf12 | ||
|
|
c53ba15ce5 | ||
|
|
3d60d74ff0 | ||
|
|
7b89dd7fd9 | ||
|
|
787d3cb7b4 | ||
|
|
f89c41dc7b | ||
|
|
7aa58cf653 | ||
|
|
6e208277e3 | ||
|
|
1bf8cd6c7a | ||
|
|
e5d99ce085 | ||
|
|
70f0c8efbb | ||
|
|
00b3c895fd | ||
|
|
17282c97c2 | ||
|
|
f02b090fe8 | ||
|
|
f3da835e0b | ||
|
|
8b58b0d207 | ||
|
|
961c3c5fa9 | ||
|
|
73fc778b61 | ||
|
|
c0d14f5e7c | ||
|
|
26ee2825fe | ||
|
|
52d9c13d6e | ||
|
|
a060765e8b | ||
|
|
7e1ad242f9 | ||
|
|
dc1e4dbfae | ||
|
|
a5f729bbeb | ||
|
|
45a1f1434b | ||
|
|
6431906dcc | ||
|
|
18b0dd3e17 | ||
|
|
465899b2ac | ||
|
|
8f507b9aec | ||
|
|
bc50ab0ba3 | ||
|
|
010349ec9b | ||
|
|
8ae9e8460d | ||
|
|
5d49fb45d0 | ||
|
|
4000680b6a | ||
|
|
851903fcc4 | ||
|
|
387e536a0a | ||
|
|
1d79533df7 | ||
|
|
85d146117e | ||
|
|
f09a7a5747 | ||
|
|
0b72bfbd9b | ||
|
|
61519fcae2 | ||
|
|
45720b6f2d | ||
|
|
48c5a6e682 | ||
|
|
1b292ee487 | ||
|
|
0dd5dae4e8 | ||
|
|
e22e641bbf | ||
|
|
203ca82ef2 | ||
|
|
037a4d1976 | ||
|
|
dfd3da2cc4 | ||
|
|
aef08dd0cd | ||
|
|
ef993c777a | ||
|
|
f58543ac11 | ||
|
|
f1afd17717 | ||
|
|
e73f08edee | ||
|
|
224e9f5eec | ||
|
|
1943ac521b | ||
|
|
77d2c4bab1 | ||
|
|
3c24cbedf6 | ||
|
|
41a2e80197 | ||
|
|
79f8680eda | ||
|
|
e163aeb563 | ||
|
|
ce24d4f735 | ||
|
|
9ea5cf40da | ||
|
|
41d9fbc317 | ||
|
|
4d1f7d0411 | ||
|
|
2f595f53f5 | ||
|
|
967e9af0eb | ||
|
|
c746cf26de | ||
|
|
c5396f02c6 | ||
|
|
a695360c4f | ||
|
|
0aadd1805d | ||
|
|
e8646fa260 | ||
|
|
0cc198acc2 | ||
|
|
b272145f3e | ||
|
|
bfe10df38a | ||
|
|
a87638486b | ||
|
|
c69a4ad382 | ||
|
|
683d699e4a | ||
|
|
472f9e6ebe | ||
|
|
d43950f1a6 | ||
|
|
f57cb48b9f | ||
|
|
03bb04bb85 | ||
|
|
bba3d96bda | ||
|
|
cb2cca146f | ||
|
|
3304c00da3 | ||
|
|
3e980f8c34 | ||
|
|
42efa96a2f | ||
|
|
d90c96a7e4 | ||
|
|
d28a5cc23a | ||
|
|
98daeb3ad5 | ||
|
|
35b98458a1 | ||
|
|
2d6ccb09a7 | ||
|
|
a9deb8c577 | ||
|
|
840b39144c | ||
|
|
e5a60bfe1c | ||
|
|
5fbb6558ec | ||
|
|
3b89e4215b | ||
|
|
efc36ff07b | ||
|
|
b85adc3a58 | ||
|
|
0c96dbe3f1 | ||
|
|
2a21f7df2c | ||
|
|
9cfe194f80 | ||
|
|
66ed4fc9e1 | ||
|
|
23b64e1358 | ||
|
|
0aa407e77d | ||
|
|
27d1cf539b | ||
|
|
c7710aad38 | ||
|
|
4a1c4894c7 | ||
|
|
9f0a516068 | ||
|
|
6602068638 | ||
|
|
c25b216898 | ||
|
|
ed817c5b15 | ||
|
|
7b9a97a758 | ||
|
|
b1f05e7268 | ||
|
|
28cb8f8206 | ||
|
|
ccd0394b86 | ||
|
|
ee5ab38a63 | ||
|
|
35a2d208d5 | ||
|
|
424480e55b | ||
|
|
094d43c6e8 | ||
|
|
f01e59b682 | ||
|
|
9ffd0a08c5 | ||
|
|
4e287df40c | ||
|
|
5c53d7db2a | ||
|
|
0904a14c1a | ||
|
|
4377e763a5 | ||
|
|
cc984fad42 | ||
|
|
53c2e449d1 | ||
|
|
74fae199f6 | ||
|
|
4a41a09d27 | ||
|
|
2244135e86 | ||
|
|
807bbfd434 | ||
|
|
6fbbcd0d3c | ||
|
|
21f1171900 | ||
|
|
f8f4029628 | ||
|
|
dbf6e0cf4b | ||
|
|
8f1bb7f13f | ||
|
|
6601553820 | ||
|
|
b6a90777c8 | ||
|
|
ea8c0ef25e | ||
|
|
f91de70d8e | ||
|
|
4b97a70f64 | ||
|
|
7feefb7313 | ||
|
|
46ae046f41 | ||
|
|
673d6b0bf0 | ||
|
|
9ca672c10d | ||
|
|
016a3b8d96 | ||
|
|
6ed01de60f | ||
|
|
5f95e4d9de | ||
|
|
90069948ec | ||
|
|
367728cafe | ||
|
|
4be201beba | ||
|
|
04a438f5f4 | ||
|
|
b06f6a6d89 | ||
|
|
81c8af90ec |
373
.drone.jsonnet
Normal file
373
.drone.jsonnet
Normal file
@@ -0,0 +1,373 @@
|
||||
# Copyright 2022 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
local library = "bind";
|
||||
|
||||
local triggers =
|
||||
{
|
||||
branch: [ "master", "develop", "feature/*" ]
|
||||
};
|
||||
|
||||
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
|
||||
local asan = { ASAN: '1' };
|
||||
|
||||
local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") =
|
||||
{
|
||||
name: name,
|
||||
kind: "pipeline",
|
||||
type: "docker",
|
||||
trigger: triggers,
|
||||
platform:
|
||||
{
|
||||
os: "linux",
|
||||
arch: arch
|
||||
},
|
||||
steps:
|
||||
[
|
||||
{
|
||||
name: "everything",
|
||||
image: image,
|
||||
environment: environment,
|
||||
commands:
|
||||
[
|
||||
'set -e',
|
||||
'uname -a',
|
||||
'echo $DRONE_STAGE_MACHINE',
|
||||
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
|
||||
] +
|
||||
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
|
||||
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
|
||||
[
|
||||
'export LIBRARY=' + library,
|
||||
'./.drone/drone.sh',
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") =
|
||||
{
|
||||
name: name,
|
||||
kind: "pipeline",
|
||||
type: "exec",
|
||||
trigger: triggers,
|
||||
platform: {
|
||||
"os": "darwin",
|
||||
"arch": arch
|
||||
},
|
||||
node: {
|
||||
"os": osx_version
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: "everything",
|
||||
environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" },
|
||||
commands:
|
||||
[
|
||||
'export LIBRARY=' + library,
|
||||
'./.drone/drone.sh',
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
{
|
||||
name: name,
|
||||
kind: "pipeline",
|
||||
type: "docker",
|
||||
trigger: triggers,
|
||||
platform:
|
||||
{
|
||||
os: "windows",
|
||||
arch: arch
|
||||
},
|
||||
"steps":
|
||||
[
|
||||
{
|
||||
name: "everything",
|
||||
image: image,
|
||||
environment: environment,
|
||||
commands:
|
||||
[
|
||||
'cmd /C .drone\\\\drone.bat ' + library,
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
[
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 4.7",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '0x' },
|
||||
"g++-4.7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 4.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '11' },
|
||||
"g++-4.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 4.9",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '11' },
|
||||
"g++-4.9",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 5*",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 6",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '11,14' },
|
||||
"g++-6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 7* 32/64",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 8",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '11,14,17' },
|
||||
"g++-8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 32/64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* ARM64",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
|
||||
arch="arm64",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* S390x",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
|
||||
arch="s390x",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 32/64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '11,14,17,20', ADDRMD: '32,64' },
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 11* 32/64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 32/64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' },
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 13 32 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 13 32 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 13 64 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 14 32 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
"g++-14-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 14 64 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + asan,
|
||||
"g++-14-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 14 32 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan,
|
||||
"g++-14-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 14 64 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan,
|
||||
"g++-14-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.5",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '11,14' },
|
||||
"clang-3.5",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.6",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '11,14' },
|
||||
"clang-3.6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.7",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '11,14' },
|
||||
"clang-3.7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '11,14' },
|
||||
"clang-3.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 13",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-13",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-14",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 15",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-15",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 16",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-16",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 17 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 17 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 18 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"clang-18",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 18 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-18",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.10 Clang 19",
|
||||
"cppalliance/droneubuntu2410:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-19",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2015 msvc-14.0",
|
||||
"cppalliance/dronevs2015",
|
||||
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2017 msvc-14.1",
|
||||
"cppalliance/dronevs2017",
|
||||
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2019 msvc-14.2",
|
||||
"cppalliance/dronevs2019",
|
||||
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2022 msvc-14.3",
|
||||
"cppalliance/dronevs2022:1",
|
||||
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
|
||||
),
|
||||
]
|
||||
23
.drone/drone.bat
Normal file
23
.drone/drone.bat
Normal file
@@ -0,0 +1,23 @@
|
||||
@REM Copyright 2022 Peter Dimov
|
||||
@REM Distributed under the Boost Software License, Version 1.0.
|
||||
@REM https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
@ECHO ON
|
||||
|
||||
set LIBRARY=%1
|
||||
set DRONE_BUILD_DIR=%CD%
|
||||
|
||||
set BOOST_BRANCH=develop
|
||||
if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init tools/boostdep
|
||||
xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\
|
||||
python tools/boostdep/depinst/depinst.py %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
25
.drone/drone.sh
Executable file
25
.drone/drone.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2022 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
set -ex
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
DRONE_BUILD_DIR=$(pwd)
|
||||
|
||||
BOOST_BRANCH=develop
|
||||
if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init tools/boostdep
|
||||
cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
640
.github/workflows/ci.yml
vendored
Normal file
640
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,640 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "11"
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-4.8
|
||||
- toolset: gcc-5
|
||||
cxxstd: "11,14,1z"
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "11,14,1z"
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: g++-7
|
||||
- toolset: gcc-8
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
- toolset: gcc-12
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: g++-12
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-13
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-14
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "11,14"
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "11,14"
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "11,14,1z"
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-15
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-18
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.10
|
||||
os: ubuntu-latest
|
||||
install: clang-19
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
container:
|
||||
image: ${{matrix.container}}
|
||||
volumes:
|
||||
- /node20217:/node20217:rw,rshared
|
||||
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python3 git g++ curl xz-utils
|
||||
|
||||
- name: Install nodejs20glibc2.17
|
||||
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
|
||||
run: |
|
||||
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
|
||||
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
|
||||
ldd /__e/node20/bin/node
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
posix-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
windows-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Use library with add_subdirectory (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use library with add_subdirectory (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
|
||||
- name: Install (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Debug
|
||||
|
||||
- name: Install (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
- name: Use the installed library (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use the installed library (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests --config Debug
|
||||
|
||||
- name: Run tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Build tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests --config Release
|
||||
|
||||
- name: Run tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
361
.travis.yml
Normal file
361
.travis.yml
Normal file
@@ -0,0 +1,361 @@
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_TEST=1
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=bind ..
|
||||
- ctest --output-on-failure -R boost_bind
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
install:
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
|
||||
script:
|
||||
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- cmake ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_INSTALL_TEST=1
|
||||
script:
|
||||
- pip install --user cmake
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=bind -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build . --target install
|
||||
- cd ../libs/bind/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/boostdep
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/bind
|
||||
- python tools/boostdep/depinst/depinst.py bind
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/bind/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
27
CMakeLists.txt
Normal file
27
CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
# Generated by `boostdep --cmake bind`
|
||||
# Copyright 2020, 2021 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.8...3.20)
|
||||
|
||||
project(boost_bind VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_bind INTERFACE)
|
||||
add_library(Boost::bind ALIAS boost_bind)
|
||||
|
||||
target_include_directories(boost_bind INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_bind
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::core
|
||||
)
|
||||
|
||||
target_compile_features(boost_bind INTERFACE cxx_std_11)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
6
README.md
Normal file
6
README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Boost.Bind
|
||||
|
||||
Branch | Travis | Appveyor
|
||||
---------|--------|---------
|
||||
Develop | [](https://travis-ci.org/boostorg/bind) | [](https://ci.appveyor.com/project/pdimov/bind)
|
||||
Master | [](https://travis-ci.org/boostorg/bind) | [](https://ci.appveyor.com/project/pdimov/bind)
|
||||
59
appveyor.yml
Normal file
59
appveyor.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
# Copyright 2016-2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1,clang-win
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/boostdep
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\bind\
|
||||
- python tools/boostdep/depinst/depinst.py bind
|
||||
- cmd /c bootstrap
|
||||
- b2 -d0 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/bind/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
889
bind.html
889
bind.html
@@ -1,865 +1,28 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: bind.hpp documentation</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%" bgColor="white">
|
||||
<table width="100%" border="0">
|
||||
<tr>
|
||||
<td width="277"><IMG height="86" alt="c++boost.gif (8819 bytes)" src="../../c++boost.gif" width="277">
|
||||
</td>
|
||||
<td align="middle">
|
||||
<h1>bind.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colSpan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Contents</h2>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Purpose">Purpose</A></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_functions">Using bind with functions and
|
||||
function pointers</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_function_objects">Using bind with function
|
||||
objects</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_member_pointers">Using bind with pointers
|
||||
to members</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#nested_binds">Using nested binds for function
|
||||
composition</A></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Examples">Examples</A></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_algorithms">Using bind with standard
|
||||
algorithms</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_boost_function">Using bind with
|
||||
Boost.Function</A></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Limitations">Limitations</A></h3>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#FAQ">Frequently Asked Questions</A></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_doesnt_compile">Why doesn't this compile?</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_does_compile">Why does this compile? It
|
||||
should not.</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_forms">What is the difference between bind(f,
|
||||
...) and bind<R>(f, ...)?</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_win32_api">Does <b>bind</b> work with Windows
|
||||
API functions?</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_com">Does <b>bind</b> work with COM methods?</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_mac">Does <b>bind</b> work with Mac toolbox
|
||||
functions?</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_extern_C">Does <b>bind</b> work with extern
|
||||
"C" functions?</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_auto_stdcall">Why doesn't <b>bind</b> automatically
|
||||
recognize nonstandard functions?</A></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Troubleshooting">Troubleshooting</A></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_num_args">Incorrect number of arguments</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_signature">The function object cannot be
|
||||
called with the specified arguments</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_arg_access">Accessing an argument that does
|
||||
not exist</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_short_form">Inappropriate use of bind(f,
|
||||
...)</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_long_form">Inappropriate use of
|
||||
bind<R>(f, ...)</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_nonstd">Binding a nonstandard function</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_const_arg"><b>const</b> in signatures</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
|
||||
boost::bind;</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_class_template">MSVC specific: class
|
||||
templates shadow function templates</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_ellipsis">MSVC specific: ... in
|
||||
signatures treated as type</A></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Interface">Interface</A></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Synopsis">Synopsis</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#CommonRequirements">Common requirements</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#CommonDefinitions">Common definitions</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#bind">bind</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#AdditionalOverloads">Additional overloads</A></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Implementation">Implementation</A></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Files">Files</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Dependencies">Dependencies</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#NumberOfArguments">Number of Arguments</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#stdcall">"__stdcall", "__fastcall", and
|
||||
"pascal" Support</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#visit_each"><b>visit_each</b> support</A></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Acknowledgements">Acknowledgements</A></h3>
|
||||
<h2><a name="Purpose">Purpose</a></h2>
|
||||
<p><b>boost::bind</b> is a generalization of the standard functions <b>std::bind1st</b>
|
||||
and <b>std::bind2nd</b>. It supports arbitrary function objects, functions,
|
||||
function pointers, and member function pointers, and is able to bind any
|
||||
argument to a specific value or route input arguments into arbitrary positions. <b>bind</b>
|
||||
does not place any requirements on the function object; in particular, it does
|
||||
not need the <b>result_type</b>, <b>first_argument_type</b> and <b>second_argument_type</b>
|
||||
standard typedefs.
|
||||
</p>
|
||||
<h3><a name="with_functions">Using bind with functions and function pointers</a></h3>
|
||||
<p>Given these definitions:
|
||||
</p>
|
||||
<pre>int f(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int g(int a, int b, int c)
|
||||
{
|
||||
return a + b + c;
|
||||
}
|
||||
</pre>
|
||||
<p><tt>bind(f, 1, 2)</tt> will produce a "nullary" function object that takes no
|
||||
arguments and returns <tt>f(1, 2)</tt>. Similarly, <tt>bind(g, 1, 2, 3)()</tt> is
|
||||
equivalent to <tt>g(1, 2, 3)</tt>.
|
||||
</p>
|
||||
<p>It is possible to selectively bind only some of the arguments. <tt>bind(f, _1, 5)(x)</tt>
|
||||
is equivalent to <tt>f(x, 5)</tt>; here <b>_1</b>
|
||||
is a placeholder argument that means "substitute with the first input
|
||||
argument."
|
||||
<p>For comparison, here is the same operation expressed with the standard library
|
||||
primitives:
|
||||
</p>
|
||||
<pre>std::bind2nd(std::ptr_fun(f), 5)(x);
|
||||
</pre>
|
||||
<p><b>bind</b> covers the functionality of <b>std::bind1st</b> as well:
|
||||
</p>
|
||||
<pre>std::bind1st(std::ptr_fun(f), 5)(x); // f(5, x)
|
||||
bind(f, 5, _1)(x); // f(5, x)
|
||||
</pre>
|
||||
<p><b>bind</b> can handle functions with more than two arguments, and its argument
|
||||
substitution mechanism is more general:
|
||||
</p>
|
||||
<pre>bind(f, _2, _1)(x, y); // f(y, x)
|
||||
|
||||
bind(g, _1, 9, _1)(x); // g(x, 9, x)
|
||||
|
||||
bind(g, _3, _3, _3)(x, y, z); // g(z, z, z)
|
||||
|
||||
bind(g, _1, _1, _1)(x, y, z); // g(x, x, x)
|
||||
</pre>
|
||||
<p>Note that, in the last example, the function object produced by <tt>bind(g, _1, _1,
|
||||
_1)</tt> does not contain references to any arguments beyond the first, but
|
||||
it can still be used with more than one argument. Any extra arguments are
|
||||
silently ignored, just like the first and the second argument are ignored in
|
||||
the third example.
|
||||
</p>
|
||||
<p>The arguments that <b>bind</b> takes are copied and held internally by the
|
||||
returned function object. For example, in the following code:
|
||||
</p>
|
||||
<pre>int i = 5;
|
||||
|
||||
bind(f, i, _1);
|
||||
</pre>
|
||||
<p>a copy of the value of <b>i</b> is stored into the function object. <A href="ref.html">
|
||||
boost::ref</A> and <A href="ref.html">boost::cref</A> can be used to make
|
||||
the function object store a reference to an object, rather than a copy:
|
||||
</p>
|
||||
<pre>int i = 5;
|
||||
|
||||
bind(f, ref(i), _1);
|
||||
</pre>
|
||||
<h3><a name="with_function_objects">Using bind with function objects</a></h3>
|
||||
<p><b>bind</b> is not limited to functions; it accepts arbitrary function objects.
|
||||
In the general case, the return type of the generated function object's <b>operator()</b>
|
||||
has to be specified explicitly (without a <b>typeof</b> operator the return
|
||||
type cannot be inferred):
|
||||
</p>
|
||||
<pre>struct F
|
||||
{
|
||||
int operator()(int a, int b) { return a - b; }
|
||||
bool operator()(long a, long b) { return a == b; }
|
||||
};
|
||||
|
||||
F f;
|
||||
|
||||
int x = 104;
|
||||
|
||||
bind<int>(f, _1, _1)(x); // f(x, x), i.e. zero
|
||||
</pre>
|
||||
<p>Some compilers have trouble with the <tt>bind<R>(f, ...)</tt> syntax. For
|
||||
portability reasons, an alternative way to express the above is supported:</p>
|
||||
<pre>boost::bind(boost::type<int>(), f, _1, _1)(x);
|
||||
</pre>
|
||||
<P>Note, however, that the alternative syntax is provided only as a workaround. It
|
||||
is not part of the interface.</P>
|
||||
<P>When the function object exposes a nested type named <b>result_type</b>, the
|
||||
explicit return type can be omitted:
|
||||
</P>
|
||||
<pre>int x = 8;
|
||||
|
||||
bind(std::less<int>(), _1, 9)(x); // x < 9
|
||||
</pre>
|
||||
<p>[Note: the ability to omit the return type is not available on all compilers.]
|
||||
</p>
|
||||
<h3><a name="with_member_pointers">Using bind with pointers to members</a></h3>
|
||||
<p>Pointers to member functions and pointers to data members are not function
|
||||
objects, because they do not support <tt>operator()</tt>. For convenience, <b>bind</b>
|
||||
accepts member pointers as its first argument, and the behavior is as if <A href="mem_fn.html">
|
||||
boost::mem_fn</A> has been used to convert the member pointer into a
|
||||
function object. In other words, the expression
|
||||
</p>
|
||||
<pre>bind(&X::f, <i>args</I>)
|
||||
</pre>
|
||||
<p>is equivalent to
|
||||
</p>
|
||||
<pre>bind<R>(<A href="mem_fn.html" >mem_fn</A>(&X::f), <i>args</I>)
|
||||
</pre>
|
||||
<p>where <b>R</b> is the return type of <b>X::f</b> (for member functions) or a
|
||||
const reference to the type of the member (for data members.)
|
||||
</p>
|
||||
<p>[Note: <b>mem_fn</b> creates function objects that are able to accept a pointer,
|
||||
a reference, or a smart pointer to an object as its first argument; for
|
||||
additional information, see the <b>mem_fn</b> <A href="mem_fn.html">documentation</A>.]
|
||||
</p>
|
||||
<p>Example:
|
||||
</p>
|
||||
<pre>struct X
|
||||
{
|
||||
bool f(int a);
|
||||
};
|
||||
|
||||
X x;
|
||||
|
||||
shared_ptr<X> p(new X);
|
||||
|
||||
int i = 5;
|
||||
|
||||
bind(&X::f, ref(x), _1)(i); // x.f(i)
|
||||
bind(&X::f, &x, _1)(i); //(&x)->f(i)
|
||||
bind(&X::f, x, _1)(i); // (<i>internal copy of x</I>).f(i)
|
||||
bind(&X::f, p, _1)(i); // (<i>internal copy of p</I>)->f(i)
|
||||
</pre>
|
||||
<p>The last two examples are interesting in that they produce "self-contained"
|
||||
function objects. <tt>bind(&X::f, x, _1)</tt> stores a copy of <b>x</b>. <tt>bind(&X::f,
|
||||
p, _1)</tt> stores a copy of <b>p</b>, and since <b>p</b> is a <A href="../smart_ptr/shared_ptr.htm">
|
||||
boost::shared_ptr</A>, the function object retains a reference to its
|
||||
instance of <b>X</b> and will remain valid even when <b>p</b> goes out of scope
|
||||
or is <b>reset()</b>.
|
||||
</p>
|
||||
<h3><a name="nested_binds">Using nested binds for function composition</a></h3>
|
||||
<p>Some of the arguments passed to <b>bind</b> may be nested <b>bind</b> expressions
|
||||
themselves:
|
||||
</p>
|
||||
<pre>bind(f, bind(g, _1))(x); // f(g(x))
|
||||
</pre>
|
||||
<p>The inner <STRONG>bind</STRONG> expressions are evaluated, in unspecified order,
|
||||
before the outer <STRONG>bind</STRONG> when the function object is called; the
|
||||
results of the evaluation are then substituted in their place when the outer <STRONG>
|
||||
bind</STRONG> is evaluated. In the example above, when the function object
|
||||
is called with the argument list <tt>(x)</tt>, <tt>bind(g, _1)(x)</tt> is
|
||||
evaluated first, yielding <tt>g(x)</tt>, and then <tt>bind(f, g(x))(x)</tt> is
|
||||
evaluated, yielding the final result <tt>f(g(x))</tt>.
|
||||
</p>
|
||||
<P>This feature of <b>bind</b> can be used to perform function composition. See <A href="bind_as_compose.cpp">
|
||||
bind_as_compose.cpp</A> for an example that demonstrates how to use <b>bind</b>
|
||||
to achieve similar functionality to <A href="../compose/index.htm">Boost.Compose</A>.
|
||||
</P>
|
||||
<p>Note that the first argument - the bound function object - is not evaluated,
|
||||
even when it's a function object that is produced by <STRONG>bind</STRONG> or a
|
||||
placeholder argument, so the example below does not work as expected:
|
||||
</p>
|
||||
<pre>typedef void (*pf)(int);
|
||||
|
||||
std::vector<pf> v;
|
||||
|
||||
std::for_each(v.begin(), v.end(), bind(_1, 5));
|
||||
</pre>
|
||||
<p>The desired effect can be achieved via a helper function object <STRONG>apply</STRONG>
|
||||
that applies its first argument, as a function object, to the rest of its
|
||||
argument list. For convenience, an implementation of <STRONG>apply</STRONG> is
|
||||
provided in the <STRONG>boost/bind/apply.hpp</STRONG> header file. Here is how
|
||||
the modified version of the previous example looks like:
|
||||
</p>
|
||||
<pre>typedef void (*pf)(int);
|
||||
|
||||
std::vector<pf> v;
|
||||
|
||||
std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));
|
||||
</pre>
|
||||
<P>Sometimes it is necessary not to evaluate the first argument, but <STRONG>not</STRONG>
|
||||
to evaluate some of the other arguments, even when they are nested <STRONG>bind</STRONG>
|
||||
subexpressions. This can be achieved with the help of another function object, <STRONG>
|
||||
protect</STRONG>, that masks the type so that <STRONG>bind</STRONG> does
|
||||
not recognize and evaluate it. When called, <STRONG>protect</STRONG> simply
|
||||
forwards the argument list to the other function object unmodified.</P>
|
||||
<P>The header <STRONG>boost/bind/protect.hpp</STRONG> contains an implementation of <STRONG>
|
||||
protect</STRONG>. To protect a <STRONG>bind</STRONG> function object from
|
||||
evaluation, use <tt>protect(bind(f, ...))</tt>.</P>
|
||||
<h2><a name="Examples">Examples</a></h2>
|
||||
<h3><a name="with_algorithms">Using bind with standard algorithms</a></h3>
|
||||
<pre>class image;
|
||||
|
||||
class animation
|
||||
{
|
||||
public:
|
||||
|
||||
void advance(int ms);
|
||||
bool inactive() const;
|
||||
void render(image & target) const;
|
||||
};
|
||||
|
||||
std::vector<animation> anims;
|
||||
|
||||
template<class C, class P> void erase_if(C & c, P pred)
|
||||
{
|
||||
c.erase(std::remove_if(c.begin(), c.end(), pred), c.end());
|
||||
}
|
||||
|
||||
void update(int ms)
|
||||
{
|
||||
std::for_each(anims.begin(), anims.end(), boost::bind(&animation::advance, _1, ms));
|
||||
erase_if(anims, boost::mem_fn(&animation::inactive));
|
||||
}
|
||||
|
||||
void render(image & target)
|
||||
{
|
||||
std::for_each(anims.begin(), anims.end(), boost::bind(&animation::render, _1, boost::ref(target)));
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="with_boost_function">Using bind with Boost.Function</a></h3>
|
||||
<pre>class button
|
||||
{
|
||||
public:
|
||||
|
||||
<A href="../function/index.html" >boost::function</A><void> onClick;
|
||||
};
|
||||
|
||||
class player
|
||||
{
|
||||
public:
|
||||
|
||||
void play();
|
||||
void stop();
|
||||
};
|
||||
|
||||
button playButton, stopButton;
|
||||
player thePlayer;
|
||||
|
||||
void connect()
|
||||
{
|
||||
playButton.onClick = boost::bind(&player::play, &thePlayer);
|
||||
stopButton.onClick = boost::bind(&player::stop, &thePlayer);
|
||||
}
|
||||
</pre>
|
||||
<h2><a name="Limitations">Limitations</a></h2>
|
||||
<p>The function objects generated by <b>bind</b> take their arguments by reference
|
||||
and cannot, therefore, accept non-const temporaries or literal constants. This
|
||||
is an inherent limitation of the C++ language, known as <A href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
|
||||
the forwarding problem</A>.</p>
|
||||
<p>The library uses signatures of the form
|
||||
</p>
|
||||
<pre>template<class T> void f(T & t);
|
||||
</pre>
|
||||
<p>to accept arguments of arbitrary types and pass them on unmodified. As noted,
|
||||
this does not work with non-const r-values.
|
||||
</p>
|
||||
<p>An oft-proposed "solution" to this problem is to add an overload:
|
||||
</p>
|
||||
<pre>template<class T> void f(T & t);
|
||||
template<class T> void f(T const & t);
|
||||
</pre>
|
||||
<p>Unfortunately, this (a) requires providing 512 overloads for nine arguments and
|
||||
(b) does not actually work for const arguments, both l- and r-values, since the
|
||||
two templates produce the exact same signature and cannot be partially ordered.
|
||||
</p>
|
||||
<p>[Note: this is a dark corner of the language, and the <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#214">
|
||||
corresponding issue</a> has not been resolved yet.]
|
||||
</p>
|
||||
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
|
||||
<h3><a name="Q_doesnt_compile">Why doesn't this compile?</a></h3>
|
||||
<p>See the <A href="#Troubleshooting">dedicated Troubleshooting section</A>.</p>
|
||||
<h3><a name="Q_does_compile">Why does this compile? It should not.</a></h3>
|
||||
<p>Probably because you used the general <tt>bind<R>(f, ...)</tt> syntax,
|
||||
thereby instructing <b>bind</b> to not "inspect" <b>f</b> to detect arity and
|
||||
return type errors.</p>
|
||||
<h3><a name="Q_forms">What is the difference between bind(f, ...) and bind<R>(f,
|
||||
...)?</a></h3>
|
||||
<p>The first form instructs <b>bind</b> to inspect the type of <b>f</b> in order to
|
||||
determine its arity (number of arguments) and return type. Arity errors will be
|
||||
detected at "bind time". This syntax, of course, places some requirements on <b>f</b>.
|
||||
It must be a function, function pointer, member function pointer, or a function
|
||||
object that defines a nested type named <b>result_type</b>; in short, it must
|
||||
be something that <b>bind</b> can recognize.</p>
|
||||
<p>The second form instructs <b>bind</b> to <b>not</b> attempt to recognize the
|
||||
type of <b>f</b>. It is generally used with function objects that do not, or
|
||||
cannot, expose <b>result_type</b>, but it can also be used with nonstandard
|
||||
functions. For example, the current implementation does not automatically
|
||||
recognize variable-argument functions like <b>printf</b>, so you will have to
|
||||
use <tt>bind<int>(printf, ...)</tt>. Note that an alternative <tt>bind(type<R>(),
|
||||
f, ...)</tt> syntax is supported for portability reasons.</p>
|
||||
<p>Another important factor to consider is that compilers without partial template
|
||||
specialization or function template partial ordering support cannot handle the
|
||||
first form when <b>f</b> is a function object, and in most cases will not
|
||||
handle the second form when <b>f</b> is a function (pointer) or a member
|
||||
function pointer.</p>
|
||||
<h3><a name="Q_win32_api">Does <b>bind</b> work with Windows API functions?</a></h3>
|
||||
<p>Yes, if you <A href="#stdcall">#define BOOST_BIND_ENABLE_STDCALL</A>. An
|
||||
alternative is to treat the function as a <A href="#with_function_objects">generic
|
||||
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
||||
<h3><a name="Q_com">Does <b>bind</b> work with COM methods?</a></h3>
|
||||
<p>Yes, if you <A href="#stdcall">#define BOOST_MEM_FN_ENABLE_STDCALL</A>.</p>
|
||||
<h3><a name="Q_mac">Does <b>bind</b> work with Mac toolbox functions?</a></h3>
|
||||
<p>Yes, if you <A href="#stdcall">#define BOOST_BIND_ENABLE_PASCAL</A>. An
|
||||
alternative is to treat the function as a <A href="#with_function_objects">generic
|
||||
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
||||
<h3><a name="Q_extern_C">Does <b>bind</b> work with extern "C" functions?</a></h3>
|
||||
<p>Sometimes. On some platforms, pointers to extern "C" functions are equivalent to
|
||||
"ordinary" function pointers, so they work fine. Other platforms treat them as
|
||||
different types. A platform-specific implementation of <b>bind</b> is expected
|
||||
to handle the problem transparently; this implementation does not. As usual,
|
||||
the workaround is to treat the function as a <A href="#with_function_objects">generic
|
||||
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
||||
<h3><a name="Q_auto_stdcall">Why doesn't <b>bind</b> automatically recognize
|
||||
nonstandard functions?</a></h3>
|
||||
<p>Non-portable extensions, in general, should default to off to prevent vendor
|
||||
lock-in. Had the <A href="#stdcall">appropriate macros</A> been defined
|
||||
automatically, you could have accidentally taken advantage of them without
|
||||
realizing that your code is, perhaps, no longer portable. In addition, some
|
||||
compilers have the option to make <b>__stdcall</b> (<STRONG>__fastcall</STRONG>)
|
||||
their default calling convention, in which case no separate support would be
|
||||
necessary.</p>
|
||||
<h2><a name="Troubleshooting">Troubleshooting</a></h2>
|
||||
<h3><a name="err_num_args">Incorrect number of arguments</a></h3>
|
||||
<p>In a <tt>bind(f, a1, a2, ..., aN)</tt> expression, the function object <b>f</b> must
|
||||
be able to take exactly <b>N</b> arguments. This error is normally detected at
|
||||
"bind time"; in other words, the compilation error is reported on the line
|
||||
where bind() is invoked:</p>
|
||||
<pre>int f(int, int);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, 1); // error, f takes two arguments
|
||||
boost::bind(f, 1, 2); // OK
|
||||
}
|
||||
</pre>
|
||||
<p>A common variation of this error is to forget that member functions have an
|
||||
implicit "this" argument:</p>
|
||||
<pre>struct X
|
||||
{
|
||||
int f(int);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(&X::f, 1); // error, X::f takes two arguments
|
||||
boost::bind(&X::f, <b>_1</B>, 1); // OK
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="err_signature">The function object cannot be called with the specified
|
||||
arguments</a></h3>
|
||||
<p>As in normal function calls, the function object that is bound must be
|
||||
compatible with the argument list. The incompatibility will usually be detected
|
||||
by the compiler at "call time" and the result is typically an error in <b>bind.hpp</b>
|
||||
on a line that looks like:</p>
|
||||
<pre> return f(a[a1_], a[a2_]);
|
||||
</pre>
|
||||
<p>An example of this kind of error:</p>
|
||||
<pre>int f(int);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, "incompatible"); // OK so far, no call
|
||||
boost::bind(f, "incompatible")(); // error, "incompatible" is not an int
|
||||
boost::bind(f, _1); // OK
|
||||
boost::bind(f, _1)("incompatible"); // error, "incompatible" is not an int
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="err_arg_access">Accessing an argument that does not exist</a></h3>
|
||||
<p>The placeholder <b>_N</b> selects the argument at position <b>N</b> from the
|
||||
argument list passed at "call time." Naturally, it is an error to attempt to
|
||||
access beyond the end of this list:</p>
|
||||
<pre>int f(int);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, _1); // OK
|
||||
boost::bind(f, _1)(); // error, there is no argument number 1
|
||||
}
|
||||
</pre>
|
||||
<p>The error is usually reported in <b>bind.hpp</b>, at a line similar to:</p>
|
||||
<pre> return f(a[a1_]);
|
||||
</pre>
|
||||
<p>When emulating <tt>std::bind1st(f, a)</tt>, a common mistake of this category is
|
||||
to type <tt>bind(f, a, _2)</tt> instead of the correct <tt>bind(f, a, _1)</tt>.</p>
|
||||
<h3><a name="err_short_form">Inappropriate use of bind(f, ...)</a></h3>
|
||||
<p>The <tt>bind(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> causes
|
||||
automatic recognition of the type of <b>f</b>. It will not work with arbitrary
|
||||
function objects; <b>f</b> must be a function or a member function pointer.</p>
|
||||
<p>It is possible to use this form with function objects that define <b>result_type</b>,
|
||||
but <b>only on compilers</b> that support partial specialization and partial
|
||||
ordering. In particular, MSVC up to version 7.0 does not support this syntax
|
||||
for function objects.</p>
|
||||
<h3><a name="err_long_form">Inappropriate use of bind<R>(f, ...)</a></h3>
|
||||
<p>The <tt>bind<R>(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> supports
|
||||
arbitrary function objects.</p>
|
||||
<p>It is possible (but not recommended) to use this form with functions or member
|
||||
function pointers, but <b>only on compilers</b> that support partial ordering.
|
||||
In particular, MSVC up to version 7.0 does not fully support this syntax for
|
||||
functions and member function pointers.</p>
|
||||
<h3><a name="err_nonstd">Binding a nonstandard function</a></h3>
|
||||
<p>By default, the <tt>bind(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> recognizes
|
||||
"ordinary" C++ functions and function pointers. <A href="#stdcall">Functions that
|
||||
use a different calling convention</A>, or variable-argument functions such
|
||||
as <STRONG>std::printf</STRONG>, do not work. The general <tt>bind<R>(f, a1,
|
||||
a2, ..., aN)</tt> <A href="#Q_forms">form</A> works with nonstandard
|
||||
functions.
|
||||
</p>
|
||||
<p>On some platforms, extern "C" functions, like <b>std::strcmp</b>, are not
|
||||
recognized by the short form of bind.
|
||||
</p>
|
||||
<P>See also <A href="#stdcall">"__stdcall" and "pascal" Support</A>.</P>
|
||||
<h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
|
||||
<p>Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the
|
||||
top-level <b>const</b> in function signatures:
|
||||
</p>
|
||||
<pre>int f(int const);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, 1); // error
|
||||
}
|
||||
</pre>
|
||||
<p>Workaround: remove the <b>const</b> qualifier from the argument.
|
||||
</p>
|
||||
<h3><a name="err_msvc_using">MSVC specific: using boost::bind;</a></h3>
|
||||
<p>On MSVC (up to version 7.0), when <b>boost::bind</b> is brought into scope with
|
||||
an using declaration:
|
||||
</p>
|
||||
<pre>using boost::bind;
|
||||
</pre>
|
||||
<p>the syntax <tt>bind<R>(f, ...)</tt> does not work. Workaround: either use
|
||||
the qualified name, <b>boost::bind</b>, or use an using directive instead:
|
||||
</p>
|
||||
<pre>using namespace boost;
|
||||
</pre>
|
||||
<h3><a name="err_msvc_class_template">MSVC specific: class templates shadow function
|
||||
templates</a></h3>
|
||||
<p>On MSVC (up to version 7.0), a nested class template named <b>bind</b> will
|
||||
shadow the function template <b>boost::bind</b>, breaking the <tt>bind<R>(f,
|
||||
...)</tt> syntax. Unfortunately, some libraries contain nested class
|
||||
templates named <b>bind</b> (ironically, such code is often an MSVC specific
|
||||
workaround.)</p>
|
||||
<P>The workaround is to use the alternative <tt>bind(type<R>(), f, ...)</tt> syntax.</P>
|
||||
<h3><a name="err_msvc_ellipsis">MSVC specific: ... in signatures treated as type</a></h3>
|
||||
<p>MSVC (up to version 7.0) treats the ellipsis in a variable argument function
|
||||
(such as <b>std::printf</b>) as a type. Therefore, it will accept the
|
||||
(incorrect in the current implementation) form:
|
||||
</p>
|
||||
<pre> bind(printf, "%s\n", _1);
|
||||
</pre>
|
||||
<p>and will reject the correct version:
|
||||
</p>
|
||||
<pre> bind<int>(printf, "%s\n", _1);
|
||||
</pre>
|
||||
<h2><a name="Interface">Interface</a></h2>
|
||||
<h3><a name="Synopsis">Synopsis</a></h3>
|
||||
<pre>namespace boost
|
||||
{
|
||||
|
||||
// no arguments
|
||||
|
||||
template<class R, class F> <i>unspecified-1</I> <A href="#bind_1" >bind</A>(F f);
|
||||
|
||||
template<class F> <i>unspecified-1-1</I> <A href="#bind_1_1" >bind</A>(F f);
|
||||
|
||||
template<class R> <i>unspecified-2</I> <A href="#bind_2" >bind</A>(R (*f) ());
|
||||
|
||||
// one argument
|
||||
|
||||
template<class R, class F, class A1> <i>unspecified-3</I> <A href="#bind_3" >bind</A>(F f, A1 a1);
|
||||
|
||||
template<class F, class A1> <i>unspecified-3-1</I> <A href="#bind_3_1" >bind</A>(F f, A1 a1);
|
||||
|
||||
template<class R, class B1, class A1> <i>unspecified-4</I> <A href="#bind_4" >bind</A>(R (*f) (B1), A1 a1);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-5</I> <A href="#bind_5" >bind</A>(R (T::*f) (), A1 a1);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-6</I> <A href="#bind_6" >bind</A>(R (T::*f) () const, A1 a1);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-6-1</I> <A href="#bind_6_1" >bind</A>(R T::*f, A1 a1);
|
||||
|
||||
// two arguments
|
||||
|
||||
template<class R, class F, class A1, class A2> <i>unspecified-7</I> <A href="#bind_7" >bind</A>(F f, A1 a1, A2 a2);
|
||||
|
||||
template<class F, class A1, class A2> <i>unspecified-7-1</I> <A href="#bind_7_1" >bind</A>(F f, A1 a1, A2 a2);
|
||||
|
||||
template<class R, class B1, class B2, class A1, class A2> <i>unspecified-8</I> <A href="#bind_8" >bind</A>(R (*f) (B1, B2), A1 a1, A2 a2);
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> <i>unspecified-9</I> <A href="#bind_9" >bind</A>(R (T::*f) (B1), A1 a1, A2 a2);
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> <i>unspecified-10</I> <A href="#bind_10" >bind</A>(R (T::*f) (B1) const, A1 a1, A2 a2);
|
||||
|
||||
// implementation defined number of additional overloads for more arguments
|
||||
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
<i>unspecified-placeholder-type-1</I> _1;
|
||||
|
||||
<i>unspecified-placeholder-type-2</I> _2;
|
||||
|
||||
<i>unspecified-placeholder-type-3</I> _3;
|
||||
|
||||
// implementation defined number of additional placeholder definitions
|
||||
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="CommonRequirements">Common requirements</a></h3>
|
||||
<p>All <tt><i>unspecified-N</i></tt> types returned by <b>bind</b> are <b>CopyConstructible</b>.
|
||||
<tt><i>unspecified-N</i>::result_type</tt> is defined as the return type of <tt><i>unspecified-N</i>::operator()</tt>.</p>
|
||||
<p>All <tt><i>unspecified-placeholder-N</i></tt> types are <b>CopyConstructible</b>.
|
||||
Their copy constructors do not throw exceptions.</p>
|
||||
<h3><a name="CommonDefinitions">Common definitions</a></h3>
|
||||
<p>The function µ(x, v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), where m is
|
||||
a nonnegative integer, is defined as:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<tt>x.get()</tt>, when <tt>x</tt> is of type <tt><A href="ref.html">boost::reference_wrapper</A><T></tt>
|
||||
for some type <tt>T</tt>;
|
||||
<li>
|
||||
v<sub>k</sub>, when <tt>x</tt>
|
||||
is (a copy of) the placeholder _k for some positive integer k;
|
||||
<li>
|
||||
<tt>x(v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>)</tt> when <tt>x</tt> is
|
||||
(a copy of) a function object returned by <b>bind</b>;
|
||||
<li>
|
||||
<tt>x</tt> otherwise.</li></ul>
|
||||
<h3><a name="bind">bind</a></h3>
|
||||
<h4><a name="bind_1">template<class R, class F> <i>unspecified-1</i> bind(F f)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>()</tt>,
|
||||
implicitly converted to <b>R</b>.</p>
|
||||
<p><b>Throws:</b> Nothing unless the copy constructor of <b>F</b> throws an
|
||||
exception.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_1_1">template<class F> <i>unspecified-1-1</i> bind(F f)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F>(f);</tt></p>
|
||||
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
||||
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_2">template<class R> <i>unspecified-2</i> bind(R (*f) ())</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>()</tt>.</p>
|
||||
<p><b>Throws:</b> Nothing.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_3">template<class R, class F, class A1> <i>unspecified-3</i> bind(F
|
||||
f, A1 a1)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>, implicitly
|
||||
converted to <b>R</b>.</p>
|
||||
<p><b>Throws:</b> Nothing unless the copy constructors of <b>F</b> or <b>A1</b> throw
|
||||
an exception.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_3_1">template<class F, class A1> <i>unspecified-3-1</i> bind(F
|
||||
f, A1 a1)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F, A1>(f, a1);</tt></p>
|
||||
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
||||
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_4">template<class R, class B1, class A1> <i>unspecified-4</i> bind(R
|
||||
(*f) (B1), A1 a1)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.</p>
|
||||
<p><b>Throws:</b> Nothing unless the copy constructor of <b>A1</b> throws an
|
||||
exception.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_5">template<class R, class T, class A1> <i>unspecified-5</i> bind(R
|
||||
(T::*f) (), A1 a1)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||
a1);</tt></p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_6">template<class R, class T, class A1> <i>unspecified-6</i> bind(R
|
||||
(T::*f) () const, A1 a1)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||
a1);</tt></p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_6_1">template<class R, class T, class A1> <i>unspecified-6-1</i>
|
||||
bind(R T::*f, A1 a1)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<R const &>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||
a1);</tt></p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_7">template<class R, class F, class A1, class A2> <i>unspecified-7</i>
|
||||
bind(F f, A1 a1, A2 a2)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), µ(<b>a2</b>, v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>))</tt>, implicitly converted to <b>R</b>.</p>
|
||||
<p><b>Throws:</b> Nothing unless the copy constructors of <b>F</b>, <b>A1</b> or <b>A2</b>
|
||||
throw an exception.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_7_1">template<class F, class A1, class A2> <i>unspecified-7-1</i>
|
||||
bind(F f, A1 a1, A2 a2)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F, A1, A2>(f,
|
||||
a1, a2);</tt></p>
|
||||
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
||||
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_8">template<class R, class B1, class B2, class A1, class A2> <i>unspecified-8</i>
|
||||
bind(R (*f) (B1, B2), A1 a1, A2 a2)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), µ(<b>a2</b>, v<sub>1</sub>,
|
||||
v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.</p>
|
||||
<p><b>Throws:</b> Nothing unless the copy constructors of <b>A1</b> or <b>A2</b> throw
|
||||
an exception.</p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_9">template<class R, class T, class B1, class A1, class A2> <i>unspecified-9</i>
|
||||
bind(R (T::*f) (B1), A1 a1, A2 a2)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||
a1, a2);</tt></p>
|
||||
</blockquote>
|
||||
<h4><a name="bind_10">template<class R, class T, class B1, class A1, class A2> <i>unspecified-10</i>
|
||||
bind(R (T::*f) (B1) const, A1 a1, A2 a2)</a></h4>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||
a1, a2);</tt></p>
|
||||
</blockquote>
|
||||
<h3><a name="AdditionalOverloads">Additional overloads</a></h3>
|
||||
<p>Implementations are allowed to provide additional <b>bind</b> overloads in order
|
||||
to support more arguments or different function pointer variations.</p>
|
||||
<h2><a name="Implementation">Implementation</a></h2>
|
||||
<h3><a name="Files">Files</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<A href="../../boost/bind.hpp">boost/bind.hpp</A>
|
||||
(main header)
|
||||
<li>
|
||||
<A href="../../boost/bind/bind_cc.hpp">boost/bind/bind_cc.hpp</A>
|
||||
(used by bind.hpp, do not include directly)
|
||||
<li>
|
||||
<A href="../../boost/bind/bind_mf_cc.hpp">boost/bind/bind_mf_cc.hpp</A>
|
||||
(used by bind.hpp, do not include directly)
|
||||
<li>
|
||||
<A href="../../boost/bind/bind_template.hpp">boost/bind/bind_template.hpp</A>
|
||||
(used by bind.hpp, do not include directly)
|
||||
<LI>
|
||||
<A href="../../boost/bind/arg.hpp">boost/bind/arg.hpp</A>
|
||||
(defines the type of the placeholder arguments)
|
||||
<LI>
|
||||
<A href="../../boost/bind/placeholders.hpp">boost/bind/placeholders.hpp</A>
|
||||
(defines the _1, _2, ... _9 placeholders)
|
||||
<LI>
|
||||
<A href="../../boost/bind/apply.hpp">boost/bind/apply.hpp</A> (<STRONG>apply</STRONG>
|
||||
helper function object)
|
||||
<LI>
|
||||
<A href="../../boost/bind/protect.hpp">boost/bind/protect.hpp</A> (<STRONG>protect</STRONG>
|
||||
helper function)
|
||||
<LI>
|
||||
<A href="../../boost/bind/make_adaptable.hpp">boost/bind/make_adaptable.hpp</A>
|
||||
(<STRONG>make_adaptable</STRONG>
|
||||
helper function)
|
||||
<li>
|
||||
<A href="test/bind_test.cpp">libs/bind/test/bind_test.cpp</A>
|
||||
(test)
|
||||
<li>
|
||||
<A href="bind_as_compose.cpp">libs/bind/bind_as_compose.cpp</A>
|
||||
(function composition example)
|
||||
<li>
|
||||
<A href="bind_visitor.cpp">libs/bind/bind_visitor.cpp</A>
|
||||
(visitor example)
|
||||
<li>
|
||||
<A href="test/bind_stdcall_test.cpp">libs/bind/test/bind_stdcall_test.cpp</A>
|
||||
(test with __stdcall functions)
|
||||
<li>
|
||||
<A href="test/bind_stdcall_mf_test.cpp">libs/bind/test/bind_stdcall_mf_test.cpp</A>
|
||||
(test with __stdcall member functions)
|
||||
<li>
|
||||
<A href="test/bind_fastcall_test.cpp">libs/bind/test/bind_fastcall_test.cpp</A>
|
||||
(test with __fastcall functions)
|
||||
<li>
|
||||
<A href="test/bind_fastcall_mf_test.cpp">libs/bind/test/bind_fastcall_mf_test.cpp</A>
|
||||
(test with __fastcall member functions)</li></ul>
|
||||
<h3><a name="Dependencies">Dependencies</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<A href="../config/config.htm">Boost.Config</A></li>
|
||||
<li>
|
||||
<A href="ref.html">boost/ref.hpp</A></li>
|
||||
<li>
|
||||
<A href="mem_fn.html">boost/mem_fn.hpp</A></li>
|
||||
<li>
|
||||
<A href="../../boost/type.hpp">boost/type.hpp</A></li>
|
||||
</ul>
|
||||
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
|
||||
<p>This implementation supports function objects with up to nine arguments. This is
|
||||
an implementation detail, not an inherent limitation of the design.</p>
|
||||
<h3><a name="stdcall">"__stdcall", "__fastcall", and "pascal" Support</a></h3>
|
||||
<p>Some platforms allow several types of (member) functions that differ by their <b>calling
|
||||
convention</b> (the rules by which the function is invoked: how are
|
||||
arguments passed, how is the return value handled, and who cleans up the stack
|
||||
- if any.)</p>
|
||||
<p>For example, Windows API functions and COM interface member functions use a
|
||||
calling convention known as <b>__stdcall</b>.Borland VCL components use <STRONG>__fastcall</STRONG>.
|
||||
Mac toolbox functions use a <b>pascal</b> calling convention.</p>
|
||||
<p>To use <b>bind</b> with <b>__stdcall</b> functions, <b>#define</b> the macro <b>BOOST_BIND_ENABLE_STDCALL</b>
|
||||
before including <b><boost/bind.hpp></b>.</p>
|
||||
<p>To use <b>bind</b> with <b>__stdcall</b> <b>member</b> functions, <b>#define</b>
|
||||
the macro <b>BOOST_MEM_FN_ENABLE_STDCALL</b> before including <b><boost/bind.hpp></b>.</p>
|
||||
<P>To use <B>bind</B> with <B>__fastcall</B> functions, <B>#define</B> the macro <B>BOOST_BIND_ENABLE_FASTCALL</B>
|
||||
before including <B><boost/bind.hpp></B>.</P>
|
||||
<P>To use <B>bind</B> with <B>__fastcall</B> <B>member</B> functions, <B>#define</B>
|
||||
the macro <B>BOOST_MEM_FN_ENABLE_FASTCALL</B> before including <B><boost/bind.hpp></B>.</P>
|
||||
<P>To use <b>bind</b> with <b>pascal</b> functions, <b>#define</b> the macro <b>BOOST_BIND_ENABLE_PASCAL</b>
|
||||
before including <b><boost/bind.hpp></b>.</P>
|
||||
<p>[Note: this is a non-portable extension. It is not part of the interface.]</p>
|
||||
<p>[Note: Some compilers provide only minimal support for the <b>__stdcall</b> keyword.]</p>
|
||||
<h3><a name="visit_each"><b>visit_each</b> support</a></h3>
|
||||
<p>Function objects returned by <b>bind</b> support the experimental and
|
||||
undocumented, as of yet, <b>visit_each</b> enumeration interface.</p>
|
||||
<p>See <A href="bind_visitor.cpp">bind_visitor.cpp</A> for an example.</p>
|
||||
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
|
||||
<p>Earlier efforts that have influenced the library design:</p>
|
||||
<ul>
|
||||
<li>
|
||||
The <a href="http://staff.cs.utu.fi/BL/">Binder Library</a>
|
||||
by Jaakko Järvi;
|
||||
<li>
|
||||
The <a href="../lambda/">Lambda Library</a> (now part of Boost)
|
||||
by Jaakko Järvi and Gary Powell (the successor to the Binder Library);
|
||||
<li>
|
||||
<a href="http://matfys.lth.se/~petter/src/more/stlext/index.html">Extensions to the
|
||||
STL</a> by Petter Urkedal.</li></ul>
|
||||
<p>Doug Gregor suggested that a visitor mechanism would allow <b>bind</b> to
|
||||
interoperate with a signal/slot library.</p>
|
||||
<p>John Maddock fixed a MSVC-specific conflict between <b>bind</b> and the <A href="../type_traits/index.htm">
|
||||
type traits library</A>.</p>
|
||||
<p>Numerous improvements were suggested during the formal review period by Ross
|
||||
Smith, Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was
|
||||
Darin Adler.
|
||||
</p>
|
||||
<p>The precise semantics of <b>bind</b> were refined in discussions with Jaakko
|
||||
Järvi.
|
||||
</p>
|
||||
<p>Dave Abrahams fixed a MSVC-specific conflict between <b>bind</b> and the <A href="../utility/iterator_adaptors.htm">
|
||||
iterator adaptors library</A>.
|
||||
</p>
|
||||
<p>Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns on
|
||||
deficient compilers.
|
||||
</p>
|
||||
<p>Mac Murrett contributed the "pascal" support enabled by
|
||||
BOOST_BIND_ENABLE_PASCAL.
|
||||
</p>
|
||||
<p>The alternative <tt>bind(type<R>(), f, ...)</tt> syntax was inspired by a
|
||||
discussion with Dave Abrahams and Joel de Guzman.</p>
|
||||
<p><br>
|
||||
<br>
|
||||
<br>
|
||||
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Permission to
|
||||
copy, use, modify, sell and distribute this document is granted provided this
|
||||
copyright notice appears in all copies. This document is provided "as is"
|
||||
without express or implied warranty, and with no claim as to its suitability
|
||||
for any purpose.</small></p>
|
||||
</body>
|
||||
<head>
|
||||
<title>Boost.Bind</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="refresh" content="0; url=doc/html/bind.html">
|
||||
<style>
|
||||
body {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
a {
|
||||
color: #00f;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="doc/html/bind.html">doc/html/bind.html</a>
|
||||
</p>
|
||||
<p>
|
||||
© 2001, 2002 Peter Dimov and Multi Media Ltd.<br>
|
||||
© 2003-2008 Peter Dimov
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
@@ -12,16 +14,17 @@
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
std::string f(std::string const & x)
|
||||
{
|
||||
return "f(" + x + ")";
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
@@ -10,52 +12,30 @@
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <typeinfo>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
using namespace boost::placeholders;
|
||||
|
||||
// default implementation of visit_each
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<class V, class T> void visit_each(V & v, T const & t, long)
|
||||
{
|
||||
v(t, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// visitor
|
||||
|
||||
int hash = 0;
|
||||
//
|
||||
|
||||
struct visitor
|
||||
{
|
||||
template<class T> void operator()(boost::reference_wrapper<T> const & r, int) const
|
||||
template<class T> void operator()( boost::reference_wrapper<T> const & r ) const
|
||||
{
|
||||
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
|
||||
hash += r.get();
|
||||
}
|
||||
|
||||
template<class T> void operator()(T const &, long) const
|
||||
template<class T> void operator()( T const & t ) const
|
||||
{
|
||||
std::cout << "Value of type " << typeid(T).name() << '\n';
|
||||
++hash;
|
||||
std::cout << "Value of type " << typeid(T).name() << " (with value " << t << ")\n";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -69,26 +49,10 @@ int f(int & i, int & j, int)
|
||||
int x = 2;
|
||||
int y = 7;
|
||||
|
||||
int detect_errors(bool x)
|
||||
{
|
||||
if(x)
|
||||
{
|
||||
std::cerr << "no errors detected.\n";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "test failed.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
visitor v;
|
||||
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
||||
|
||||
return detect_errors(hash == 12);
|
||||
}
|
||||
|
||||
21
build.jam
Normal file
21
build.jam
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2023-2024 René Ferdinand Rivera Morell
|
||||
# Copyright 2024 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/config//boost_config
|
||||
/boost/core//boost_core
|
||||
;
|
||||
|
||||
project /boost/bind ;
|
||||
|
||||
explicit
|
||||
[ alias boost_bind : : : : <include>include <library>$(boost_dependencies) ]
|
||||
[ alias all : boost_bind test ]
|
||||
;
|
||||
|
||||
call-if : boost-library bind
|
||||
;
|
||||
58
doc/Jamfile.v2
Normal file
58
doc/Jamfile.v2
Normal file
@@ -0,0 +1,58 @@
|
||||
# Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
|
||||
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import boostbook ;
|
||||
import quickbook ;
|
||||
|
||||
xml bind_ : bind.qbk ;
|
||||
boostbook standalone_bind
|
||||
:
|
||||
bind_
|
||||
:
|
||||
<xsl:param>boost.root=../../../..
|
||||
# File name of HTML output:
|
||||
<xsl:param>root.filename=bind
|
||||
# How far down we chunk nested sections, basically all of them:
|
||||
<xsl:param>chunk.section.depth=0
|
||||
# Don't put the first section on the same page as the TOC:
|
||||
<xsl:param>chunk.first.sections=0
|
||||
# How far down sections get TOC's
|
||||
<xsl:param>toc.section.depth=2
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=2
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=0
|
||||
|
||||
<xsl:param>generate.manifest=0
|
||||
;
|
||||
|
||||
xml mem_fn_ : mem_fn.qbk ;
|
||||
boostbook standalone_mem_fn
|
||||
:
|
||||
mem_fn_
|
||||
:
|
||||
<xsl:param>boost.root=../../../..
|
||||
# File name of HTML output:
|
||||
<xsl:param>root.filename=mem_fn
|
||||
# How far down we chunk nested sections, basically all of them:
|
||||
<xsl:param>chunk.section.depth=0
|
||||
# Don't put the first section on the same page as the TOC:
|
||||
<xsl:param>chunk.first.sections=0
|
||||
# How far down sections get TOC's
|
||||
<xsl:param>toc.section.depth=2
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=2
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=0
|
||||
|
||||
<xsl:param>generate.manifest=0
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : standalone_bind standalone_mem_fn ;
|
||||
explicit boostrelease ;
|
||||
35
doc/bind.qbk
Normal file
35
doc/bind.qbk
Normal file
@@ -0,0 +1,35 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[library Boost.Bind
|
||||
[quickbook 1.6]
|
||||
[id bind]
|
||||
[copyright 2001, 2002 Peter Dimov and Multi Media Ltd.]
|
||||
[copyright 2003-2008 Peter Dimov]
|
||||
[dirname bind]
|
||||
[license Distributed under the
|
||||
[@http://boost.org/LICENSE_1_0.txt Boost Software License,
|
||||
Version 1.0].
|
||||
]
|
||||
]
|
||||
|
||||
[template simplesect[title]
|
||||
[block '''<simplesect><title>'''[title]'''</title>''']]
|
||||
|
||||
[template endsimplesect[]
|
||||
[block '''</simplesect>''']]
|
||||
|
||||
[include bind/purpose.qbk]
|
||||
[include bind/examples.qbk]
|
||||
[include bind/limitations.qbk]
|
||||
[include bind/faq.qbk]
|
||||
[include bind/troubleshooting.qbk]
|
||||
[include bind/interface.qbk]
|
||||
[include bind/implementation.qbk]
|
||||
[include bind/acknowledgements.qbk]
|
||||
48
doc/bind/acknowledgements.qbk
Normal file
48
doc/bind/acknowledgements.qbk
Normal file
@@ -0,0 +1,48 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:acknowledgements Acknowledgements]
|
||||
|
||||
Earlier efforts that have influenced the library design:
|
||||
|
||||
* The [@http://staff.cs.utu.fi/BL/ Binder Library] by Jaakko J\u00E4rvi;
|
||||
|
||||
* The [@boost:/libs/lambda/index.html Lambda Library] (now part of Boost) by
|
||||
Jaakko J\u00E4rvi and Gary Powell (the successor to the Binder Library);
|
||||
|
||||
* [@http://more.sourceforge.net/ Extensions to the STL] by Petter Urkedal.
|
||||
|
||||
Doug Gregor suggested that a visitor mechanism would allow `bind` to
|
||||
interoperate with a signal/slot library.
|
||||
|
||||
John Maddock fixed a MSVC-specific conflict between `bind` and the
|
||||
[@boost:/libs/type_traits/index.html type traits library].
|
||||
|
||||
Numerous improvements were suggested during the formal review period by Ross
|
||||
Smith, Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was
|
||||
Darin Adler.
|
||||
|
||||
The precise semantics of `bind` were refined in discussions with Jaakko
|
||||
J\u00E4rvi.
|
||||
|
||||
Dave Abrahams fixed a MSVC-specific conflict between `bind` and the
|
||||
[@boost:/libs/utility/iterator_adaptors.htm iterator adaptors library].
|
||||
|
||||
Dave Abrahams modified `bind` and `mem_fn` to support `void` returns on
|
||||
deficient compilers.
|
||||
|
||||
Mac Murrett contributed the "pascal" support enabled by
|
||||
`BOOST_BIND_ENABLE_PASCAL`.
|
||||
|
||||
The alternative `bind(type<R>(), f, ...)` syntax was inspired by a discussion
|
||||
with Dave Abrahams and Joel de Guzman.
|
||||
|
||||
This documentation was ported to Quickbook by Agustín Bergé.
|
||||
|
||||
[endsect]
|
||||
70
doc/bind/examples.qbk
Normal file
70
doc/bind/examples.qbk
Normal file
@@ -0,0 +1,70 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:examples Examples]
|
||||
|
||||
[section Using bind with standard algorithms]
|
||||
|
||||
class image;
|
||||
|
||||
class animation
|
||||
{
|
||||
public:
|
||||
void advance(int ms);
|
||||
bool inactive() const;
|
||||
void render(image & target) const;
|
||||
};
|
||||
|
||||
std::vector<animation> anims;
|
||||
|
||||
template<class C, class P> void erase_if(C & c, P pred)
|
||||
{
|
||||
c.erase(std::remove_if(c.begin(), c.end(), pred), c.end());
|
||||
}
|
||||
|
||||
void update(int ms)
|
||||
{
|
||||
std::for_each(anims.begin(), anims.end(), boost::bind(&animation::advance, _1, ms));
|
||||
erase_if(anims, boost::mem_fn(&animation::inactive));
|
||||
}
|
||||
|
||||
void render(image & target)
|
||||
{
|
||||
std::for_each(anims.begin(), anims.end(), boost::bind(&animation::render, _1, boost::ref(target)));
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Using bind with Boost.Function]
|
||||
|
||||
class button
|
||||
{
|
||||
public:
|
||||
``[@boost:/libs/function/index.html `boost::function`]``<void()> onClick;
|
||||
};
|
||||
|
||||
class player
|
||||
{
|
||||
public:
|
||||
void play();
|
||||
void stop();
|
||||
};
|
||||
|
||||
button playButton, stopButton;
|
||||
player thePlayer;
|
||||
|
||||
void connect()
|
||||
{
|
||||
playButton.onClick = boost::bind(&player::play, &thePlayer);
|
||||
stopButton.onClick = boost::bind(&player::stop, &thePlayer);
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
99
doc/bind/faq.qbk
Normal file
99
doc/bind/faq.qbk
Normal file
@@ -0,0 +1,99 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:faq Frequently Asked Questions]
|
||||
|
||||
[section Why doesn't this compile?]
|
||||
|
||||
See the dedicated [link bind.troubleshooting Troubleshooting section].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Why does this compile? It should not.]
|
||||
|
||||
Probably because you used the general `bind<R>(f, ...)` syntax, thereby
|
||||
instructing `bind` to not "inspect" f to detect arity and return type errors.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:Q_forms What is the difference between `bind(f, ...)` and `bind<R>(f, ...)`?]
|
||||
|
||||
The first form instructs `bind` to inspect the type of `f` in order to
|
||||
determine its arity (number of arguments) and return type. Arity errors will
|
||||
be detected at "bind time". This syntax, of course, places some requirements
|
||||
on `f`. It must be a function, function pointer, member function pointer, or a
|
||||
function object that defines a nested type named `result_type`; in short, it
|
||||
must be something that `bind` can recognize.
|
||||
|
||||
The second form instructs `bind` to not attempt to recognize the type of `f`.
|
||||
It is generally used with function objects that do not, or cannot, expose
|
||||
`result_type`, but it can also be used with nonstandard functions. For example,
|
||||
the current implementation does not automatically recognize variable-argument
|
||||
functions like `printf`, so you will have to use `bind<int>(printf, ...)`.
|
||||
Note that an alternative `bind(type<R>(), f, ...)` syntax is supported for
|
||||
portability reasons.
|
||||
|
||||
Another important factor to consider is that compilers without partial
|
||||
template specialization or function template partial ordering support cannot
|
||||
handle the first form when `f` is a function object, and in most cases will
|
||||
not handle the second form when `f` is a function (pointer) or a member
|
||||
function pointer.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Does bind work with Windows API functions?]
|
||||
|
||||
Yes, if you [link bind.implementation.stdcall `#define
|
||||
BOOST_BIND_ENABLE_STDCALL`]. An alternative is to treat the function as a
|
||||
[link bind.purpose.with_function_objects generic function object] and use the
|
||||
`bind<R>(f, ...)` syntax.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Does bind work with COM methods?]
|
||||
|
||||
Yes, if you [link bind.implementation.stdcall `#define
|
||||
BOOST_MEM_FN_ENABLE_STDCALL`].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Does bind work with Mac toolbox functions?]
|
||||
|
||||
Yes, if you [link bind.implementation.stdcall `#define
|
||||
BOOST_BIND_ENABLE_PASCAL`]. An alternative is to treat the function as a [link
|
||||
bind.purpose.with_function_objects generic function object] and use the
|
||||
`bind<R>(f, ...)` syntax.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Does bind work with extern "C" functions?]
|
||||
|
||||
Sometimes. On some platforms, pointers to extern "C" functions are equivalent
|
||||
to "ordinary" function pointers, so they work fine. Other platforms treat them
|
||||
as different types. A platform-specific implementation of `bind` is expected
|
||||
to handle the problem transparently; this implementation does not. As usual,
|
||||
the workaround is to treat the function as a [link
|
||||
bind.purpose.with_function_objects generic function object] and use the
|
||||
`bind<R>(f, ...)` syntax.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Why doesn't bind automatically recognize nonstandard functions?]
|
||||
|
||||
Non-portable extensions, in general, should default to off to prevent vendor
|
||||
lock-in. Had the [link bind.implementation.stdcall appropriate macros] been
|
||||
defined automatically, you could have accidentally taken advantage of them
|
||||
without realizing that your code is, perhaps, no longer portable. In addition,
|
||||
some compilers have the option to make `__stdcall` (`__fastcall`) their
|
||||
default calling convention, in which case no separate support would be
|
||||
necessary.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
98
doc/bind/implementation.qbk
Normal file
98
doc/bind/implementation.qbk
Normal file
@@ -0,0 +1,98 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:implementation Implementation]
|
||||
|
||||
[section Files]
|
||||
|
||||
* [@../../../../boost/bind/bind.hpp boost/bind/bind.hpp] (main header)
|
||||
* [@../../../../boost/bind/bind_cc.hpp boost/bind/bind_cc.hpp] (used by `bind.hpp`, do not include directly)
|
||||
* [@../../../../boost/bind/bind_mf_cc.hpp boost/bind/bind_mf_cc.hpp] (used by `bind.hpp`, do not include directly)
|
||||
* [@../../../../boost/bind/bind_template.hpp boost/bind/bind_template.hpp] (used by `bind.hpp`, do not include directly)
|
||||
* [@../../../../boost/bind/arg.hpp boost/bind/arg.hpp] (defines the type of the placeholder arguments)
|
||||
* [@../../../../boost/bind/placeholders.hpp boost/bind/placeholders.hpp] (defines the `_1`, `_2`, ... `_9` placeholders)
|
||||
* [@../../../../boost/bind/apply.hpp boost/bind/apply.hpp] (`apply` helper function object)
|
||||
* [@../../../../boost/bind/protect.hpp boost/bind/protect.hpp] (`protect` helper function)
|
||||
* [@../../../../boost/bind/make_adaptable.hpp boost/bind/make_adaptable.hpp] (`make_adaptable` helper function)
|
||||
* [@../../test/bind_test.cpp libs/bind/test/bind_test.cpp] (test)
|
||||
* [@../../bind_as_compose.cpp libs/bind/bind_as_compose.cpp] (function composition example)
|
||||
* [@../../bind_visitor.cpp libs/bind/bind_visitor.cpp] (visitor example)
|
||||
* [@../../test/bind_stdcall_test.cpp libs/bind/test/bind_stdcall_test.cpp] (test with `__stdcall` functions)
|
||||
* [@../../test/bind_stdcall_mf_test.cpp libs/bind/test/bind_stdcall_mf_test.cpp] (test with `__stdcall` member functions)
|
||||
* [@../../test/bind_fastcall_test.cpp libs/bind/test/bind_fastcall_test.] (test with `__fastcall` functions)
|
||||
* [@../../test/bind_fastcall_mf_test.cpp libs/bind/test/bind_fastcall_mf_test.cpp] (test with `__fastcall` member functions)
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Dependencies]
|
||||
|
||||
* [@boost:/libs/config/config.htm Boost.Config]
|
||||
* [@boost:/libs/core/doc/html/core/ref.html boost/ref.hpp]
|
||||
* [@boost:/libs/bind/mem_fn.html boost/mem_fn.hpp]
|
||||
* [@boost:/boost/type.hpp boost/type.hpp]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Number of Arguments]
|
||||
|
||||
This implementation supports function objects with up to nine arguments. This
|
||||
is an implementation detail, not an inherent limitation of the design.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:stdcall `__stdcall`, `__cdecl`, `__fastcall`, and `pascal` Support]
|
||||
|
||||
Some platforms allow several types of (member) functions that differ by their
|
||||
calling convention (the rules by which the function is invoked: how are
|
||||
arguments passed, how is the return value handled, and who cleans up the stack
|
||||
- if any.)
|
||||
|
||||
For example, Windows API functions and COM interface member functions use a
|
||||
calling convention known as `__stdcall`. Borland VCL components use
|
||||
`__fastcall`. Mac toolbox functions use a `pascal` calling convention.
|
||||
|
||||
To use `bind` with `__stdcall` functions, `#define` the macro
|
||||
`BOOST_BIND_ENABLE_STDCALL` before including `<boost/bind/bind.hpp>`.
|
||||
|
||||
To use `bind` with `__stdcall` member functions, `#define` the macro
|
||||
`BOOST_MEM_FN_ENABLE_STDCALL` before including `<boost/bind/bind.hpp>`.
|
||||
|
||||
To use `bind` with `__fastcall` functions, `#define` the macro
|
||||
`BOOST_BIND_ENABLE_FASTCALL` before including `<boost/bind/bind.hpp>`.
|
||||
|
||||
To use `bind` with `__fastcall` member functions, `#define` the macro
|
||||
`BOOST_MEM_FN_ENABLE_FASTCALL` before including `<boost/bind/bind.hpp>`.
|
||||
|
||||
To use `bind` with `pascal` functions, `#define` the macro
|
||||
`BOOST_BIND_ENABLE_PASCAL` before including `<boost/bind/bind.hpp>`.
|
||||
|
||||
To use `bind` with `__cdecl` member functions, `#define` the macro
|
||||
`BOOST_MEM_FN_ENABLE_CDECL` before including `<boost/bind/bind.hpp>`.
|
||||
|
||||
[*It is best to define these macros in the project options, via `-D` on the
|
||||
command line, or as the first line in the translation unit (.cpp file) where
|
||||
`bind` is used.] Not following this rule can lead to obscure errors when a
|
||||
header includes `bind.hpp` before the macro has been defined.
|
||||
|
||||
/[Note:/ this is a non-portable extension. It is not part of the interface./]/
|
||||
|
||||
/[Note:/ Some compilers provide only minimal support for the `__stdcall` keyword./]/
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `visit_each` support]
|
||||
|
||||
Function objects returned by `bind` support the experimental and undocumented,
|
||||
as of yet, `visit_each` enumeration interface.
|
||||
|
||||
See [@../../bind_visitor.cpp bind_visitor.cpp] for an example.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
216
doc/bind/interface.qbk
Normal file
216
doc/bind/interface.qbk
Normal file
@@ -0,0 +1,216 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:interface Interface]
|
||||
|
||||
[section:synopsys Synopsis]
|
||||
|
||||
namespace boost
|
||||
{
|
||||
// no arguments
|
||||
|
||||
template<class R, class F> ``/unspecified-1/`` ``[link bind_1 `bind`]``(F f);
|
||||
|
||||
template<class F> ``/unspecified-1-1/`` ``[link bind_1_1 `bind`]``(F f);
|
||||
|
||||
template<class R> ``/unspecified-2/`` ``[link bind_2 `bind`]``(R (*f) ());
|
||||
|
||||
// one argument
|
||||
|
||||
template<class R, class F, class A1> ``/unspecified-3/`` ``[link bind_3 `bind`]``(F f, A1 a1);
|
||||
|
||||
template<class F, class A1> ``/unspecified-3-1/`` ``[link bind_3_1 `bind`]``(F f, A1 a1);
|
||||
|
||||
template<class R, class B1, class A1> ``/unspecified-4/`` ``[link bind_4 `bind`]``(R (*f) (B1), A1 a1);
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-5/`` ``[link bind_5 `bind`]``(R (T::*f) (), A1 a1);
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-6/`` ``[link bind_6 `bind`]``(R (T::*f) () const, A1 a1);
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-6-1/`` ``[link bind_6_1 `bind`]``(R T::*f, A1 a1);
|
||||
|
||||
// two arguments
|
||||
|
||||
template<class R, class F, class A1, class A2> ``/unspecified-7/`` ``[link bind_7 `bind`]``(F f, A1 a1, A2 a2);
|
||||
|
||||
template<class F, class A1, class A2> ``/unspecified-7-1/`` ``[link bind_7_1 `bind`]``(F f, A1 a1, A2 a2);
|
||||
|
||||
template<class R, class B1, class B2, class A1, class A2> ``/unspecified-8/`` ``[link bind_8 `bind`]``(R (*f) (B1, B2), A1 a1, A2 a2);
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> ``/unspecified-9/`` ``[link bind_9 `bind`]``(R (T::*f) (B1), A1 a1, A2 a2);
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> ``/unspecified-10/`` ``[link bind_10 `bind`]``(R (T::*f) (B1) const, A1 a1, A2 a2);
|
||||
|
||||
// implementation defined number of additional overloads for more arguments
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
``/unspecified-placeholder-type-1/`` _1;
|
||||
|
||||
``/unspecified-placeholder-type-2/`` _2;
|
||||
|
||||
``/unspecified-placeholder-type-3/`` _3;
|
||||
|
||||
// implementation defined number of additional placeholder definitions
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Common requirements]
|
||||
|
||||
All /unspecified-N/ types returned by `bind` are /CopyConstructible/. /unspecified-N/`::result_type` is defined as the return type of /unspecified-N/`::operator()`.
|
||||
|
||||
All /unspecified-placeholder-N/ types are /CopyConstructible/. Their copy constructors do not throw exceptions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Common definitions]
|
||||
|
||||
The function \u03BC`(x, v1, v2, ..., vm)`, where `m` is a nonnegative integer, is
|
||||
defined as:
|
||||
|
||||
* `x.get()`, when `x` is of type [@boost:/libs/core/doc/html/core/ref.html `boost::reference_wrapper`]`<T>` for some type
|
||||
`T`;
|
||||
|
||||
* `vk`, when `x` is (a copy of) the placeholder /_k/ for some positive integer
|
||||
/k/;
|
||||
|
||||
* `x(v1, v2, ..., vm)` when `x` is (a copy of) a function object returned by
|
||||
`bind`;
|
||||
|
||||
* `x` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `bind`]
|
||||
|
||||
[#bind_1]
|
||||
|
||||
template<class R, class F> ``/unspecified-1/`` bind(F f)
|
||||
|
||||
* /Returns:/ A function object \u03BB such that the expression \u03BB`(v1, v2, ..., vm)`
|
||||
is equivalent to `f()`, implicitly converted to `R`.
|
||||
|
||||
* /Throws:/ Nothing unless the copy constructor of `F` throws an exception.
|
||||
|
||||
[#bind_1_1]
|
||||
|
||||
template<class F> ``/unspecified-1-1/`` bind(F f)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<typename F::result_type, F>(f)`.
|
||||
|
||||
* /Notes:/ Implementations are allowed to infer the return type of `f` via other
|
||||
means as an extension, without relying on the `result_type` member.
|
||||
|
||||
[#bind_2]
|
||||
|
||||
template<class R> ``/unspecified-2/`` bind(R (*f) ())
|
||||
|
||||
* /Returns:/ A function object \u03BB such that the expression \u03BB`(v1, v2, ..., vm)`
|
||||
is equivalent to `f()`.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#bind_3]
|
||||
|
||||
template<class R, class F, class A1> ``/unspecified-3/`` bind(F f, A1 a1)
|
||||
|
||||
* /Returns:/ A function object \u03BB such that the expression \u03BB`(v1, v2, ..., vm)`
|
||||
is equivalent to `f(`\u03BC`(a1, v1, v2, ..., vm))`, implicitly converted to `R`.
|
||||
|
||||
* /Throws:/ Nothing unless the copy constructors of `F` or `A1` throw an exception.
|
||||
|
||||
[#bind_3_1]
|
||||
|
||||
template<class F, class A1> ``/unspecified-3-1/`` bind(F f, A1 a1)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<typename F::result_type, F, A1>(f, a1)`.
|
||||
|
||||
* /Notes:/ Implementations are allowed to infer the return type of `f` via other
|
||||
means as an extension, without relying on the `result_type` member.
|
||||
|
||||
[#bind_4]
|
||||
|
||||
template<class R, class B1, class A1> ``/unspecified-4/`` bind(R (*f) (B1), A1 a1)
|
||||
|
||||
* /Returns:/ A function object \u03BB such that the expression \u03BB`(v1, v2, ..., vm)`
|
||||
is equivalent to `f(`\u03BC`(a1, v1, v2, ..., vm))`.
|
||||
|
||||
* /Throws:/ Nothing unless the copy constructor of `A1` throws an exception.
|
||||
|
||||
[#bind_5]
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-5/`` bind(R (T::*f) (), A1 a1)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<R>(`[@boost:/libs/bind/mem_fn.html `boost::mem_fn`]`(f), a1)`.
|
||||
|
||||
[#bind_6]
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-6/`` bind(R (T::*f) () const, A1 a1)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<R>(`[@boost:/libs/bind/mem_fn.html `boost::mem_fn`]`(f), a1)`.
|
||||
|
||||
[#bind_6_1]
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-6-1/`` bind(R T::*f, A1 a1)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<R>(`[@boost:/libs/bind/mem_fn.html `boost::mem_fn`]`(f), a1)`.
|
||||
|
||||
[#bind_7]
|
||||
|
||||
template<class R, class F, class A1, class A2> ``/unspecified-7/`` bind(F f, A1 a1, A2 a2)
|
||||
|
||||
* /Returns:/ A function object \u03BB such that the expression \u03BB`(v1, v2, ..., vm)`
|
||||
is equivalent to `f(`\u03BC`(a1, v1, v2, ..., vm), `\u03BC`(a2, v1, v2, ..., vm))`,
|
||||
implicitly converted to `R`.
|
||||
|
||||
* /Throws:/ Nothing unless the copy constructors of `F`, `A1` or `A2` throw an
|
||||
exception.
|
||||
|
||||
[#bind_7_1]
|
||||
|
||||
template<class F, class A1, class A2> ``/unspecified-7-1/`` bind(F f, A1 a1, A2 a2)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<typename F::result_type, F, A1, A2>(f, a1, a2)`.
|
||||
|
||||
* /Notes:/ Implementations are allowed to infer the return type of `f` via other
|
||||
means as an extension, without relying on the `result_type` member.
|
||||
|
||||
[#bind_8]
|
||||
|
||||
template<class R, class B1, class B2, class A1, class A2> ``/unspecified-8/`` bind(R (*f) (B1, B2), A1 a1, A2 a2)
|
||||
|
||||
* /Returns:/ A function object \u03BB such that the expression \u03BB`(v1, v2, ..., vm)`
|
||||
is equivalent to `f(`\u03BC`(a1, v1, v2, ..., vm), `\u03BC`(a2, v1, v2, ..., vm))`.
|
||||
|
||||
* /Throws:/ Nothing unless the copy constructors of `A1` or `A2` throw an exception.
|
||||
|
||||
[#bind_9]
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> ``/unspecified-9/`` bind(R (T::*f) (B1), A1 a1, A2 a2)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<R>(`[@boost:/libs/bind/mem_fn.html `boost::mem_fn`]`(f), a1, a2)`.
|
||||
|
||||
[#bind_10]
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> ``/unspecified-10/`` bind(R (T::*f) (B1) const, A1 a1, A2 a2)
|
||||
|
||||
* /Effects:/ Equivalent to `bind<R>(`[@boost:/libs/bind/mem_fn.html `boost::mem_fn`]`(f), a1, a2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Additional overloads]
|
||||
|
||||
Implementations are allowed to provide additional `bind` overloads in order to
|
||||
support more arguments or different function pointer variations.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
37
doc/bind/limitations.qbk
Normal file
37
doc/bind/limitations.qbk
Normal file
@@ -0,0 +1,37 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:limitations Limitations]
|
||||
|
||||
As a general rule, the function objects generated by `bind` take their
|
||||
arguments by reference and cannot, therefore, accept non-const temporaries or
|
||||
literal constants. This is an inherent limitation of the C++ language in its
|
||||
current (2003) incarnation, known as the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm forwarding problem].
|
||||
(It will be fixed in the next standard, usually called C++0x.)
|
||||
|
||||
The library uses signatures of the form
|
||||
|
||||
template<class T> void f(T & t);
|
||||
|
||||
to accept arguments of arbitrary types and pass them on unmodified. As noted,
|
||||
this does not work with non-const r-values.
|
||||
|
||||
On compilers that support partial ordering of function templates, a possible
|
||||
solution is to add an overload:
|
||||
|
||||
template<class T> void f(T & t);
|
||||
template<class T> void f(T const & t);
|
||||
|
||||
Unfortunately, this requires providing 512 overloads for nine arguments, which
|
||||
is impractical. The library chooses a small subset: for up to two arguments,
|
||||
it provides the const overloads in full, for arities of three and more it
|
||||
provides a single additional overload with all of the arguments taken by const
|
||||
reference. This covers a reasonable portion of the use cases.
|
||||
|
||||
[endsect]
|
||||
273
doc/bind/purpose.qbk
Normal file
273
doc/bind/purpose.qbk
Normal file
@@ -0,0 +1,273 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:purpose Purpose]
|
||||
|
||||
`boost::bind` is a generalization of the standard functions `std::bind1st` and
|
||||
`std::bind2nd`. It supports arbitrary function objects, functions, function
|
||||
pointers, and member function pointers, and is able to bind any argument to a
|
||||
specific value or route input arguments into arbitrary positions. `bind` does
|
||||
not place any requirements on the function object; in particular, it does not
|
||||
need the `result_type`, `first_argument_type` and `second_argument_type`
|
||||
standard typedefs.
|
||||
|
||||
[section Using bind with functions and function pointers]
|
||||
|
||||
Given these definitions:
|
||||
|
||||
int f(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int g(int a, int b, int c)
|
||||
{
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
`bind(f, 1, 2)` will produce a "nullary" function object that takes no
|
||||
arguments and returns `f(1, 2)`. Similarly, `bind(g, 1, 2, 3)()` is equivalent
|
||||
`to g(1, 2, 3)`.
|
||||
|
||||
It is possible to selectively bind only some of the arguments.
|
||||
`bind(f, _1, 5)(x)` is equivalent to `f(x, 5)`; here `_1` is a /placeholder/
|
||||
argument that means "substitute with the first input argument."
|
||||
|
||||
For comparison, here is the same operation expressed with the standard library
|
||||
primitives:
|
||||
|
||||
std::bind2nd(std::ptr_fun(f), 5)(x);
|
||||
|
||||
`bind` covers the functionality of `std::bind1st` as well:
|
||||
|
||||
std::bind1st(std::ptr_fun(f), 5)(x); // f(5, x)
|
||||
bind(f, 5, _1)(x); // f(5, x)
|
||||
|
||||
`bind` can handle functions with more than two arguments, and its argument
|
||||
substitution mechanism is more general:
|
||||
|
||||
bind(f, _2, _1)(x, y); // f(y, x)
|
||||
bind(g, _1, 9, _1)(x); // g(x, 9, x)
|
||||
bind(g, _3, _3, _3)(x, y, z); // g(z, z, z)
|
||||
bind(g, _1, _1, _1)(x, y, z); // g(x, x, x)
|
||||
|
||||
Note that, in the last example, the function object produced by
|
||||
`bind(g, _1, _1, _1)` does not contain references to any arguments beyond the
|
||||
first, but it can still be used with more than one argument. Any extra
|
||||
arguments are silently ignored, just like the first and the second argument
|
||||
are ignored in the third example.
|
||||
|
||||
The arguments that `bind` takes are copied and held internally by the returned
|
||||
function object. For example, in the following code:
|
||||
|
||||
int i = 5;
|
||||
bind(f, i, _1);
|
||||
|
||||
a copy of the value of `i` is stored into the function object.
|
||||
[@boost:/libs/core/doc/html/core/ref.html `boost::ref`] and
|
||||
[@boost:/libs/core/doc/html/core/ref.html `boost::cref`] can be used to make the function
|
||||
object store a reference to an object, rather than a copy:
|
||||
|
||||
int i = 5;
|
||||
bind(f, ref(i), _1);
|
||||
bind(f, cref(i), _1);
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:with_function_objects Using bind with function objects]
|
||||
|
||||
`bind` is not limited to functions; it accepts arbitrary function objects. In
|
||||
the general case, the return type of the generated function object's
|
||||
`operator()` has to be specified explicitly (without a `typeof` operator the
|
||||
return type cannot be inferred):
|
||||
|
||||
struct F
|
||||
{
|
||||
int operator()(int a, int b) { return a - b; }
|
||||
bool operator()(long a, long b) { return a == b; }
|
||||
};
|
||||
|
||||
F f;
|
||||
int x = 104;
|
||||
bind<int>(f, _1, _1)(x); // f(x, x), i.e. zero
|
||||
|
||||
Some compilers have trouble with the `bind<R>(f, ...)` syntax. For portability
|
||||
reasons, an alternative way to express the above is supported:
|
||||
|
||||
boost::bind(boost::type<int>(), f, _1, _1)(x);
|
||||
|
||||
Note, however, that the alternative syntax is provided only as a workaround.
|
||||
It is not part of the interface.
|
||||
|
||||
When the function object exposes a nested type named `result_type`, the explicit
|
||||
return type can be omitted:
|
||||
|
||||
int x = 8;
|
||||
bind(std::less<int>(), _1, 9)(x); // x < 9
|
||||
|
||||
/[Note:/ the ability to omit the return type is not available on all compilers./]/
|
||||
|
||||
By default, `bind` makes a copy of the provided function object. `boost::ref`
|
||||
and `boost::cref` can be used to make it store a reference to the function
|
||||
object, rather than a copy. This can be useful when the function object is
|
||||
non-copyable, expensive to copy, or contains state; of course, in this case
|
||||
the programmer is expected to ensure that the function object is not destroyed
|
||||
while it's still being used.
|
||||
|
||||
struct F2
|
||||
{
|
||||
int s;
|
||||
|
||||
typedef void result_type;
|
||||
void operator()(int x) { s += x; }
|
||||
};
|
||||
|
||||
F2 f2 = { 0 };
|
||||
int a[] = { 1, 2, 3 };
|
||||
|
||||
std::for_each(a, a+3, bind(ref(f2), _1));
|
||||
|
||||
assert(f2.s == 6);
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Using bind with pointers to members]
|
||||
|
||||
Pointers to member functions and pointers to data members are not function
|
||||
objects, because they do not support `operator()`. For convenience, `bind`
|
||||
accepts member pointers as its first argument, and the behavior is as if
|
||||
[@boost:/libs/bind/mem_fn.html `boost::mem_fn`] has been used to convert the
|
||||
member pointer into a function object. In other words, the expression
|
||||
|
||||
bind(&X::f, args)
|
||||
|
||||
is equivalent to
|
||||
|
||||
bind<R>(``[@boost:/libs/bind/mem_fn.html `mem_fn`]``(&X::f), args)
|
||||
|
||||
where `R` is the return type of `X::f` (for member functions) or the type of
|
||||
the member (for data members.)
|
||||
|
||||
/[Note:/ `mem_fn` creates function objects that are able to accept a pointer,
|
||||
a reference, or a smart pointer to an object as its first argument; for
|
||||
additional information, see the `mem_fn`
|
||||
[@boost:/libs/bind/mem_fn.html documentation]./]/
|
||||
|
||||
Example:
|
||||
|
||||
struct X
|
||||
{
|
||||
bool f(int a);
|
||||
};
|
||||
|
||||
X x;
|
||||
shared_ptr<X> p(new X);
|
||||
int i = 5;
|
||||
|
||||
bind(&X::f, ref(x), _1)(i); // x.f(i)
|
||||
bind(&X::f, &x, _1)(i); // (&x)->f(i)
|
||||
bind(&X::f, x, _1)(i); // (internal copy of x).f(i)
|
||||
bind(&X::f, p, _1)(i); // (internal copy of p)->f(i)
|
||||
|
||||
The last two examples are interesting in that they produce "self-contained"
|
||||
function objects. `bind(&X::f, x, _1)` stores a copy of `x`.
|
||||
`bind(&X::f, p, _1)` stores a copy of `p`, and since `p` is a
|
||||
[@boost:/libs/smart_ptr/doc/html/smart_ptr.html#shared_ptr `boost::shared_ptr`], the function
|
||||
object retains a reference to its instance of `X` and will remain valid even
|
||||
when `p` goes out of scope or is `reset()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Using nested binds for function composition]
|
||||
|
||||
Some of the arguments passed to `bind` may be nested /bind expressions/
|
||||
themselves:
|
||||
|
||||
bind(f, bind(g, _1))(x); // f(g(x))
|
||||
|
||||
The inner /bind expressions/ are evaluated, in unspecified order, before the
|
||||
outer `bind` when the function object is called; the results of the evaluation
|
||||
are then substituted in their place when the outer `bind` is evaluated. In the
|
||||
example above, when the function object is called with the argument list `(x)`,
|
||||
`bind(g, _1)(x)` is evaluated first, yielding `g(x)`, and then
|
||||
`bind(f, g(x))(x)` is evaluated, yielding the final result `f(g(x))`.
|
||||
|
||||
This feature of `bind` can be used to perform function composition. See
|
||||
[@../../bind_as_compose.cpp bind_as_compose.cpp] for an example that
|
||||
demonstrates how to use `bind` to achieve similar functionality to
|
||||
[@http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm Boost.Compose].
|
||||
|
||||
Note that the first argument - the bound function object - is not evaluated,
|
||||
even when it's a function object that is produced by `bind` or a /placeholder/
|
||||
argument, so the example below does not work as expected:
|
||||
|
||||
typedef void (*pf)(int);
|
||||
|
||||
std::vector<pf> v;
|
||||
std::for_each(v.begin(), v.end(), bind(_1, 5));
|
||||
|
||||
The desired effect can be achieved via a helper function object `apply` that
|
||||
applies its first argument, as a function object, to the rest of its argument
|
||||
list. For convenience, an implementation of `apply` is provided in the
|
||||
[@../../../../boost/bind/apply.hpp apply.hpp] header file. Here is how the
|
||||
modified version of the previous example looks like:
|
||||
|
||||
typedef void (*pf)(int);
|
||||
|
||||
std::vector<pf> v;
|
||||
std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));
|
||||
|
||||
Although the first argument is, by default, not evaluated, all other arguments
|
||||
are. Sometimes it is necessary not to evaluate arguments subsequent to the
|
||||
first, even when they are nested /bind subexpressions/. This can be achieved
|
||||
with the help of another function object, `protect`, that masks the type so
|
||||
that `bind` does not recognize and evaluate it. When called, protect simply
|
||||
forwards the argument list to the other function object unmodified.
|
||||
|
||||
The header [@../../../../boost/bind/protect.hpp protect.hpp] contains an
|
||||
implementation of `protect`. To `protect` a bind function object from
|
||||
evaluation, use `protect(bind(f, ...))`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Overloaded operators (new in Boost 1.33)]
|
||||
|
||||
For convenience, the function objects produced by `bind` overload the logical
|
||||
not operator `!` and the relational and logical operators `==, !=, <, <=, >,
|
||||
>=, &&, ||`.
|
||||
|
||||
`!bind(f, ...)` is equivalent to `bind(logical_not(), bind(f, ...))`, where
|
||||
`logical_not` is a function object that takes one argument `x` and returns
|
||||
`!x`.
|
||||
|
||||
`bind(f, ...) op x`, where _op_ is a relational or logical operator, is
|
||||
equivalent to `bind(relation(), bind(f, ...), x)`, where `relation` is a
|
||||
function object that takes two arguments `a` and `b` and returns `a op b`.
|
||||
|
||||
What this means in practice is that you can conveniently negate the result of
|
||||
`bind`:
|
||||
|
||||
std::remove_if(first, last, !bind(&X::visible, _1)); // remove invisible objects
|
||||
|
||||
and compare the result of `bind` against a value:
|
||||
|
||||
std::find_if(first, last, bind(&X::name, _1) == "Peter");
|
||||
std::find_if(first, last, bind(&X::name, _1) == "Peter" || bind(&X::name, _1) == "Paul");
|
||||
|
||||
against a /placeholder/:
|
||||
|
||||
bind(&X::name, _1) == _2
|
||||
|
||||
or against another /bind expression/:
|
||||
|
||||
std::sort(first, last, bind(&X::name, _1) < bind(&X::name, _2)); // sort by name
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
268
doc/bind/troubleshooting.qbk
Normal file
268
doc/bind/troubleshooting.qbk
Normal file
@@ -0,0 +1,268 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2008 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:troubleshooting Troubleshooting]
|
||||
|
||||
[section Incorrect number of arguments]
|
||||
|
||||
In a `bind(f, a1, a2, ..., aN)` expression, the function object `f` must be
|
||||
able to take exactly N arguments. This error is normally detected at "bind
|
||||
time"; in other words, the compilation error is reported on the line where
|
||||
`bind()` is invoked:
|
||||
|
||||
int f(int, int);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, 1); // error, f takes two arguments
|
||||
boost::bind(f, 1, 2); // OK
|
||||
}
|
||||
|
||||
A common variation of this error is to forget that member functions have an
|
||||
implicit "this" argument:
|
||||
|
||||
struct X
|
||||
{
|
||||
int f(int);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(&X::f, 1); // error, X::f takes two arguments
|
||||
boost::bind(&X::f, _1, 1); // OK
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[section The function object cannot be called with the specified arguments]
|
||||
|
||||
As in normal function calls, the function object that is bound must be
|
||||
compatible with the argument list. The incompatibility will usually be
|
||||
detected by the compiler at "call time" and the result is typically an error
|
||||
in `bind.hpp` on a line that looks like:
|
||||
|
||||
return f(a[a1_], a[a2_]);
|
||||
|
||||
An example of this kind of error:
|
||||
|
||||
int f(int);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, "incompatible"); // OK so far, no call
|
||||
boost::bind(f, "incompatible")(); // error, "incompatible" is not an int
|
||||
boost::bind(f, _1); // OK
|
||||
boost::bind(f, _1)("incompatible"); // error, "incompatible" is not an int
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Accessing an argument that does not exist]
|
||||
|
||||
The placeholder `_N` selects the argument at position `N` from the argument
|
||||
list passed at "call time." Naturally, it is an error to attempt to access
|
||||
beyond the end of this list:
|
||||
|
||||
int f(int);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, _1); // OK
|
||||
boost::bind(f, _1)(); // error, there is no argument number 1
|
||||
}
|
||||
|
||||
The error is usually reported in `bind.hpp`, at a line similar to:
|
||||
|
||||
return f(a[a1_]);
|
||||
|
||||
When emulating `std::bind1st(f, a)`, a common mistake of this category is to
|
||||
type `bind(f, a, _2)` instead of the correct `bind(f, a, _1)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Inappropriate use of `bind(f, ...)`]
|
||||
|
||||
The `bind(f, a1, a2, ..., aN)` [link bind.faq.Q_forms form] causes automatic
|
||||
recognition of the type of `f`. It will not work with arbitrary function
|
||||
objects; `f` must be a function or a member function pointer.
|
||||
|
||||
It is possible to use this form with function objects that define
|
||||
`result_type`, but only on compilers that support partial specialization and
|
||||
partial ordering. In particular, MSVC up to version 7.0 does not support this
|
||||
syntax for function objects.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Inappropriate use of `bind<R>(f, ...)`]
|
||||
|
||||
The `bind<R>(f, a1, a2, ..., aN)` [link bind.faq.Q_forms form] supports
|
||||
arbitrary function objects.
|
||||
|
||||
It is possible (but not recommended) to use this form with functions or member
|
||||
function pointers, but only on compilers that support partial ordering. In
|
||||
particular, MSVC up to version 7.0 does not fully support this syntax for
|
||||
functions and member function pointers.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Binding a nonstandard function]
|
||||
|
||||
By default, the `bind(f, a1, a2, ..., aN)` [link bind.faq.Q_forms form]
|
||||
recognizes "ordinary" C++ functions and function pointers. [link
|
||||
bind.implementation.stdcall Functions that use a different calling convention],
|
||||
or variable-argument functions such as `std::printf`, do not work. The general
|
||||
`bind<R>(f, a1, a2, ..., aN)` [link bind.faq.Q_forms form] works with
|
||||
nonstandard functions.
|
||||
|
||||
On some platforms, extern "C" functions, like `std::strcmp`, are not
|
||||
recognized by the short form of `bind`.
|
||||
|
||||
See also [link bind.implementation.stdcall `__stdcall` and `pascal` Support].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Binding an overloaded function]
|
||||
|
||||
An attempt to bind an overloaded function usually results in an error, as
|
||||
there is no way to tell which overload was meant to be bound. This is a common
|
||||
problem with member functions with two overloads, const and non-const, as in
|
||||
this simplified example:
|
||||
|
||||
struct X
|
||||
{
|
||||
int& get();
|
||||
int const& get() const;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(&X::get, _1);
|
||||
}
|
||||
|
||||
The ambiguity can be resolved manually by casting the (member) function
|
||||
pointer to the desired type:
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(static_cast< int const& (X::*) () const >(&X::get), _1);
|
||||
}
|
||||
|
||||
Another, arguably more readable, alternative is to introduce a temporary
|
||||
variable:
|
||||
|
||||
int main()
|
||||
{
|
||||
int const& (X::*get) () const = &X::get;
|
||||
boost::bind(get, _1);
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Modeling STL function object concepts]
|
||||
|
||||
The function objects that are produced by `bind` do not model the STL
|
||||
[@https://boost.org/sgi/stl/UnaryFunction.html /Unary Function/] or
|
||||
[@https://boost.org/sgi/stl/BinaryFunction.html /Binary Function/] concepts,
|
||||
even when the function objects are unary or binary operations, because the
|
||||
function object types are missing public typedefs `result_type` and
|
||||
`argument_type` or `first_argument_type` and `second_argument_type`. In cases
|
||||
where these typedefs are desirable, however, the utility function
|
||||
`make_adaptable` can be used to adapt unary and binary function objects to
|
||||
these concepts. This allows unary and binary function objects resulting from
|
||||
`bind` to be combined with STL templates such as
|
||||
[@http://en.cppreference.com/w/cpp/utility/functional/unary_negate `std::unary_negate`]
|
||||
and [@http://en.cppreference.com/w/cpp/utility/functional/binary_negate `std::binary_negate`].
|
||||
|
||||
The `make_adaptable` function is defined in [@../../../../boost/bind/make_adaptable.hpp
|
||||
`<boost/bind/make_adaptable.hpp>`], which must be included explicitly in
|
||||
addition to [@../../../../boost/bind/bind.hpp `<boost/bind/bind.hpp>`]:
|
||||
|
||||
#include <boost/bind/make_adaptable.hpp>
|
||||
|
||||
template <class R, class F> ``/unspecified-type/`` make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class F> ``/unspecified-unary-functional-type/`` make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class A2, class F> ``/unspecified-binary-functional-type/`` make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class A2, class A3, class F> ``/unspecified-ternary-functional-type/`` make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class A2, class A3, class A4, class F> ``/unspecified-4-ary-functional-type/`` make_adaptable(F f);
|
||||
|
||||
This example shows how to use `make_adaptable` to make a predicate for "is not a space":
|
||||
|
||||
typedef char char_t;
|
||||
std::locale loc("");
|
||||
const std::ctype<char_t>& ct = std::use_facet<std::ctype<char_t> >(loc);
|
||||
|
||||
auto isntspace = std::not1(boost::make_adaptable<bool, char_t>(boost::bind(&std::ctype<char_t>::is, &ct, std::ctype_base::space, _1)));
|
||||
|
||||
In this example, `bind` creates the "is a space" (unary) predicate. It is then
|
||||
passed to `make_adaptable` so that a function object modeling the /Unary
|
||||
Function/ concept can be created, serving as the argument to
|
||||
[@http://en.cppreference.com/w/cpp/utility/functional/not1 `std::not1`].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `const` in signatures]
|
||||
|
||||
Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with
|
||||
the top-level `const` in function signatures:
|
||||
|
||||
int f(int const);
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f, 1); // error
|
||||
}
|
||||
|
||||
Workaround: remove the `const` qualifier from the argument.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section MSVC specific: `using boost::bind;`]
|
||||
|
||||
On MSVC (up to version 7.0), when `boost::bind` is brought into scope with an
|
||||
using declaration:
|
||||
|
||||
using boost::bind;
|
||||
|
||||
the syntax `bind<R>(f, ...)` does not work. Workaround: either use the
|
||||
qualified name, `boost::bind`, or use an using directive instead:
|
||||
|
||||
using namespace boost;
|
||||
|
||||
[endsect]
|
||||
|
||||
[section MSVC specific: class templates shadow function templates]
|
||||
|
||||
On MSVC (up to version 7.0), a nested class template named `bind` will shadow
|
||||
the function template `boost::bind`, breaking the `bind<R>(f, ...)`syntax.
|
||||
Unfortunately, some libraries contain nested class templates named `bind`
|
||||
(ironically, such code is often an MSVC specific workaround.)
|
||||
|
||||
The workaround is to use the alternative `bind(type<R>(), f, ...)` syntax.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section MSVC specific: `...` in signatures treated as type]
|
||||
|
||||
MSVC (up to version 7.0) treats the ellipsis in a variable argument function
|
||||
(such as `std::printf`) as a type. Therefore, it will accept the (incorrect in
|
||||
the current implementation) form:
|
||||
|
||||
bind(printf, "%s\n", _1);
|
||||
|
||||
and will reject the correct version:
|
||||
|
||||
bind<int>(printf, "%s\n", _1);
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
1552
doc/html/bind.html
Normal file
1552
doc/html/bind.html
Normal file
File diff suppressed because it is too large
Load Diff
552
doc/html/mem_fn.html
Normal file
552
doc/html/mem_fn.html
Normal file
@@ -0,0 +1,552 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 1. Boost.Member Function</title>
|
||||
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="mem_fn.html" title="Chapter 1. Boost.Member Function">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav"></div>
|
||||
<div class="chapter">
|
||||
<div class="titlepage"><div>
|
||||
<div><h2 class="title">
|
||||
<a name="mem_fn"></a>Chapter 1. Boost.Member Function</h2></div>
|
||||
<div><p class="copyright">Copyright © 2001, 2002 Peter Dimov and Multi Media Ltd.</p></div>
|
||||
<div><p class="copyright">Copyright © 2003-2005 Peter Dimov</p></div>
|
||||
<div><div class="legalnotice">
|
||||
<a name="mem_fn.legal"></a><p>
|
||||
Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
|
||||
Software License, Version 1.0</a>.
|
||||
</p>
|
||||
</div></div>
|
||||
</div></div>
|
||||
<div class="toc">
|
||||
<p><b>Table of Contents</b></p>
|
||||
<dl class="toc">
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.purpose">Purpose</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.faq">Frequently Asked Questions</a></span></dt>
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.can_mem_fn_be_used_instead_of_th">Can <code class="computeroutput"><span class="identifier">mem_fn</span></code> be used instead of the standard <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code>
|
||||
adaptors?</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.should_i_replace_every_occurence">Should I
|
||||
replace every occurence of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code>
|
||||
with <code class="computeroutput"><span class="identifier">mem_fn</span></code> in my existing
|
||||
code?</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.does_mem_fn_work_with_com_method">Does <code class="computeroutput"><span class="identifier">mem_fn</span></code> work with COM methods?</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.why_isn_t_boost_mem_fn_enable_st">Why isn't
|
||||
<code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code>
|
||||
defined automatically?</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.interface">Interface</a></span></dt>
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.synopsys">Synopsis</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.common_requirements">Common requirements</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.get_pointer"><code class="computeroutput"><span class="identifier">get_pointer</span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.mem_fn"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation">Implementation</a></span></dt>
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.files">Files</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.dependencies">Dependencies</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.number_of_arguments">Number of
|
||||
Arguments</a></span></dt>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.stdcall"><code class="computeroutput"><span class="identifier">__stdcall</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">__cdecl</span></code>, and <code class="computeroutput"><span class="identifier">__fastcall</span></code> Support</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="mem_fn.html#mem_fn.acknowledgements">Acknowledgements</a></span></dt>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="mem_fn.purpose"></a><a class="link" href="mem_fn.html#mem_fn.purpose" title="Purpose">Purpose</a>
|
||||
</h2></div></div></div>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span></code> is a generalization of the standard
|
||||
functions <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun_ref</span></code>.
|
||||
It supports member function pointers with more than one argument, and the returned
|
||||
function object can take a pointer, a reference, or a smart pointer to an object
|
||||
instance as its first argument. <code class="computeroutput"><span class="identifier">mem_fn</span></code>
|
||||
also supports pointers to data members by treating them as functions taking
|
||||
no arguments and returning a (const) reference to the member.
|
||||
</p>
|
||||
<p>
|
||||
The purpose of <code class="computeroutput"><span class="identifier">mem_fn</span></code> is twofold.
|
||||
First, it allows users to invoke a member function on a container with the
|
||||
familiar
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">Shape</span><span class="special">::</span><span class="identifier">draw</span><span class="special">));</span>
|
||||
</pre>
|
||||
<p>
|
||||
syntax, even when the container stores smart pointers.
|
||||
</p>
|
||||
<p>
|
||||
Second, it can be used as a building block by library developers that want
|
||||
to treat a pointer to member function as a function object. A library might
|
||||
define an enhanced <code class="computeroutput"><span class="identifier">for_each</span></code>
|
||||
algorithm with an overload of the form:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">It</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">It</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">It</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">())</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">pmf</span><span class="special">));</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
that will allow the convenient syntax:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="special">&</span><span class="identifier">Shape</span><span class="special">::</span><span class="identifier">draw</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
When documenting the feature, the library author will simply state:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">It</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">It</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">It</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">());</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<span class="emphasis"><em>Effects:</em></span> Equivalent to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">pmf</span><span class="special">))</span></code>.
|
||||
</li></ul></div>
|
||||
<p>
|
||||
where <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span></code> can be a link to this page. See the
|
||||
<a href="../../../../libs/bind/bind.html" target="_top">documentation of <code class="computeroutput"><span class="identifier">bind</span></code></a>
|
||||
for an example.
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">mem_fn</span></code> takes one argument,
|
||||
a pointer to a member, and returns a function object suitable for use with
|
||||
standard or user-defined algorithms:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">void</span> <span class="identifier">f</span><span class="special">();</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">void</span> <span class="identifier">g</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span> <span class="special">&</span> <span class="identifier">v</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">));</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">void</span> <span class="identifier">h</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">X</span> <span class="special">*></span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">));</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">void</span> <span class="identifier">k</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span> <span class="special">></span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">));</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
The returned function object takes the same arguments as the input member function
|
||||
plus a "flexible" first argument that represents the object instance.
|
||||
</p>
|
||||
<p>
|
||||
When the function object is invoked with a first argument <code class="computeroutput"><span class="identifier">x</span></code>
|
||||
that is neither a pointer nor a reference to the appropriate class (<code class="computeroutput"><span class="identifier">X</span></code> in the example above), it uses <code class="computeroutput"><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> to obtain
|
||||
a pointer from <code class="computeroutput"><span class="identifier">x</span></code>. Library authors
|
||||
can "register" their smart pointer classes by supplying an appropriate
|
||||
<code class="computeroutput"><span class="identifier">get_pointer</span></code> overload, allowing
|
||||
<code class="computeroutput"><span class="identifier">mem_fn</span></code> to recognize and support
|
||||
them.
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>[Note:</em></span> <code class="computeroutput"><span class="identifier">get_pointer</span></code>
|
||||
is not restricted to return a pointer. Any object that can be used in a member
|
||||
function call expression <code class="computeroutput"><span class="special">(</span><span class="identifier">x</span><span class="special">->*</span><span class="identifier">pmf</span><span class="special">)(...)</span></code> will work.<span class="emphasis"><em>]</em></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>[Note:</em></span> the library uses an unqualified call to <code class="computeroutput"><span class="identifier">get_pointer</span></code>. Therefore, it will find, through
|
||||
argument-dependent lookup, <code class="computeroutput"><span class="identifier">get_pointer</span></code>
|
||||
overloads that are defined in the same namespace as the corresponding smart
|
||||
pointer class, in addition to any <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">get_pointer</span></code>
|
||||
overloads.<span class="emphasis"><em>]</em></span>
|
||||
</p>
|
||||
<p>
|
||||
All function objects returned by <code class="computeroutput"><span class="identifier">mem_fn</span></code>
|
||||
expose a <code class="computeroutput"><span class="identifier">result_type</span></code> typedef
|
||||
that represents the return type of the member function. For data members,
|
||||
<code class="computeroutput"><span class="identifier">result_type</span></code> is defined as the
|
||||
type of the member.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="mem_fn.faq"></a><a class="link" href="mem_fn.html#mem_fn.faq" title="Frequently Asked Questions">Frequently Asked Questions</a>
|
||||
</h2></div></div></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.faq.can_mem_fn_be_used_instead_of_th"></a><a class="link" href="mem_fn.html#mem_fn.faq.can_mem_fn_be_used_instead_of_th" title="Can mem_fn be used instead of the standard std::mem_fun[_ref] adaptors?">Can <code class="computeroutput"><span class="identifier">mem_fn</span></code> be used instead of the standard <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code>
|
||||
adaptors?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Yes. For simple uses, <code class="computeroutput"><span class="identifier">mem_fn</span></code>
|
||||
provides additional functionality that the standard adaptors do not. Complicated
|
||||
expressions that use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bind1st</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bind2nd</span></code> or <a href="http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm" target="_top">Boost.Compose</a>
|
||||
along with the standard adaptors can be rewritten using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span></code>
|
||||
that automatically takes advantage of <code class="computeroutput"><span class="identifier">mem_fn</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.faq.should_i_replace_every_occurence"></a><a class="link" href="mem_fn.html#mem_fn.faq.should_i_replace_every_occurence" title="Should I replace every occurence of std::mem_fun[_ref] with mem_fn in my existing code?">Should I
|
||||
replace every occurence of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code>
|
||||
with <code class="computeroutput"><span class="identifier">mem_fn</span></code> in my existing
|
||||
code?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
No, unless you have good reasons to do so. <code class="computeroutput"><span class="identifier">mem_fn</span></code>
|
||||
is not 100% compatible with the standard adaptors, although it comes pretty
|
||||
close. In particular, <code class="computeroutput"><span class="identifier">mem_fn</span></code>
|
||||
does not return objects of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::[</span><span class="identifier">const_</span><span class="special">]</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="number">1</span><span class="special">][</span><span class="identifier">_ref</span><span class="special">]</span><span class="identifier">_t</span></code>,
|
||||
as the standard adaptors do, and it is not possible to fully describe the
|
||||
type of the first argument using the standard <code class="computeroutput"><span class="identifier">argument_type</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">first_argument_type</span></code> nested
|
||||
typedefs. Libraries that need adaptable function objects in order to function
|
||||
might not like <code class="computeroutput"><span class="identifier">mem_fn</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.faq.does_mem_fn_work_with_com_method"></a><a class="link" href="mem_fn.html#mem_fn.faq.does_mem_fn_work_with_com_method" title="Does mem_fn work with COM methods?">Does <code class="computeroutput"><span class="identifier">mem_fn</span></code> work with COM methods?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Yes, if you <a class="link" href="mem_fn.html#mem_fn.implementation.stdcall" title="__stdcall, __cdecl, and __fastcall Support">`#define BOOST_MEM_FN_ENABLE_STDCALL</a>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.faq.why_isn_t_boost_mem_fn_enable_st"></a><a class="link" href="mem_fn.html#mem_fn.faq.why_isn_t_boost_mem_fn_enable_st" title="Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?">Why isn't
|
||||
<code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code>
|
||||
defined automatically?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Non-portable extensions, in general, should default to off to prevent vendor
|
||||
lock-in. Had <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code>
|
||||
been defined automatically, you could have accidentally taken advantage of
|
||||
it without realizing that your code is, perhaps, no longer portable. In addition,
|
||||
it is possible for the default calling convention to be <code class="computeroutput"><span class="identifier">__stdcall</span></code>,
|
||||
in which case enabling <code class="computeroutput"><span class="identifier">__stdcall</span></code>
|
||||
support will result in duplicate definitions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="mem_fn.interface"></a><a class="link" href="mem_fn.html#mem_fn.interface" title="Interface">Interface</a>
|
||||
</h2></div></div></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.interface.synopsys"></a><a class="link" href="mem_fn.html#mem_fn.interface.synopsys" title="Synopsis">Synopsis</a>
|
||||
</h3></div></div></div>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="identifier">T</span> <span class="special">*</span> <a class="link" href="mem_fn.html#get_pointer_1"><code class="computeroutput"><span class="identifier">get_pointer</span></code></a><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-1</em></span> <a class="link" href="mem_fn.html#mem_fn_1"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">());</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2</em></span> <a class="link" href="mem_fn.html#mem_fn_2"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2-1</em></span> <a class="link" href="mem_fn.html#mem_fn_2_1"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-3</em></span> <a class="link" href="mem_fn.html#mem_fn_3"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">));</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-4</em></span> <a class="link" href="mem_fn.html#mem_fn_4"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">)</span> <span class="keyword">const</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-5</em></span> <a class="link" href="mem_fn.html#mem_fn_5"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">));</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-6</em></span> <a class="link" href="mem_fn.html#mem_fn_6"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">)</span> <span class="keyword">const</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// implementation defined number of additional overloads for more arguments</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.interface.common_requirements"></a><a class="link" href="mem_fn.html#mem_fn.interface.common_requirements" title="Common requirements">Common requirements</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
All <span class="emphasis"><em>unspecified-N</em></span> types mentioned in the Synopsis are
|
||||
<span class="emphasis"><em>CopyConstructible</em></span> and <span class="emphasis"><em>Assignable</em></span>.
|
||||
Their copy constructors and assignment operators do not throw exceptions.
|
||||
<span class="emphasis"><em>unspecified-N</em></span><code class="computeroutput"><span class="special">::</span><span class="identifier">result_type</span></code> is defined as the return type
|
||||
of the member function pointer passed as an argument to <code class="computeroutput"><span class="identifier">mem_fn</span></code>
|
||||
(<code class="computeroutput"><span class="identifier">R</span></code> in the Synopsis.) <span class="emphasis"><em>unspecified-2-1</em></span><code class="computeroutput"><span class="special">::</span><span class="identifier">result_type</span></code>
|
||||
is defined as <code class="computeroutput"><span class="identifier">R</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.interface.get_pointer"></a><a class="link" href="mem_fn.html#mem_fn.interface.get_pointer" title="get_pointer"><code class="computeroutput"><span class="identifier">get_pointer</span></code></a>
|
||||
</h3></div></div></div>
|
||||
<a name="get_pointer_1"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="identifier">T</span> <span class="special">*</span> <span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">)</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> <code class="computeroutput"><span class="identifier">p</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.interface.mem_fn"></a><a class="link" href="mem_fn.html#mem_fn.interface.mem_fn" title="mem_fn"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a>
|
||||
</h3></div></div></div>
|
||||
<a name="mem_fn_1"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-1</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">())</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)()</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is an l-value
|
||||
of type <code class="computeroutput"><span class="identifier">T</span></code> or derived,
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)()</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="mem_fn_2"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">)</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)()</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived,
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)()</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="mem_fn_2_1"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2-1</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">)</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pm</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived,
|
||||
<code class="computeroutput"><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pm</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="mem_fn_3"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-3</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">))</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is an l-value
|
||||
of type <code class="computeroutput"><span class="identifier">T</span></code> or derived,
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="mem_fn_4"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-4</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">)</span> <span class="keyword">const</span><span class="special">)</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived,
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="mem_fn_5"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-5</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">))</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is an l-value
|
||||
of type <code class="computeroutput"><span class="identifier">T</span></code> or derived,
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="mem_fn_6"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-6</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">)</span> <span class="keyword">const</span><span class="special">)</span>
|
||||
</pre>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the
|
||||
expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived,
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> otherwise.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="emphasis"><em>Throws:</em></span> Nothing.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="mem_fn.implementation"></a><a class="link" href="mem_fn.html#mem_fn.implementation" title="Implementation">Implementation</a>
|
||||
</h2></div></div></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.implementation.files"></a><a class="link" href="mem_fn.html#mem_fn.implementation.files" title="Files">Files</a>
|
||||
</h3></div></div></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="../../../../boost/mem_fn.hpp" target="_top">boost/mem_fn.hpp</a> (main
|
||||
header)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../../../boost/bind/mem_fn_cc.hpp" target="_top">boost/bind/mem_fn_cc.hpp</a>
|
||||
(used by <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code>, do not include directly)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../../../boost/bind/mem_fn_vw.hpp" target="_top">boost/bind/mem_fn_vw.hpp</a>
|
||||
(used by <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code>, do not include directly)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../../../boost/bind/mem_fn_template.hpp" target="_top">boost/bind/mem_fn_template.hpp</a>
|
||||
(used by <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code>, do not include directly)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../test/mem_fn_test.cpp" target="_top">libs/bind/test/mem_fn_test.cpp</a>
|
||||
(test)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../test/mem_fn_derived_test.cpp" target="_top">libs/bind/test/mem_fn_derived_test.cpp</a>
|
||||
(test with derived objects)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../test/mem_fn_fastcall_test.cpp" target="_top">libs/bind/test/mem_fn_fastcall_test.cpp</a>
|
||||
(test for <code class="computeroutput"><span class="identifier">__fastcall</span></code>)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../test/mem_fn_stdcall_test.cpp" target="_top">libs/bind/test/mem_fn_stdcall_test.cpp</a>
|
||||
(test for <code class="computeroutput"><span class="identifier">__stdcall</span></code>)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="../../test/mem_fn_void_test.cpp" target="_top">libs/bind/test/mem_fn_void_test.cpp</a>
|
||||
(test for <code class="computeroutput"><span class="keyword">void</span></code> returns)
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.implementation.dependencies"></a><a class="link" href="mem_fn.html#mem_fn.implementation.dependencies" title="Dependencies">Dependencies</a>
|
||||
</h3></div></div></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<a href="../../../../libs/config/config.htm" target="_top">Boost.Config</a>
|
||||
</li></ul></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.implementation.number_of_arguments"></a><a class="link" href="mem_fn.html#mem_fn.implementation.number_of_arguments" title="Number of Arguments">Number of
|
||||
Arguments</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
This implementation supports member functions with up to eight arguments.
|
||||
This is not an inherent limitation of the design, but an implementation detail.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="mem_fn.implementation.stdcall"></a><a class="link" href="mem_fn.html#mem_fn.implementation.stdcall" title="__stdcall, __cdecl, and __fastcall Support"><code class="computeroutput"><span class="identifier">__stdcall</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">__cdecl</span></code>, and <code class="computeroutput"><span class="identifier">__fastcall</span></code> Support</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Some platforms allow several types of member functions that differ by their
|
||||
calling convention (the rules by which the function is invoked: how are arguments
|
||||
passed, how is the return value handled, and who cleans up the stack - if
|
||||
any.)
|
||||
</p>
|
||||
<p>
|
||||
For example, Windows API functions and COM interface member functions use
|
||||
a calling convention known as <code class="computeroutput"><span class="identifier">__stdcall</span></code>.
|
||||
Borland VCL components use <code class="computeroutput"><span class="identifier">__fastcall</span></code>.
|
||||
UDK, the component model of OpenOffice.org, uses <code class="computeroutput"><span class="identifier">__cdecl</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
To use <code class="computeroutput"><span class="identifier">mem_fn</span></code> with <code class="computeroutput"><span class="identifier">__stdcall</span></code> member functions, <code class="computeroutput"><span class="preprocessor">#define</span></code> the macro <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code>
|
||||
before including <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
</p>
|
||||
<p>
|
||||
To use <code class="computeroutput"><span class="identifier">mem_fn</span></code> with <code class="computeroutput"><span class="identifier">__fastcall</span></code> member functions, <code class="computeroutput"><span class="preprocessor">#define</span></code> the macro <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_FASTCALL</span></code>
|
||||
before including <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
</p>
|
||||
<p>
|
||||
To use <code class="computeroutput"><span class="identifier">mem_fn</span></code> with <code class="computeroutput"><span class="identifier">__cdecl</span></code> member functions, <code class="computeroutput"><span class="preprocessor">#define</span></code> the macro <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_CDECL</span></code>
|
||||
before including <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>It is best to define these macros in the project options,
|
||||
via <code class="computeroutput"><span class="special">-</span><span class="identifier">D</span></code>
|
||||
on the command line, or as the first line in the translation unit (.cpp file)
|
||||
where <code class="computeroutput"><span class="identifier">mem_fn</span></code> is used.</strong></span>
|
||||
Not following this rule can lead to obscure errors when a header includes
|
||||
<code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code> before the macro has been defined.
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>[Note:</em></span> this is a non-portable extension. It is not part
|
||||
of the interface.<span class="emphasis"><em>]</em></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>[Note:</em></span> Some compilers provide only minimal support for
|
||||
the <code class="computeroutput"><span class="identifier">__stdcall</span></code> keyword.<span class="emphasis"><em>]</em></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="mem_fn.acknowledgements"></a><a class="link" href="mem_fn.html#mem_fn.acknowledgements" title="Acknowledgements">Acknowledgements</a>
|
||||
</h2></div></div></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Rene Jager's initial suggestion of using traits classes to make <code class="computeroutput"><span class="identifier">mem_fn</span></code> adapt to user-defined smart pointers
|
||||
inspired the <code class="computeroutput"><span class="identifier">get_pointer</span></code>-based
|
||||
design.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Numerous improvements were suggested during the formal review period by
|
||||
Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was
|
||||
Darin Adler.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Steve Anichini pointed out that COM interfaces use <code class="computeroutput"><span class="identifier">__stdcall</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Dave Abrahams modified <code class="computeroutput"><span class="identifier">bind</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">mem_fn</span></code> to support
|
||||
<code class="computeroutput"><span class="keyword">void</span></code> returns on deficient
|
||||
compilers.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Daniel Boelzle pointed out that UDK uses <code class="computeroutput"><span class="identifier">__cdecl</span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
This documentation was ported to Quickbook by Agustín Bergé.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: December 13, 2019 at 18:24:22 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav"></div>
|
||||
</body>
|
||||
</html>
|
||||
32
doc/mem_fn.qbk
Normal file
32
doc/mem_fn.qbk
Normal file
@@ -0,0 +1,32 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2005 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[library Boost.Member Function
|
||||
[quickbook 1.6]
|
||||
[id mem_fn]
|
||||
[copyright 2001, 2002 Peter Dimov and Multi Media Ltd.]
|
||||
[copyright 2003-2005 Peter Dimov]
|
||||
[dirname bind]
|
||||
[license Distributed under the
|
||||
[@http://boost.org/LICENSE_1_0.txt Boost Software License,
|
||||
Version 1.0].
|
||||
]
|
||||
]
|
||||
|
||||
[template simplesect[title]
|
||||
[block '''<simplesect><title>'''[title]'''</title>''']]
|
||||
|
||||
[template endsimplesect[]
|
||||
[block '''</simplesect>''']]
|
||||
|
||||
[include mem_fn/purpose.qbk]
|
||||
[include mem_fn/faq.qbk]
|
||||
[include mem_fn/interface.qbk]
|
||||
[include mem_fn/implementation.qbk]
|
||||
[include mem_fn/acknowledgements.qbk]
|
||||
28
doc/mem_fn/acknowledgements.qbk
Normal file
28
doc/mem_fn/acknowledgements.qbk
Normal file
@@ -0,0 +1,28 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2005 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:acknowledgements Acknowledgements]
|
||||
|
||||
* Rene Jager's initial suggestion of using traits classes to make `mem_fn`
|
||||
adapt to user-defined smart pointers inspired the `get_pointer`-based design.
|
||||
|
||||
* Numerous improvements were suggested during the formal review period by
|
||||
Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was Darin
|
||||
Adler.
|
||||
|
||||
* Steve Anichini pointed out that COM interfaces use `__stdcall`.
|
||||
|
||||
* Dave Abrahams modified `bind` and `mem_fn` to support `void` returns on
|
||||
deficient compilers.
|
||||
|
||||
* Daniel Boelzle pointed out that UDK uses `__cdecl`.
|
||||
|
||||
This documentation was ported to Quickbook by Agustín Bergé.
|
||||
|
||||
[endsect]
|
||||
53
doc/mem_fn/faq.qbk
Normal file
53
doc/mem_fn/faq.qbk
Normal file
@@ -0,0 +1,53 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2005 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:faq Frequently Asked Questions]
|
||||
|
||||
[section Can `mem_fn` be used instead of the standard `std::mem_fun[_ref]`
|
||||
adaptors?]
|
||||
|
||||
Yes. For simple uses, `mem_fn` provides additional functionality that the
|
||||
standard adaptors do not. Complicated expressions that use `std::bind1st`,
|
||||
`std::bind2nd` or [@http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm Boost.Compose]
|
||||
along with the standard adaptors can be rewritten using `boost::bind` that
|
||||
automatically takes advantage of `mem_fn`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Should I replace every occurence of `std::mem_fun[_ref]` with
|
||||
`mem_fn` in my existing code?]
|
||||
|
||||
No, unless you have good reasons to do so. `mem_fn` is not 100% compatible
|
||||
with the standard adaptors, although it comes pretty close. In particular,
|
||||
`mem_fn` does not return objects of type `std::[const_]mem_fun[1][_ref]_t`, as
|
||||
the standard adaptors do, and it is not possible to fully describe the type of
|
||||
the first argument using the standard `argument_type` and `first_argument_type`
|
||||
nested typedefs. Libraries that need adaptable function objects in order to
|
||||
function might not like `mem_fn`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Does `mem_fn` work with COM methods?]
|
||||
|
||||
Yes, if you [link mem_fn.implementation.stdcall `#define BOOST_MEM_FN_ENABLE_STDCALL].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Why isn't `BOOST_MEM_FN_ENABLE_STDCALL` defined automatically?]
|
||||
|
||||
Non-portable extensions, in general, should default to off to prevent vendor
|
||||
lock-in. Had `BOOST_MEM_FN_ENABLE_STDCALL` been defined automatically, you
|
||||
could have accidentally taken advantage of it without realizing that your code
|
||||
is, perhaps, no longer portable. In addition, it is possible for the default
|
||||
calling convention to be `__stdcall`, in which case enabling `__stdcall`
|
||||
support will result in duplicate definitions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
70
doc/mem_fn/implementation.qbk
Normal file
70
doc/mem_fn/implementation.qbk
Normal file
@@ -0,0 +1,70 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2005 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:implementation Implementation]
|
||||
|
||||
[section Files]
|
||||
|
||||
* [@../../../../boost/mem_fn.hpp boost/mem_fn.hpp] (main header)
|
||||
* [@../../../../boost/bind/mem_fn_cc.hpp boost/bind/mem_fn_cc.hpp] (used by `mem_fn.hpp`, do not include directly)
|
||||
* [@../../../../boost/bind/mem_fn_vw.hpp boost/bind/mem_fn_vw.hpp] (used by `mem_fn.hpp`, do not include directly)
|
||||
* [@../../../../boost/bind/mem_fn_template.hpp boost/bind/mem_fn_template.hpp] (used by `mem_fn.hpp`, do not include directly)
|
||||
* [@../../test/mem_fn_test.cpp libs/bind/test/mem_fn_test.cpp] (test)
|
||||
* [@../../test/mem_fn_derived_test.cpp libs/bind/test/mem_fn_derived_test.cpp] (test with derived objects)
|
||||
* [@../../test/mem_fn_fastcall_test.cpp libs/bind/test/mem_fn_fastcall_test.cpp] (test for `__fastcall`)
|
||||
* [@../../test/mem_fn_stdcall_test.cpp libs/bind/test/mem_fn_stdcall_test.cpp] (test for `__stdcall`)
|
||||
* [@../../test/mem_fn_void_test.cpp libs/bind/test/mem_fn_void_test.cpp] (test for `void` returns)
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Dependencies]
|
||||
|
||||
* [@boost:/libs/config/config.htm Boost.Config]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Number of Arguments]
|
||||
|
||||
This implementation supports member functions with up to eight arguments. This
|
||||
is not an inherent limitation of the design, but an implementation detail.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:stdcall `__stdcall`, `__cdecl`, and `__fastcall` Support]
|
||||
|
||||
Some platforms allow several types of member functions that differ by their
|
||||
calling convention (the rules by which the function is invoked: how are
|
||||
arguments passed, how is the return value handled, and who cleans up the stack
|
||||
- if any.)
|
||||
|
||||
For example, Windows API functions and COM interface member functions use a
|
||||
calling convention known as `__stdcall`. Borland VCL components use
|
||||
`__fastcall`. UDK, the component model of OpenOffice.org, uses `__cdecl`.
|
||||
|
||||
To use `mem_fn` with `__stdcall` member functions, `#define` the macro
|
||||
`BOOST_MEM_FN_ENABLE_STDCALL` before including `<boost/mem_fn.hpp>`.
|
||||
|
||||
To use `mem_fn` with `__fastcall` member functions, `#define` the macro
|
||||
`BOOST_MEM_FN_ENABLE_FASTCALL` before including `<boost/mem_fn.hpp>`.
|
||||
|
||||
To use `mem_fn` with `__cdecl` member functions, `#define` the macro
|
||||
`BOOST_MEM_FN_ENABLE_CDECL` before including `<boost/mem_fn.hpp>`.
|
||||
|
||||
[*It is best to define these macros in the project options, via `-D` on the
|
||||
command line, or as the first line in the translation unit (.cpp file) where
|
||||
`mem_fn` is used.] Not following this rule can lead to obscure errors when a
|
||||
header includes `mem_fn.hpp` before the macro has been defined.
|
||||
|
||||
/[Note:/ this is a non-portable extension. It is not part of the interface./]/
|
||||
|
||||
/[Note:/ Some compilers provide only minimal support for the `__stdcall` keyword./]/
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
133
doc/mem_fn/interface.qbk
Normal file
133
doc/mem_fn/interface.qbk
Normal file
@@ -0,0 +1,133 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2005 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:interface Interface]
|
||||
|
||||
[section:synopsys Synopsis]
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<class T> T * ``[link get_pointer_1 `get_pointer`]``(T * p);
|
||||
|
||||
template<class R, class T> ``/unspecified-1/`` ``[link mem_fn_1 `mem_fn`]``(R (T::*pmf) ());
|
||||
|
||||
template<class R, class T> ``/unspecified-2/`` ``[link mem_fn_2 `mem_fn`]``(R (T::*pmf) () const);
|
||||
|
||||
template<class R, class T> ``/unspecified-2-1/`` ``[link mem_fn_2_1 `mem_fn`]``(R T::*pm);
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-3/`` ``[link mem_fn_3 `mem_fn`]``(R (T::*pmf) (A1));
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-4/`` ``[link mem_fn_4 `mem_fn`]``(R (T::*pmf) (A1) const);
|
||||
|
||||
template<class R, class T, class A1, class A2> ``/unspecified-5/`` ``[link mem_fn_5 `mem_fn`]``(R (T::*pmf) (A1, A2));
|
||||
|
||||
template<class R, class T, class A1, class A2> ``/unspecified-6/`` ``[link mem_fn_6 `mem_fn`]``(R (T::*pmf) (A1, A2) const);
|
||||
|
||||
// implementation defined number of additional overloads for more arguments
|
||||
}
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Common requirements]
|
||||
|
||||
All /unspecified-N/ types mentioned in the Synopsis are /CopyConstructible/
|
||||
and /Assignable/. Their copy constructors and assignment operators do not
|
||||
throw exceptions. /unspecified-N/`::result_type` is defined as the return type
|
||||
of the member function pointer passed as an argument to `mem_fn` (`R` in the
|
||||
Synopsis.) /unspecified-2-1/`::result_type` is defined as `R`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `get_pointer`]
|
||||
|
||||
[#get_pointer_1]
|
||||
|
||||
template<class T> T * get_pointer(T * p)
|
||||
|
||||
* /Returns:/ `p`.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `mem_fn`]
|
||||
|
||||
[#mem_fn_1]
|
||||
|
||||
template<class R, class T> ``/unspecified-1/`` mem_fn(R (T::*pmf) ())
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t)` is
|
||||
equivalent to `(t.*pmf)()` when `t` is an l-value of type `T` or derived,
|
||||
`(get_pointer(t)->*pmf)()` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#mem_fn_2]
|
||||
|
||||
template<class R, class T> ``/unspecified-2/`` mem_fn(R (T::*pmf) () const)
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t)` is
|
||||
equivalent to `(t.*pmf)()` when `t` is of type `T` /[/`const`/]/ or derived,
|
||||
`(get_pointer(t)->*pmf)()` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#mem_fn_2_1]
|
||||
|
||||
template<class R, class T> ``/unspecified-2-1/`` mem_fn(R T::*pm)
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t)` is
|
||||
equivalent to `t.*pm` when `t` is of type `T` /[/`const`/]/ or derived,
|
||||
`get_pointer(t)->*pm` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#mem_fn_3]
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-3/`` mem_fn(R (T::*pmf) (A1))
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t, a1)`
|
||||
is equivalent to `(t.*pmf)(a1)` when `t` is an l-value of type `T` or derived,
|
||||
`(get_pointer(t)->*pmf)(a1)` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#mem_fn_4]
|
||||
|
||||
template<class R, class T, class A1> ``/unspecified-4/`` mem_fn(R (T::*pmf) (A1) const)
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t, a1)`
|
||||
is equivalent to `(t.*pmf)(a1)` when `t` is of type `T` /[/`const`/]/ or derived,
|
||||
`(get_pointer(t)->*pmf)(a1)` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#mem_fn_5]
|
||||
|
||||
template<class R, class T, class A1, class A2> ``/unspecified-5/`` mem_fn(R (T::*pmf) (A1, A2))
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t, a1, a2)`
|
||||
is equivalent to `(t.*pmf)(a1, a2)` when `t` is an l-value of type `T` or derived,
|
||||
`(get_pointer(t)->*pmf)(a1, a2)` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[#mem_fn_6]
|
||||
|
||||
template<class R, class T, class A1, class A2> ``/unspecified-6/`` mem_fn(R (T::*pmf) (A1, A2) const)
|
||||
|
||||
* /Returns:/ a function object \u03DD such that the expression \u03DD`(t, a1, a2)`
|
||||
is equivalent to `(t.*pmf)(a1, a2)` when `t` is of type `T` /[/`const`/]/ or derived,
|
||||
`(get_pointer(t)->*pmf)(a1, a2)` otherwise.
|
||||
|
||||
* /Throws:/ Nothing.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
93
doc/mem_fn/purpose.qbk
Normal file
93
doc/mem_fn/purpose.qbk
Normal file
@@ -0,0 +1,93 @@
|
||||
[/
|
||||
/ Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
/ Copyright (c) 2003-2005 Peter Dimov
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See
|
||||
/ accompanying file LICENSE_1_0.txt or copy at
|
||||
/ http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:purpose Purpose]
|
||||
|
||||
`boost::mem_fn` is a generalization of the standard functions `std::mem_fun`
|
||||
and `std::mem_fun_ref`. It supports member function pointers with more than
|
||||
one argument, and the returned function object can take a pointer, a
|
||||
reference, or a smart pointer to an object instance as its first argument.
|
||||
`mem_fn` also supports pointers to data members by treating them as functions
|
||||
taking no arguments and returning a (const) reference to the member.
|
||||
|
||||
The purpose of `mem_fn` is twofold. First, it allows users to invoke a member
|
||||
function on a container with the familiar
|
||||
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&Shape::draw));
|
||||
|
||||
syntax, even when the container stores smart pointers.
|
||||
|
||||
Second, it can be used as a building block by library developers that want to
|
||||
treat a pointer to member function as a function object. A library might
|
||||
define an enhanced `for_each` algorithm with an overload of the form:
|
||||
|
||||
template<class It, class R, class T> void for_each(It first, It last, R (T::*pmf) ())
|
||||
{
|
||||
std::for_each(first, last, boost::mem_fn(pmf));
|
||||
}
|
||||
|
||||
that will allow the convenient syntax:
|
||||
|
||||
for_each(v.begin(), v.end(), &Shape::draw);
|
||||
|
||||
When documenting the feature, the library author will simply state:
|
||||
|
||||
template<class It, class R, class T> void for_each(It first, It last, R (T::*pmf) ());
|
||||
|
||||
* /Effects:/ Equivalent to `std::for_each(first, last, boost::mem_fn(pmf))`.
|
||||
|
||||
where `boost::mem_fn` can be a link to this page. See the
|
||||
[@boost:/libs/bind/bind.html documentation of `bind`] for an example.
|
||||
|
||||
`mem_fn` takes one argument, a pointer to a member, and returns a function
|
||||
object suitable for use with standard or user-defined algorithms:
|
||||
|
||||
struct X
|
||||
{
|
||||
void f();
|
||||
};
|
||||
|
||||
void g(std::vector<X> & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
void h(std::vector<X *> const & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
void k(std::vector<boost::shared_ptr<X> > const & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
The returned function object takes the same arguments as the input member
|
||||
function plus a "flexible" first argument that represents the object instance.
|
||||
|
||||
When the function object is invoked with a first argument `x` that is neither
|
||||
a pointer nor a reference to the appropriate class (`X` in the example above),
|
||||
it uses `get_pointer(x)` to obtain a pointer from `x`. Library authors can
|
||||
"register" their smart pointer classes by supplying an appropriate
|
||||
`get_pointer` overload, allowing `mem_fn` to recognize and support them.
|
||||
|
||||
|
||||
/[Note:/ `get_pointer` is not restricted to return a pointer. Any object that
|
||||
can be used in a member function call expression `(x->*pmf)(...)` will work./]/
|
||||
|
||||
/[Note:/ the library uses an unqualified call to `get_pointer`. Therefore, it
|
||||
will find, through argument-dependent lookup, `get_pointer` overloads that are
|
||||
defined in the same namespace as the corresponding smart pointer class, in
|
||||
addition to any `boost::get_pointer` overloads./]/
|
||||
|
||||
All function objects returned by `mem_fn` expose a `result_type` typedef that
|
||||
represents the return type of the member function. For data members,
|
||||
`result_type` is defined as the type of the member.
|
||||
|
||||
[endsect]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,14 +2,13 @@
|
||||
#define BOOST_BIND_APPLY_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// apply.hpp
|
||||
// apply.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright 2002, 2003, 2024 Peter Dimov
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
namespace boost
|
||||
@@ -19,54 +18,9 @@ template<class R> struct apply
|
||||
{
|
||||
typedef R result_type;
|
||||
|
||||
template<class F> result_type operator()(F f) const
|
||||
template<class F, class... A> result_type operator()( F&& f, A&&... a ) const
|
||||
{
|
||||
return f();
|
||||
}
|
||||
|
||||
template<class F, class A1> result_type operator()(F f, A1 & a1) const
|
||||
{
|
||||
return f(a1);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2> result_type operator()(F f, A1 & a1, A2 & a2) const
|
||||
{
|
||||
return f(a1, a2);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3) const
|
||||
{
|
||||
return f(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
|
||||
{
|
||||
return f(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(F f, A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
|
||||
{
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
return static_cast<F&&>( f )( static_cast<A&&>( a )... );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
||||
#define BOOST_BIND_ARG_HPP_INCLUDED
|
||||
|
||||
#if _MSC_VER >= 1020
|
||||
#pragma once
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -10,21 +12,58 @@
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/is_placeholder.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<int I> class arg
|
||||
template<bool Eq> struct _arg_eq
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct _arg_eq<true>
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template< int I > struct arg
|
||||
{
|
||||
BOOST_CONSTEXPR arg()
|
||||
{
|
||||
}
|
||||
|
||||
template< class T > BOOST_CONSTEXPR arg( T const & /* t */, typename _arg_eq< I == is_placeholder<T>::value >::type * = 0 )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template< int I > BOOST_CONSTEXPR bool operator==( arg<I> const &, arg<I> const & )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template< int I > struct is_placeholder< arg<I> >
|
||||
{
|
||||
enum _vt { value = I };
|
||||
};
|
||||
|
||||
template< int I > struct is_placeholder< arg<I> (*) () >
|
||||
{
|
||||
enum _vt { value = I };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
||||
|
||||
813
include/boost/bind/bind.hpp
Normal file
813
include/boost/bind/bind.hpp
Normal file
@@ -0,0 +1,813 @@
|
||||
#ifndef BOOST_BIND_BIND_HPP_INCLUDED
|
||||
#define BOOST_BIND_BIND_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind.hpp - binds function objects to arguments
|
||||
//
|
||||
// Copyright 2001-2005, 2024 Peter Dimov
|
||||
// Copyright 2001 David Abrahams
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind for documentation.
|
||||
//
|
||||
|
||||
#include <boost/bind/mem_fn.hpp>
|
||||
#include <boost/bind/arg.hpp>
|
||||
#include <boost/bind/std_placeholders.hpp>
|
||||
#include <boost/bind/detail/result_traits.hpp>
|
||||
#include <boost/bind/detail/tuple_for_each.hpp>
|
||||
#include <boost/bind/detail/integer_sequence.hpp>
|
||||
#include <boost/visit_each.hpp>
|
||||
#include <boost/is_placeholder.hpp>
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> class weak_ptr;
|
||||
|
||||
namespace _bi // implementation details
|
||||
{
|
||||
|
||||
// ref_compare
|
||||
|
||||
template<class T> bool ref_compare( T const & a, T const & b )
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
template<int I> bool ref_compare( arg<I> const &, arg<I> const & )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<int I> bool ref_compare( arg<I> (*) (), arg<I> (*) () )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T> bool ref_compare( reference_wrapper<T> const & a, reference_wrapper<T> const & b )
|
||||
{
|
||||
return a.get_pointer() == b.get_pointer();
|
||||
}
|
||||
|
||||
// bind_t forward declaration for listN
|
||||
|
||||
template<class R, class F, class L> class bind_t;
|
||||
|
||||
template<class R, class F, class L> bool ref_compare( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b )
|
||||
{
|
||||
return a.compare( b );
|
||||
}
|
||||
|
||||
// value
|
||||
|
||||
template<class T> class value
|
||||
{
|
||||
public:
|
||||
|
||||
value(T const & t): t_(t) {}
|
||||
|
||||
T & get() { return t_; }
|
||||
T const & get() const { return t_; }
|
||||
|
||||
bool operator==(value const & rhs) const
|
||||
{
|
||||
return t_ == rhs.t_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T t_;
|
||||
};
|
||||
|
||||
// ref_compare for weak_ptr
|
||||
|
||||
template<class T> bool ref_compare( value< weak_ptr<T> > const & a, value< weak_ptr<T> > const & b )
|
||||
{
|
||||
return !(a.get() < b.get()) && !(b.get() < a.get());
|
||||
}
|
||||
|
||||
// type
|
||||
|
||||
template<class T> class type {};
|
||||
|
||||
// unwrap
|
||||
|
||||
template<class F> struct unwrapper
|
||||
{
|
||||
static inline F & unwrap( F & f, long )
|
||||
{
|
||||
return f;
|
||||
}
|
||||
|
||||
template<class F2> static inline F2 & unwrap( reference_wrapper<F2> rf, int )
|
||||
{
|
||||
return rf.get();
|
||||
}
|
||||
|
||||
template<class R, class T> static inline _mfi::dm<R, T> unwrap( R T::* pm, int )
|
||||
{
|
||||
return _mfi::dm<R, T>( pm );
|
||||
}
|
||||
};
|
||||
|
||||
// list
|
||||
|
||||
template<class V> struct accept_lambda
|
||||
{
|
||||
V& v_;
|
||||
|
||||
explicit accept_lambda( V& v ): v_( v ) {}
|
||||
|
||||
template<class A> void operator()( A& a ) const
|
||||
{
|
||||
visit_each( v_, a, 0 );
|
||||
}
|
||||
};
|
||||
|
||||
struct equal_lambda
|
||||
{
|
||||
bool result;
|
||||
|
||||
equal_lambda(): result( true ) {}
|
||||
|
||||
template<class A1, class A2> void operator()( A1& a1, A2& a2 )
|
||||
{
|
||||
result = result && ref_compare( a1, a2 );
|
||||
}
|
||||
};
|
||||
|
||||
struct logical_and;
|
||||
struct logical_or;
|
||||
|
||||
template<class... A> class list
|
||||
{
|
||||
private:
|
||||
|
||||
typedef std::tuple<A...> data_type;
|
||||
data_type data_;
|
||||
|
||||
public:
|
||||
|
||||
list( A... a ): data_( a... ) {}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4100 ) // unreferenced formal parameter 'a2'
|
||||
#endif
|
||||
|
||||
template<class R, class F, class A2, std::size_t... I> R call_impl( type<R>, F & f, A2 & a2, _bi::index_sequence<I...> )
|
||||
{
|
||||
return unwrapper<F>::unwrap( f, 0 )( a2[ std::get<I>( data_ ) ]... );
|
||||
}
|
||||
|
||||
template<class R, class F, class A2, std::size_t... I> R call_impl( type<R>, F & f, A2 & a2, _bi::index_sequence<I...> ) const
|
||||
{
|
||||
return unwrapper<F>::unwrap( f, 0 )( a2[ std::get<I>( data_ ) ]... );
|
||||
}
|
||||
|
||||
template<class F, class A2, std::size_t... I> void call_impl( type<void>, F & f, A2 & a2, _bi::index_sequence<I...> )
|
||||
{
|
||||
unwrapper<F>::unwrap( f, 0 )( a2[ std::get<I>( data_ ) ]... );
|
||||
}
|
||||
|
||||
template<class F, class A2, std::size_t... I> void call_impl( type<void>, F & f, A2 & a2, _bi::index_sequence<I...> ) const
|
||||
{
|
||||
unwrapper<F>::unwrap( f, 0 )( a2[ std::get<I>( data_ ) ]... );
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
//
|
||||
|
||||
template<class R, class F, class A2> R operator()( type<R>, F & f, A2 & a2 )
|
||||
{
|
||||
return call_impl( type<R>(), f, a2, _bi::index_sequence_for<A...>() );
|
||||
}
|
||||
|
||||
template<class R, class F, class A2> R operator()( type<R>, F & f, A2 & a2 ) const
|
||||
{
|
||||
return call_impl( type<R>(), f, a2, _bi::index_sequence_for<A...>() );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class A2> bool operator()( type<bool>, logical_and & /*f*/, A2 & a2 )
|
||||
{
|
||||
static_assert( sizeof...(A) == 2, "operator&& must have two arguments" );
|
||||
return a2[ std::get<0>( data_ ) ] && a2[ std::get<1>( data_ ) ];
|
||||
}
|
||||
|
||||
template<class A2> bool operator()( type<bool>, logical_and const & /*f*/, A2 & a2 ) const
|
||||
{
|
||||
static_assert( sizeof...(A) == 2, "operator&& must have two arguments" );
|
||||
return a2[ std::get<0>( data_ ) ] && a2[ std::get<1>( data_ ) ];
|
||||
}
|
||||
|
||||
template<class A2> bool operator()( type<bool>, logical_or & /*f*/, A2 & a2 )
|
||||
{
|
||||
static_assert( sizeof...(A) == 2, "operator|| must have two arguments" );
|
||||
return a2[ std::get<0>( data_ ) ] || a2[ std::get<1>( data_ ) ];
|
||||
}
|
||||
|
||||
template<class A2> bool operator()( type<bool>, logical_or const & /*f*/, A2 & a2 ) const
|
||||
{
|
||||
static_assert( sizeof...(A) == 2, "operator|| must have two arguments" );
|
||||
return a2[ std::get<0>( data_ ) ] || a2[ std::get<1>( data_ ) ];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class V> void accept( V & v ) const
|
||||
{
|
||||
_bi::tuple_for_each( accept_lambda<V>( v ), data_ );
|
||||
}
|
||||
|
||||
bool operator==( list const & rhs ) const
|
||||
{
|
||||
return _bi::tuple_for_each( equal_lambda(), data_, rhs.data_ ).result;
|
||||
}
|
||||
};
|
||||
|
||||
// bind_t
|
||||
|
||||
template<class... A> class rrlist
|
||||
{
|
||||
private:
|
||||
|
||||
using args_type = std::tuple<A...>;
|
||||
|
||||
using data_type = std::tuple<A&...>;
|
||||
data_type data_;
|
||||
|
||||
template<class...> friend class rrlist;
|
||||
|
||||
public:
|
||||
|
||||
explicit rrlist( A&... a ): data_( a... ) {}
|
||||
template<class... B> explicit rrlist( rrlist<B...> const& r ): data_( r.data_ ) {}
|
||||
|
||||
template<int I> typename std::tuple_element<I-1, args_type>::type&& operator[] ( boost::arg<I> ) const
|
||||
{
|
||||
return std::forward<typename std::tuple_element<I-1, args_type>::type>( std::get<I-1>( data_ ) );
|
||||
}
|
||||
|
||||
template<int I> typename std::tuple_element<I-1, args_type>::type&& operator[] ( boost::arg<I>(*)() ) const
|
||||
{
|
||||
return std::forward<typename std::tuple_element<I-1, args_type>::type>( std::get<I-1>( data_ ) );
|
||||
}
|
||||
|
||||
template<class T> T & operator[] ( _bi::value<T> & v ) const { return v.get(); }
|
||||
|
||||
template<class T> T const & operator[] ( _bi::value<T> const & v ) const { return v.get(); }
|
||||
|
||||
template<class T> T & operator[] ( reference_wrapper<T> const & v ) const { return v.get(); }
|
||||
|
||||
template<class R, class F, class L> typename result_traits<R, F>::type operator[] ( bind_t<R, F, L> & b ) const
|
||||
{
|
||||
rrlist<A&...> a2( *this );
|
||||
return b.eval( a2 );
|
||||
}
|
||||
|
||||
template<class R, class F, class L> typename result_traits<R, F>::type operator[] ( bind_t<R, F, L> const & b ) const
|
||||
{
|
||||
rrlist<A&...> a2( *this );
|
||||
return b.eval( a2 );
|
||||
}
|
||||
};
|
||||
|
||||
template<class R, class F, class L> class bind_t
|
||||
{
|
||||
private:
|
||||
|
||||
F f_;
|
||||
L l_;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename result_traits<R, F>::type result_type;
|
||||
typedef bind_t this_type;
|
||||
|
||||
bind_t( F f, L const & l ): f_( std::move(f) ), l_( l ) {}
|
||||
|
||||
//
|
||||
|
||||
template<class... A> result_type operator()( A&&... a )
|
||||
{
|
||||
rrlist<A...> a2( a... );
|
||||
return l_( type<result_type>(), f_, a2 );
|
||||
}
|
||||
|
||||
template<class... A> result_type operator()( A&&... a ) const
|
||||
{
|
||||
rrlist<A...> a2( a... );
|
||||
return l_( type<result_type>(), f_, a2 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class A> result_type eval( A & a )
|
||||
{
|
||||
return l_( type<result_type>(), f_, a );
|
||||
}
|
||||
|
||||
template<class A> result_type eval( A & a ) const
|
||||
{
|
||||
return l_( type<result_type>(), f_, a );
|
||||
}
|
||||
|
||||
template<class V> void accept( V & v ) const
|
||||
{
|
||||
using boost::visit_each;
|
||||
visit_each( v, f_, 0 );
|
||||
l_.accept( v );
|
||||
}
|
||||
|
||||
bool compare( this_type const & rhs ) const
|
||||
{
|
||||
return ref_compare( f_, rhs.f_ ) && l_ == rhs.l_;
|
||||
}
|
||||
};
|
||||
|
||||
// function_equal
|
||||
|
||||
template<class R, class F, class L> bool function_equal( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b )
|
||||
{
|
||||
return a.compare(b);
|
||||
}
|
||||
|
||||
// add_value
|
||||
|
||||
template< class T, int I > struct add_value_2
|
||||
{
|
||||
typedef boost::arg<I> type;
|
||||
};
|
||||
|
||||
template< class T > struct add_value_2< T, 0 >
|
||||
{
|
||||
typedef _bi::value< T > type;
|
||||
};
|
||||
|
||||
template<class T> struct add_value
|
||||
{
|
||||
typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type;
|
||||
};
|
||||
|
||||
template<class T> struct add_value< value<T> >
|
||||
{
|
||||
typedef _bi::value<T> type;
|
||||
};
|
||||
|
||||
template<class T> struct add_value< reference_wrapper<T> >
|
||||
{
|
||||
typedef reference_wrapper<T> type;
|
||||
};
|
||||
|
||||
template<int I> struct add_value< arg<I> >
|
||||
{
|
||||
typedef boost::arg<I> type;
|
||||
};
|
||||
|
||||
template<int I> struct add_value< arg<I> (*) () >
|
||||
{
|
||||
typedef boost::arg<I> (*type) ();
|
||||
};
|
||||
|
||||
template<class R, class F, class L> struct add_value< bind_t<R, F, L> >
|
||||
{
|
||||
typedef bind_t<R, F, L> type;
|
||||
};
|
||||
|
||||
// list_av
|
||||
|
||||
template<class... A> struct list_av
|
||||
{
|
||||
typedef list< typename add_value<A>::type... > type;
|
||||
};
|
||||
|
||||
// operator!
|
||||
|
||||
struct logical_not
|
||||
{
|
||||
template<class V> bool operator()(V const & v) const { return !v; }
|
||||
};
|
||||
|
||||
template<class R, class F, class L>
|
||||
bind_t< bool, logical_not, list< bind_t<R, F, L> > >
|
||||
operator! (bind_t<R, F, L> const & f)
|
||||
{
|
||||
typedef list< bind_t<R, F, L> > list_type;
|
||||
return bind_t<bool, logical_not, list_type> ( logical_not(), list_type(f) );
|
||||
}
|
||||
|
||||
// relational operators
|
||||
|
||||
#define BOOST_BIND_OPERATOR( op, name ) \
|
||||
\
|
||||
struct name \
|
||||
{ \
|
||||
template<class V, class W> bool operator()(V const & v, W const & w) const { return v op w; } \
|
||||
}; \
|
||||
\
|
||||
template<class R, class F, class L, class A2> \
|
||||
bind_t< bool, name, list< bind_t<R, F, L>, typename add_value<A2>::type > > \
|
||||
operator op (bind_t<R, F, L> const & f, A2 a2) \
|
||||
{ \
|
||||
typedef typename add_value<A2>::type B2; \
|
||||
typedef list< bind_t<R, F, L>, B2> list_type; \
|
||||
return bind_t<bool, name, list_type> ( name(), list_type(f, a2) ); \
|
||||
}
|
||||
|
||||
BOOST_BIND_OPERATOR( ==, equal )
|
||||
BOOST_BIND_OPERATOR( !=, not_equal )
|
||||
|
||||
BOOST_BIND_OPERATOR( <, less )
|
||||
BOOST_BIND_OPERATOR( <=, less_equal )
|
||||
|
||||
BOOST_BIND_OPERATOR( >, greater )
|
||||
BOOST_BIND_OPERATOR( >=, greater_equal )
|
||||
|
||||
BOOST_BIND_OPERATOR( &&, logical_and )
|
||||
BOOST_BIND_OPERATOR( ||, logical_or )
|
||||
|
||||
#undef BOOST_BIND_OPERATOR
|
||||
|
||||
// visit_each
|
||||
|
||||
template<class V, class T> void visit_each( V & v, value<T> const & t, int )
|
||||
{
|
||||
using boost::visit_each;
|
||||
visit_each( v, t.get(), 0 );
|
||||
}
|
||||
|
||||
template<class V, class R, class F, class L> void visit_each( V & v, bind_t<R, F, L> const & t, int )
|
||||
{
|
||||
t.accept( v );
|
||||
}
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
// is_bind_expression
|
||||
|
||||
template< class T > struct is_bind_expression
|
||||
{
|
||||
enum _vt { value = 0 };
|
||||
};
|
||||
|
||||
template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > >
|
||||
{
|
||||
enum _vt { value = 1 };
|
||||
};
|
||||
|
||||
// bind
|
||||
|
||||
#ifndef BOOST_BIND
|
||||
#define BOOST_BIND bind
|
||||
#endif
|
||||
|
||||
// generic function objects
|
||||
|
||||
#if !BOOST_WORKAROUND(__GNUC__, < 6)
|
||||
|
||||
template<class R, class F, class... A>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A...>::type>
|
||||
BOOST_BIND( F f, A... a )
|
||||
{
|
||||
typedef typename _bi::list_av<A...>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a... ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// g++ 4.x (and some 5.x) consider boost::bind<void>( &X::f )
|
||||
// ambiguous if the variadic form above is used
|
||||
|
||||
template<class R, class F>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<>::type>
|
||||
BOOST_BIND( F f )
|
||||
{
|
||||
typedef typename _bi::list_av<>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type() );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1>::type>
|
||||
BOOST_BIND( F f, A1 a1 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3, A4 a4 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3, a4 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3, a4, a5 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3, a4, a5, a6 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3, a4, a5, a6, a7 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3, a4, a5, a6, a7, a8 ) );
|
||||
}
|
||||
|
||||
template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND( F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 )
|
||||
{
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a1, a2, a3, a4, a5, a6, a7, a8, a9 ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// generic function objects, alternative syntax
|
||||
|
||||
template<class R, class F, class... A>
|
||||
_bi::bind_t<R, F, typename _bi::list_av<A...>::type>
|
||||
BOOST_BIND( boost::type<R>, F f, A... a )
|
||||
{
|
||||
typedef typename _bi::list_av<A...>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>( std::move(f), list_type( a... ) );
|
||||
}
|
||||
|
||||
// adaptable function objects
|
||||
|
||||
template<class F, class... A>
|
||||
_bi::bind_t<_bi::unspecified, F, typename _bi::list_av<A...>::type>
|
||||
BOOST_BIND( F f, A... a )
|
||||
{
|
||||
typedef typename _bi::list_av<A...>::type list_type;
|
||||
return _bi::bind_t<_bi::unspecified, F, list_type>( std::move(f), list_type( a... ) );
|
||||
}
|
||||
|
||||
// function pointers
|
||||
|
||||
#define BOOST_BIND_CC
|
||||
#define BOOST_BIND_ST
|
||||
#define BOOST_BIND_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_cc.hpp>
|
||||
|
||||
# if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
# undef BOOST_BIND_NOEXCEPT
|
||||
# define BOOST_BIND_NOEXCEPT noexcept
|
||||
# include <boost/bind/detail/bind_cc.hpp>
|
||||
# endif
|
||||
|
||||
#undef BOOST_BIND_CC
|
||||
#undef BOOST_BIND_ST
|
||||
#undef BOOST_BIND_NOEXCEPT
|
||||
|
||||
#if defined(BOOST_BIND_ENABLE_STDCALL) && !defined(_M_X64)
|
||||
|
||||
#define BOOST_BIND_CC __stdcall
|
||||
#define BOOST_BIND_ST
|
||||
#define BOOST_BIND_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_cc.hpp>
|
||||
|
||||
#undef BOOST_BIND_CC
|
||||
#undef BOOST_BIND_ST
|
||||
#undef BOOST_BIND_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_BIND_ENABLE_FASTCALL) && !defined(_M_X64)
|
||||
|
||||
#define BOOST_BIND_CC __fastcall
|
||||
#define BOOST_BIND_ST
|
||||
#define BOOST_BIND_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_cc.hpp>
|
||||
|
||||
#undef BOOST_BIND_CC
|
||||
#undef BOOST_BIND_ST
|
||||
#undef BOOST_BIND_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_BIND_ENABLE_PASCAL
|
||||
|
||||
#define BOOST_BIND_ST pascal
|
||||
#define BOOST_BIND_CC
|
||||
#define BOOST_BIND_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_cc.hpp>
|
||||
|
||||
#undef BOOST_BIND_ST
|
||||
#undef BOOST_BIND_CC
|
||||
#undef BOOST_BIND_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
// member function pointers
|
||||
|
||||
#define BOOST_BIND_MF_NAME(X) X
|
||||
#define BOOST_BIND_MF_CC
|
||||
#define BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_mf_cc.hpp>
|
||||
#include <boost/bind/detail/bind_mf2_cc.hpp>
|
||||
|
||||
# if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
# undef BOOST_BIND_MF_NOEXCEPT
|
||||
# define BOOST_BIND_MF_NOEXCEPT noexcept
|
||||
# include <boost/bind/detail/bind_mf_cc.hpp>
|
||||
# include <boost/bind/detail/bind_mf2_cc.hpp>
|
||||
# endif
|
||||
|
||||
#undef BOOST_BIND_MF_NAME
|
||||
#undef BOOST_BIND_MF_CC
|
||||
#undef BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
|
||||
|
||||
#define BOOST_BIND_MF_NAME(X) X##_cdecl
|
||||
#define BOOST_BIND_MF_CC __cdecl
|
||||
#define BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_mf_cc.hpp>
|
||||
#include <boost/bind/detail/bind_mf2_cc.hpp>
|
||||
|
||||
#undef BOOST_BIND_MF_NAME
|
||||
#undef BOOST_BIND_MF_CC
|
||||
#undef BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
|
||||
|
||||
#define BOOST_BIND_MF_NAME(X) X##_stdcall
|
||||
#define BOOST_BIND_MF_CC __stdcall
|
||||
#define BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_mf_cc.hpp>
|
||||
#include <boost/bind/detail/bind_mf2_cc.hpp>
|
||||
|
||||
#undef BOOST_BIND_MF_NAME
|
||||
#undef BOOST_BIND_MF_CC
|
||||
#undef BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
|
||||
|
||||
#define BOOST_BIND_MF_NAME(X) X##_fastcall
|
||||
#define BOOST_BIND_MF_CC __fastcall
|
||||
#define BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#include <boost/bind/detail/bind_mf_cc.hpp>
|
||||
#include <boost/bind/detail/bind_mf2_cc.hpp>
|
||||
|
||||
#undef BOOST_BIND_MF_NAME
|
||||
#undef BOOST_BIND_MF_CC
|
||||
#undef BOOST_BIND_MF_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
// data member pointers
|
||||
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
template<class M, int I> struct add_cref;
|
||||
|
||||
template<class M> struct add_cref<M, 0>
|
||||
{
|
||||
typedef M type;
|
||||
};
|
||||
|
||||
template<class M> struct add_cref<M, 1>
|
||||
{
|
||||
typedef M const& type;
|
||||
};
|
||||
|
||||
template<class R> struct isref
|
||||
{
|
||||
enum value_type { value = 0 };
|
||||
};
|
||||
|
||||
template<class R> struct isref< R& >
|
||||
{
|
||||
enum value_type { value = 1 };
|
||||
};
|
||||
|
||||
template<class R> struct isref< R* >
|
||||
{
|
||||
enum value_type { value = 1 };
|
||||
};
|
||||
|
||||
template<class M, class A1, bool fn = std::is_function<M>::value> struct dm_result
|
||||
{
|
||||
};
|
||||
|
||||
template<class M, class A1> struct dm_result<M, A1, false>
|
||||
{
|
||||
typedef typename add_cref< M, 1 >::type type;
|
||||
};
|
||||
|
||||
template<class M, class R, class F, class L> struct dm_result<M, bind_t<R, F, L>, false>
|
||||
{
|
||||
typedef typename bind_t<R, F, L>::result_type result_type;
|
||||
typedef typename add_cref< M, isref< result_type >::value >::type type;
|
||||
};
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
template<class A1, class M, class T>
|
||||
|
||||
_bi::bind_t<
|
||||
typename _bi::dm_result<M, A1>::type,
|
||||
_mfi::dm<M, T>,
|
||||
typename _bi::list_av<A1>::type
|
||||
>
|
||||
|
||||
BOOST_BIND( M T::*f, A1 a1 )
|
||||
{
|
||||
typedef typename _bi::dm_result<M, A1>::type result_type;
|
||||
typedef _mfi::dm<M, T> F;
|
||||
typedef typename _bi::list_av<A1>::type list_type;
|
||||
return _bi::bind_t< result_type, F, list_type >( F( f ), list_type( a1 ) );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#ifndef BOOST_BIND_NO_PLACEHOLDERS
|
||||
|
||||
# include <boost/bind/placeholders.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(default: 4512) // assignment operator could not be generated
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_BIND_BIND_HPP_INCLUDED
|
||||
@@ -1,228 +0,0 @@
|
||||
//
|
||||
// bind/bind_mf_cc.hpp - support for different calling conventions
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
// 0
|
||||
|
||||
template<class R, class T,
|
||||
class A1>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf0)<R, T>, typename _bi::list_av_1<A1>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (), A1 a1)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf0)<R, T> F;
|
||||
typedef typename _bi::list_av_1<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class A1>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T>, typename _bi::list_av_1<A1>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () const, A1 a1)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T> F;
|
||||
typedef typename _bi::list_av_1<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
|
||||
}
|
||||
|
||||
// 1
|
||||
|
||||
template<class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1), A1 a1, A2 a2)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1> F;
|
||||
typedef typename _bi::list_av_2<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) const, A1 a1, A2 a2)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1> F;
|
||||
typedef typename _bi::list_av_2<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2));
|
||||
}
|
||||
|
||||
// 2
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2), A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2> F;
|
||||
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) const, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2> F;
|
||||
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3));
|
||||
}
|
||||
|
||||
// 3
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3), A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3> F;
|
||||
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3> F;
|
||||
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
// 4
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf4)<R, T, B1, B2, B3, B4>, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf4)<R, T, B1, B2, B3, B4> F;
|
||||
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf4)<R, T, B1, B2, B3, B4>, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf4)<R, T, B1, B2, B3, B4> F;
|
||||
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
// 5
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf5)<R, T, B1, B2, B3, B4, B5>, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf5)<R, T, B1, B2, B3, B4, B5> F;
|
||||
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf5)<R, T, B1, B2, B3, B4, B5>, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf5)<R, T, B1, B2, B3, B4, B5> F;
|
||||
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
// 6
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf6)<R, T, B1, B2, B3, B4, B5, B6>, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf6)<R, T, B1, B2, B3, B4, B5, B6> F;
|
||||
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf6)<R, T, B1, B2, B3, B4, B5, B6>, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf6)<R, T, B1, B2, B3, B4, B5, B6> F;
|
||||
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
// 7
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf7)<R, T, B1, B2, B3, B4, B5, B6, B7>, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf7)<R, T, B1, B2, B3, B4, B5, B6, B7> F;
|
||||
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf7)<R, T, B1, B2, B3, B4, B5, B6, B7>, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf7)<R, T, B1, B2, B3, B4, B5, B6, B7> F;
|
||||
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
// 8
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8>, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(mf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8> F;
|
||||
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8>, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
typedef _mfi::BOOST_BIND_MF_NAME(cmf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8> F;
|
||||
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
//
|
||||
// bind/bind_template.hpp
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
typedef typename result_traits<R, F>::type result_type;
|
||||
|
||||
result_type operator()()
|
||||
{
|
||||
list0 a;
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
result_type operator()() const
|
||||
{
|
||||
list0 a;
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1)
|
||||
{
|
||||
list1<A1 &> a(a1);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1) const
|
||||
{
|
||||
list1<A1 &> a(a1);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
||||
{
|
||||
list2<A1 &, A2 &> a(a1, a2);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2) const
|
||||
{
|
||||
list2<A1 &, A2 &> a(a1, a2);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
||||
{
|
||||
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3) const
|
||||
{
|
||||
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
|
||||
{
|
||||
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
|
||||
{
|
||||
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5)
|
||||
{
|
||||
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
|
||||
{
|
||||
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6)
|
||||
{
|
||||
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
|
||||
{
|
||||
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7)
|
||||
{
|
||||
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
|
||||
{
|
||||
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8)
|
||||
{
|
||||
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
|
||||
{
|
||||
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9)
|
||||
{
|
||||
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
|
||||
{
|
||||
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A> result_type eval(A & a)
|
||||
{
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class A> result_type eval(A & a) const
|
||||
{
|
||||
BOOST_BIND_EVALUATE;
|
||||
}
|
||||
|
||||
template<class V> void accept(V & v) const
|
||||
{
|
||||
BOOST_BIND_VISIT_EACH(v, f_, 0);
|
||||
l_.accept(v);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
L l_;
|
||||
@@ -5,114 +5,113 @@
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
template<class R>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (), _bi::list0>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) ())
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) () BOOST_BIND_NOEXCEPT, typename _bi::list_av<>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) () BOOST_BIND_NOEXCEPT)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) ();
|
||||
typedef _bi::list0 list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) () BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type> (f, list_type());
|
||||
}
|
||||
|
||||
template<class R, class B1, class A1>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1), typename _bi::list_av_1<A1>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1), A1 a1)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1) BOOST_BIND_NOEXCEPT, A1 a1)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1);
|
||||
typedef typename _bi::list_av_1<A1>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type> (f, list_type(a1));
|
||||
}
|
||||
|
||||
template<class R, class B1, class B2, class A1, class A2>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2), typename _bi::list_av_2<A1, A2>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2), A1 a1, A2 a2)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2);
|
||||
typedef typename _bi::list_av_2<A1, A2>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3), typename _bi::list_av_3<A1, A2, A3>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3), A1 a1, A2 a2, A3 a3)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3);
|
||||
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4), typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3, A4>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4);
|
||||
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5), typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3, A4, A5>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5);
|
||||
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6), typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3, A4, A5, A6>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6);
|
||||
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7), typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7);
|
||||
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8), typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8);
|
||||
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
template<class R,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8, class B9,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8, B9), typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8, B9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8, B9) BOOST_BIND_NOEXCEPT, typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
|
||||
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8, B9) BOOST_BIND_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8, B9);
|
||||
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8, B9) BOOST_BIND_NOEXCEPT;
|
||||
typedef typename _bi::list_av<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
|
||||
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
210
include/boost/bind/detail/bind_mf2_cc.hpp
Normal file
210
include/boost/bind/detail/bind_mf2_cc.hpp
Normal file
@@ -0,0 +1,210 @@
|
||||
//
|
||||
// bind/bind_mf2_cc.hpp - member functions, type<> syntax
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2008 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
// 0
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class A1>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) () BOOST_BIND_MF_NOEXCEPT, A1 a1)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class A1>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) () const BOOST_BIND_MF_NOEXCEPT, A1 a1)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1 );
|
||||
}
|
||||
|
||||
// 1
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2 );
|
||||
}
|
||||
|
||||
// 2
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3 );
|
||||
}
|
||||
|
||||
// 3
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4 );
|
||||
}
|
||||
|
||||
// 4
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5 );
|
||||
}
|
||||
|
||||
// 5
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 );
|
||||
}
|
||||
|
||||
// 6
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 );
|
||||
}
|
||||
|
||||
// 7
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 );
|
||||
}
|
||||
|
||||
// 8
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
auto
|
||||
BOOST_BIND(boost::type<Rt2>, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
-> decltype( boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::type<Rt2>(), boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 );
|
||||
}
|
||||
405
include/boost/bind/detail/bind_mf_cc.hpp
Normal file
405
include/boost/bind/detail/bind_mf_cc.hpp
Normal file
@@ -0,0 +1,405 @@
|
||||
//
|
||||
// bind/bind_mf_cc.hpp - support for different calling conventions
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
// 0
|
||||
|
||||
template<class R, class T,
|
||||
class A1>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () BOOST_BIND_MF_NOEXCEPT, A1 a1)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class A1>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () const BOOST_BIND_MF_NOEXCEPT, A1 a1)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class A1,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () BOOST_BIND_MF_NOEXCEPT, A1 a1)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class A1,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () const BOOST_BIND_MF_NOEXCEPT, A1 a1)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1 );
|
||||
}
|
||||
|
||||
// 1
|
||||
|
||||
template<class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1,
|
||||
class A1, class A2>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1,
|
||||
class A1, class A2,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1,
|
||||
class A1, class A2,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2 );
|
||||
}
|
||||
|
||||
// 2
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2,
|
||||
class A1, class A2, class A3,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3 );
|
||||
}
|
||||
|
||||
// 3
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3,
|
||||
class A1, class A2, class A3, class A4,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4 );
|
||||
}
|
||||
|
||||
// 4
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4,
|
||||
class A1, class A2, class A3, class A4, class A5,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5 );
|
||||
}
|
||||
|
||||
// 5
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6 );
|
||||
}
|
||||
|
||||
// 6
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7 );
|
||||
}
|
||||
|
||||
// 7
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8 );
|
||||
}
|
||||
|
||||
// 8
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 );
|
||||
}
|
||||
|
||||
template<class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
-> decltype( boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
{
|
||||
return boost::BOOST_BIND( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 );
|
||||
}
|
||||
|
||||
template<class Rt2, class R, class T,
|
||||
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
|
||||
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9,
|
||||
class En = typename std::enable_if< !std::is_same<Rt2, R>::value >::type>
|
||||
auto
|
||||
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) const BOOST_BIND_MF_NOEXCEPT, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
-> decltype( boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
{
|
||||
return boost::BOOST_BIND<Rt2>( boost::mem_fn( f ), a1, a2, a3, a4, a5, a6, a7, a8, a9 );
|
||||
}
|
||||
111
include/boost/bind/detail/integer_sequence.hpp
Normal file
111
include/boost/bind/detail/integer_sequence.hpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef BOOST_BIND_DETAIL_INTEGER_SEQUENCE_HPP_INCLUDED
|
||||
#define BOOST_BIND_DETAIL_INTEGER_SEQUENCE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2015, 2017, 2019 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__make_integer_seq)
|
||||
# define BOOST_BIND_DETAIL_HAS_MAKE_INTEGER_SEQ
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
// integer_sequence
|
||||
template<class T, T... I> struct integer_sequence
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(BOOST_BIND_DETAIL_HAS_MAKE_INTEGER_SEQ)
|
||||
|
||||
template<class T, T N> using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
|
||||
|
||||
#else
|
||||
|
||||
// detail::make_integer_sequence_impl
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// iseq_if_c
|
||||
template<bool C, class T, class E> struct iseq_if_c_impl;
|
||||
|
||||
template<class T, class E> struct iseq_if_c_impl<true, T, E>
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<class T, class E> struct iseq_if_c_impl<false, T, E>
|
||||
{
|
||||
using type = E;
|
||||
};
|
||||
|
||||
template<bool C, class T, class E> using iseq_if_c = typename iseq_if_c_impl<C, T, E>::type;
|
||||
|
||||
// iseq_identity
|
||||
template<class T> struct iseq_identity
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<class S1, class S2> struct append_integer_sequence;
|
||||
|
||||
template<class T, T... I, T... J> struct append_integer_sequence<integer_sequence<T, I...>, integer_sequence<T, J...>>
|
||||
{
|
||||
using type = integer_sequence< T, I..., ( J + sizeof...(I) )... >;
|
||||
};
|
||||
|
||||
template<class T, T N> struct make_integer_sequence_impl;
|
||||
|
||||
template<class T, T N> struct make_integer_sequence_impl_
|
||||
{
|
||||
private:
|
||||
|
||||
static_assert( N >= 0, "make_integer_sequence<T, N>: N must not be negative" );
|
||||
|
||||
static T const M = N / 2;
|
||||
static T const R = N % 2;
|
||||
|
||||
using S1 = typename make_integer_sequence_impl<T, M>::type;
|
||||
using S2 = typename append_integer_sequence<S1, S1>::type;
|
||||
using S3 = typename make_integer_sequence_impl<T, R>::type;
|
||||
using S4 = typename append_integer_sequence<S2, S3>::type;
|
||||
|
||||
public:
|
||||
|
||||
using type = S4;
|
||||
};
|
||||
|
||||
template<class T, T N> struct make_integer_sequence_impl: iseq_if_c<N == 0, iseq_identity<integer_sequence<T>>, iseq_if_c<N == 1, iseq_identity<integer_sequence<T, 0>>, make_integer_sequence_impl_<T, N> > >
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// make_integer_sequence
|
||||
template<class T, T N> using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
|
||||
|
||||
#endif // defined(BOOST_BIND_DETAIL_HAS_MAKE_INTEGER_SEQ)
|
||||
|
||||
// index_sequence
|
||||
template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
|
||||
|
||||
// make_index_sequence
|
||||
template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
|
||||
|
||||
// index_sequence_for
|
||||
template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
|
||||
|
||||
} // namespace _bi
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_DETAIL_INTEGER_SEQUENCE_HPP_INCLUDED
|
||||
165
include/boost/bind/detail/result_traits.hpp
Normal file
165
include/boost/bind/detail/result_traits.hpp
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind/detail/result_traits.hpp
|
||||
//
|
||||
// boost/bind.hpp support header, return type deduction
|
||||
//
|
||||
// Copyright 2006, 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201700L
|
||||
#include <functional>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
template<class R, class F> struct result_traits
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
struct unspecified {};
|
||||
|
||||
template<class F> struct result_traits<unspecified, F>
|
||||
{
|
||||
typedef typename F::result_type type;
|
||||
};
|
||||
|
||||
template<class F> struct result_traits< unspecified, reference_wrapper<F> >
|
||||
{
|
||||
typedef typename F::result_type type;
|
||||
};
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201700L
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::plus<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::minus<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::multiplies<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::divides<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::modulus<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::negate<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::equal_to<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::not_equal_to<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::greater<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::less<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::greater_equal<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::less_equal<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::logical_and<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::logical_or<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::logical_not<T> >
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::bit_and<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::bit_or<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::bit_xor<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 40900
|
||||
|
||||
// libstdc++ 4.8 and below don't have std::bit_not
|
||||
|
||||
#else
|
||||
|
||||
template<class T> struct result_traits< unspecified, std::bit_not<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED
|
||||
64
include/boost/bind/detail/tuple_for_each.hpp
Normal file
64
include/boost/bind/detail/tuple_for_each.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef BOOST_BIND_DETAIL_TUPLE_FOR_EACH_HPP_INCLUDED
|
||||
#define BOOST_BIND_DETAIL_TUPLE_FOR_EACH_HPP_INCLUDED
|
||||
|
||||
// Copyright 2015-2020, 2024 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/bind/detail/integer_sequence.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4100 ) // unreferenced formal parameter 'tp'
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
// tuple_for_each( f, tp )
|
||||
|
||||
template<class F, class Tp, std::size_t... J> F tuple_for_each_impl( F&& f, Tp&& tp, integer_sequence<std::size_t, J...> )
|
||||
{
|
||||
using A = int[ 1 + sizeof...(J) ];
|
||||
using std::get;
|
||||
return (void)A{ 0, ((void)f(get<J>(std::forward<Tp>(tp))), 0)... }, std::forward<F>(f);
|
||||
}
|
||||
|
||||
template<class F, class Tp> F tuple_for_each( F&& f, Tp&& tp )
|
||||
{
|
||||
using seq = make_index_sequence<std::tuple_size<typename std::remove_reference<Tp>::type>::value>;
|
||||
return _bi::tuple_for_each_impl( std::forward<F>(f), std::forward<Tp>(tp), seq() );
|
||||
}
|
||||
|
||||
// tuple_for_each( f, tp1, tp2 )
|
||||
|
||||
template<class F, class Tp1, class Tp2, std::size_t... J> F tuple_for_each_impl( F&& f, Tp1&& tp1, Tp2&& tp2, integer_sequence<std::size_t, J...> )
|
||||
{
|
||||
using A = int[ 1 + sizeof...(J) ];
|
||||
using std::get;
|
||||
return (void)A{ 0, ((void)f( get<J>(std::forward<Tp1>(tp1)), get<J>(std::forward<Tp2>(tp2)) ), 0)... }, std::forward<F>(f);
|
||||
}
|
||||
|
||||
template<class F, class Tp1, class Tp2> F tuple_for_each( F&& f, Tp1&& tp1, Tp2&& tp2 )
|
||||
{
|
||||
using seq = make_index_sequence<std::tuple_size<typename std::remove_reference<Tp1>::type>::value>;
|
||||
return _bi::tuple_for_each_impl( std::forward<F>(f), std::forward<Tp1>(tp1), std::forward<Tp2>(tp2), seq() );
|
||||
}
|
||||
|
||||
} // namespace _bi
|
||||
} // namespace boost
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_BIND_DETAIL_TUPLE_FOR_EACH_HPP_INCLUDED
|
||||
@@ -6,10 +6,9 @@
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
namespace boost
|
||||
@@ -18,10 +17,6 @@ namespace boost
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
template<class F> void instantiate(F)
|
||||
{
|
||||
}
|
||||
|
||||
template<class R, class F> class af0
|
||||
{
|
||||
public:
|
||||
@@ -37,6 +32,11 @@ public:
|
||||
return f_();
|
||||
}
|
||||
|
||||
result_type operator()() const
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
@@ -59,6 +59,11 @@ public:
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1) const
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
@@ -83,6 +88,11 @@ public:
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
@@ -106,6 +116,11 @@ public:
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
@@ -130,6 +145,11 @@ public:
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
@@ -139,31 +159,26 @@ private:
|
||||
|
||||
template<class R, class F> _bi::af0<R, F> make_adaptable(F f)
|
||||
{
|
||||
_bi::instantiate( &_bi::af0<R, F>::operator() ); // for early error detection
|
||||
return _bi::af0<R, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class F> _bi::af1<R, A1, F> make_adaptable(F f)
|
||||
{
|
||||
instantiate( &_bi::af1<R, A1, F>::operator() );
|
||||
return _bi::af1<R, A1, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class A2, class F> _bi::af2<R, A1, A2, F> make_adaptable(F f)
|
||||
{
|
||||
instantiate( &_bi::af2<R, A1, A2, F>::operator() );
|
||||
return _bi::af2<R, A1, A2, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class A2, class A3, class F> _bi::af3<R, A1, A2, A3, F> make_adaptable(F f)
|
||||
{
|
||||
instantiate( &_bi::af3<R, A1, A2, A3, F>::operator() );
|
||||
return _bi::af3<R, A1, A2, A3, F>(f);
|
||||
}
|
||||
|
||||
template<class R, class A1, class A2, class A3, class A4, class F> _bi::af4<R, A1, A2, A3, A4, F> make_adaptable(F f)
|
||||
{
|
||||
instantiate( &_bi::af4<R, A1, A2, A3, A4, F>::operator() );
|
||||
return _bi::af4<R, A1, A2, A3, A4, F>(f);
|
||||
}
|
||||
|
||||
|
||||
253
include/boost/bind/mem_fn.hpp
Normal file
253
include/boost/bind/mem_fn.hpp
Normal file
@@ -0,0 +1,253 @@
|
||||
#ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
|
||||
#define BOOST_BIND_MEM_FN_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// mem_fn.hpp - a generalization of std::mem_fun[_ref]
|
||||
//
|
||||
// Copyright 2001-2005, 2024 Peter Dimov
|
||||
// Copyright 2001 David Abrahams
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
template<class T> struct remove_cvref: std::remove_cv< typename std::remove_reference<T>::type >
|
||||
{
|
||||
};
|
||||
|
||||
template<class Pm, class R, class T, class... A> class mf
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
Pm pm_;
|
||||
|
||||
public:
|
||||
|
||||
mf( Pm pm ): pm_( pm ) {}
|
||||
|
||||
template<class U,
|
||||
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||
class En = typename std::enable_if<
|
||||
std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value
|
||||
>::type
|
||||
>
|
||||
|
||||
R operator()( U&& u, A... a ) const
|
||||
{
|
||||
return (std::forward<U>( u ).*pm_)( std::forward<A>( a )... );
|
||||
}
|
||||
|
||||
template<class U,
|
||||
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||
class E1 = void,
|
||||
class En = typename std::enable_if<
|
||||
!(std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value)
|
||||
>::type
|
||||
>
|
||||
|
||||
R operator()( U&& u, A... a ) const
|
||||
{
|
||||
return (get_pointer( std::forward<U>( u ) )->*pm_)( std::forward<A>( a )... );
|
||||
}
|
||||
|
||||
bool operator==( mf const & rhs ) const
|
||||
{
|
||||
return pm_ == rhs.pm_;
|
||||
}
|
||||
|
||||
bool operator!=( mf const & rhs ) const
|
||||
{
|
||||
return pm_ != rhs.pm_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
//
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (T::*pmf) (A...) ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (T::*pmf) (A...) const ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (T::*pmf) (A...) noexcept ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (T::*pmf) (A...) const noexcept ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
#endif // #if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
|
||||
#if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (__cdecl T::*pmf) (A...) ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (__cdecl T::*pmf) (A...) const ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
|
||||
|
||||
#if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (__stdcall T::*pmf) (A...) ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (__stdcall T::*pmf) (A...) const ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
|
||||
|
||||
#if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (__fastcall T::*pmf) (A...) ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
template<class R, class T, class... A>
|
||||
auto mem_fn( R (__fastcall T::*pmf) (A...) const ) -> _mfi::mf<decltype(pmf), R, T, A...>
|
||||
{
|
||||
return pmf;
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
|
||||
|
||||
// data member support
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
template<class R, class T> class dm
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R const & result_type;
|
||||
typedef T const * argument_type;
|
||||
|
||||
private:
|
||||
|
||||
typedef R (T::*Pm);
|
||||
Pm pm_;
|
||||
|
||||
public:
|
||||
|
||||
dm( Pm pm ): pm_( pm ) {}
|
||||
|
||||
template<class U,
|
||||
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||
class En = typename std::enable_if<
|
||||
std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value
|
||||
>::type
|
||||
>
|
||||
|
||||
auto operator()( U&& u ) const -> decltype( std::forward<U>( u ).*pm_ )
|
||||
{
|
||||
return std::forward<U>( u ).*pm_;
|
||||
}
|
||||
|
||||
template<class U,
|
||||
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||
class E1 = void,
|
||||
class En = typename std::enable_if<
|
||||
!(std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value)
|
||||
>::type
|
||||
>
|
||||
|
||||
auto operator()( U&& u ) const -> decltype( get_pointer( std::forward<U>( u ) )->*pm_ )
|
||||
{
|
||||
return get_pointer( std::forward<U>( u ) )->*pm_;
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
|
||||
template<class U>
|
||||
R& operator()( U* u ) const
|
||||
{
|
||||
return u->*pm_;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
R const& operator()( U const* u ) const
|
||||
{
|
||||
return u->*pm_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool operator==( dm const & rhs ) const
|
||||
{
|
||||
return pm_ == rhs.pm_;
|
||||
}
|
||||
|
||||
bool operator!=( dm const & rhs ) const
|
||||
{
|
||||
return pm_ != rhs.pm_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
template<class R, class T,
|
||||
class E = typename std::enable_if< !std::is_function<R>::value >::type
|
||||
>
|
||||
_mfi::dm<R, T> mem_fn( R T::*pm )
|
||||
{
|
||||
return pm;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
|
||||
@@ -1,104 +0,0 @@
|
||||
//
|
||||
// bind/mem_fn_cc.hpp - support for different calling conventions
|
||||
//
|
||||
// Do not include this header directly.
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
template<class R, class T> _mfi::BOOST_MEM_FN_NAME(mf0)<R, T> mem_fn(R (BOOST_MEM_FN_CC T::*f) ())
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf0)<R, T>(f);
|
||||
}
|
||||
|
||||
template<class R, class T> _mfi::BOOST_MEM_FN_NAME(cmf0)<R, T> mem_fn(R (BOOST_MEM_FN_CC T::*f) () const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf0)<R, T>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1> _mfi::BOOST_MEM_FN_NAME(mf1)<R, T, A1> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf1)<R, T, A1>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1> _mfi::BOOST_MEM_FN_NAME(cmf1)<R, T, A1> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf1)<R, T, A1>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2> _mfi::BOOST_MEM_FN_NAME(mf2)<R, T, A1, A2> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf2)<R, T, A1, A2>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2> _mfi::BOOST_MEM_FN_NAME(cmf2)<R, T, A1, A2> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf2)<R, T, A1, A2>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> _mfi::BOOST_MEM_FN_NAME(mf3)<R, T, A1, A2, A3> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf3)<R, T, A1, A2, A3>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> _mfi::BOOST_MEM_FN_NAME(cmf3)<R, T, A1, A2, A3> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf3)<R, T, A1, A2, A3>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::BOOST_MEM_FN_NAME(mf4)<R, T, A1, A2, A3, A4> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf4)<R, T, A1, A2, A3, A4>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::BOOST_MEM_FN_NAME(cmf4)<R, T, A1, A2, A3, A4> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf4)<R, T, A1, A2, A3, A4>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::BOOST_MEM_FN_NAME(mf5)<R, T, A1, A2, A3, A4, A5> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf5)<R, T, A1, A2, A3, A4, A5>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::BOOST_MEM_FN_NAME(cmf5)<R, T, A1, A2, A3, A4, A5> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf5)<R, T, A1, A2, A3, A4, A5>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::BOOST_MEM_FN_NAME(mf6)<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf6)<R, T, A1, A2, A3, A4, A5, A6>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::BOOST_MEM_FN_NAME(cmf6)<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf6)<R, T, A1, A2, A3, A4, A5, A6>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::BOOST_MEM_FN_NAME(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::BOOST_MEM_FN_NAME(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::BOOST_MEM_FN_NAME(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7, A8))
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
|
||||
}
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::BOOST_MEM_FN_NAME(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7, A8) const)
|
||||
{
|
||||
return _mfi::BOOST_MEM_FN_NAME(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
|
||||
}
|
||||
@@ -1,755 +0,0 @@
|
||||
//
|
||||
// bind/mem_fn_template.hpp
|
||||
//
|
||||
// Do not include this header directly
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
// mf0
|
||||
|
||||
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf0)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) ())
|
||||
F f_;
|
||||
|
||||
template<class U> R call(U & u, T const *) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)();
|
||||
}
|
||||
|
||||
template<class U> R call(U & u, void const *) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf0)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)();
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u);
|
||||
}
|
||||
|
||||
R operator()(T & t) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)();
|
||||
}
|
||||
};
|
||||
|
||||
// cmf0
|
||||
|
||||
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf0)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef T const * argument_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) () const)
|
||||
F f_;
|
||||
|
||||
template<class U> R call(U & u, T const *) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)();
|
||||
}
|
||||
|
||||
template<class U> R call(U & u, void const *) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf0)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u);
|
||||
}
|
||||
|
||||
R operator()(T const & t) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)();
|
||||
}
|
||||
};
|
||||
|
||||
// mf1
|
||||
|
||||
template<class R, class T, class A1 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf1)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef T * first_argument_type;
|
||||
typedef A1 second_argument_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1> R call(U & u, T const *, B1 & b1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1);
|
||||
}
|
||||
|
||||
template<class U, class B1> R call(U & u, void const *, B1 & b1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf1)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf1
|
||||
|
||||
template<class R, class T, class A1 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf1)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
typedef T const * first_argument_type;
|
||||
typedef A1 second_argument_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1> R call(U & u, T const *, B1 & b1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1);
|
||||
}
|
||||
|
||||
template<class U, class B1> R call(U & u, void const *, B1 & b1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf1)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1);
|
||||
}
|
||||
};
|
||||
|
||||
// mf2
|
||||
|
||||
template<class R, class T, class A1, class A2 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf2)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2> R call(U & u, T const *, B1 & b1, B2 & b2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2> R call(U & u, void const *, B1 & b1, B2 & b2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf2)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf2
|
||||
|
||||
template<class R, class T, class A1, class A2 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf2)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2> R call(U & u, T const *, B1 & b1, B2 & b2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2> R call(U & u, void const *, B1 & b1, B2 & b2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf2)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
|
||||
}
|
||||
};
|
||||
|
||||
// mf3
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf3)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf3)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf3
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf3)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf3)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
|
||||
}
|
||||
};
|
||||
|
||||
// mf4
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf4)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf4)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf4
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf4)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf4)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
|
||||
}
|
||||
};
|
||||
|
||||
// mf5
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf5)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf5)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf5
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf5)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf5)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
|
||||
}
|
||||
};
|
||||
|
||||
// mf6
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf6)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf6)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf6
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf6)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf6)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
};
|
||||
|
||||
// mf7
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf7)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf7)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf7
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf7)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf7)(F f): f_(f) {}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
};
|
||||
|
||||
// mf8
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf8)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8))
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(mf8)(F f): f_(f) {}
|
||||
|
||||
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
};
|
||||
|
||||
// cmf8
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf8)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private:
|
||||
|
||||
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8) const)
|
||||
F f_;
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
|
||||
}
|
||||
|
||||
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit BOOST_MEM_FN_NAME(cmf8)(F f): f_(f) {}
|
||||
|
||||
R operator()(T const * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
//
|
||||
// bind/mem_fn_vw.hpp - void return helper wrappers
|
||||
//
|
||||
// Do not include this header directly
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
template<class R, class T> struct BOOST_MEM_FN_NAME(mf0): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf0)<R, T, R (BOOST_MEM_FN_CC T::*) ()>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) ();
|
||||
explicit BOOST_MEM_FN_NAME(mf0)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf0)<R, T, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T> struct BOOST_MEM_FN_NAME(cmf0): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf0)<R, T, R (BOOST_MEM_FN_CC T::*) () const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) () const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf0)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf0)<R, T, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1> struct BOOST_MEM_FN_NAME(mf1): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf1)<R, T, A1, R (BOOST_MEM_FN_CC T::*) (A1)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1);
|
||||
explicit BOOST_MEM_FN_NAME(mf1)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf1)<R, T, A1, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1> struct BOOST_MEM_FN_NAME(cmf1): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf1)<R, T, A1, R (BOOST_MEM_FN_CC T::*) (A1) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf1)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf1)<R, T, A1, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2> struct BOOST_MEM_FN_NAME(mf2): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf2)<R, T, A1, A2, R (BOOST_MEM_FN_CC T::*) (A1, A2)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2);
|
||||
explicit BOOST_MEM_FN_NAME(mf2)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf2)<R, T, A1, A2, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2> struct BOOST_MEM_FN_NAME(cmf2): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf2)<R, T, A1, A2, R (BOOST_MEM_FN_CC T::*) (A1, A2) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf2)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf2)<R, T, A1, A2, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> struct BOOST_MEM_FN_NAME(mf3): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf3)<R, T, A1, A2, A3, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3);
|
||||
explicit BOOST_MEM_FN_NAME(mf3)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf3)<R, T, A1, A2, A3, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3> struct BOOST_MEM_FN_NAME(cmf3): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf3)<R, T, A1, A2, A3, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf3)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf3)<R, T, A1, A2, A3, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> struct BOOST_MEM_FN_NAME(mf4): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf4)<R, T, A1, A2, A3, A4, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4);
|
||||
explicit BOOST_MEM_FN_NAME(mf4)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf4)<R, T, A1, A2, A3, A4, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4> struct BOOST_MEM_FN_NAME(cmf4): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf4)<R, T, A1, A2, A3, A4, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf4)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf4)<R, T, A1, A2, A3, A4, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> struct BOOST_MEM_FN_NAME(mf5): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf5)<R, T, A1, A2, A3, A4, A5, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5);
|
||||
explicit BOOST_MEM_FN_NAME(mf5)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf5)<R, T, A1, A2, A3, A4, A5, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5> struct BOOST_MEM_FN_NAME(cmf5): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf5)<R, T, A1, A2, A3, A4, A5, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf5)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf5)<R, T, A1, A2, A3, A4, A5, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> struct BOOST_MEM_FN_NAME(mf6): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf6)<R, T, A1, A2, A3, A4, A5, A6, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6);
|
||||
explicit BOOST_MEM_FN_NAME(mf6)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf6)<R, T, A1, A2, A3, A4, A5, A6, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> struct BOOST_MEM_FN_NAME(cmf6): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf6)<R, T, A1, A2, A3, A4, A5, A6, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf6)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf6)<R, T, A1, A2, A3, A4, A5, A6, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct BOOST_MEM_FN_NAME(mf7): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7);
|
||||
explicit BOOST_MEM_FN_NAME(mf7)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct BOOST_MEM_FN_NAME(cmf7): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf7)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7, F>(f) {}
|
||||
};
|
||||
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct BOOST_MEM_FN_NAME(mf8): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7, A8)>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8);
|
||||
explicit BOOST_MEM_FN_NAME(mf8)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, F>(f) {}
|
||||
};
|
||||
|
||||
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct BOOST_MEM_FN_NAME(cmf8): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7, A8) const>
|
||||
{
|
||||
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8) const;
|
||||
explicit BOOST_MEM_FN_NAME(cmf8)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, F>(f) {}
|
||||
};
|
||||
|
||||
@@ -1,67 +1,61 @@
|
||||
#ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
|
||||
#define BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
|
||||
|
||||
#if _MSC_VER >= 1020
|
||||
#pragma once
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind/placeholders.hpp - _N definitions
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright 2002, 2015, 2024 Peter Dimov
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
// See http://www.boost.org/libs/bind for documentation.
|
||||
//
|
||||
|
||||
#include <boost/bind/arg.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
namespace placeholders
|
||||
{
|
||||
|
||||
static inline boost::arg<1> _1() { return boost::arg<1>(); }
|
||||
static inline boost::arg<2> _2() { return boost::arg<2>(); }
|
||||
static inline boost::arg<3> _3() { return boost::arg<3>(); }
|
||||
static inline boost::arg<4> _4() { return boost::arg<4>(); }
|
||||
static inline boost::arg<5> _5() { return boost::arg<5>(); }
|
||||
static inline boost::arg<6> _6() { return boost::arg<6>(); }
|
||||
static inline boost::arg<7> _7() { return boost::arg<7>(); }
|
||||
static inline boost::arg<8> _8() { return boost::arg<8>(); }
|
||||
static inline boost::arg<9> _9() { return boost::arg<9>(); }
|
||||
#if !defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
|
||||
#elif (defined(BOOST_MSVC) && BOOST_MSVC <= 1300) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__)
|
||||
|
||||
static boost::arg<1> _1;
|
||||
static boost::arg<2> _2;
|
||||
static boost::arg<3> _3;
|
||||
static boost::arg<4> _4;
|
||||
static boost::arg<5> _5;
|
||||
static boost::arg<6> _6;
|
||||
static boost::arg<7> _7;
|
||||
static boost::arg<8> _8;
|
||||
static boost::arg<9> _9;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<1> _1;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<2> _2;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<3> _3;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<4> _4;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<5> _5;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<6> _6;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<7> _7;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<8> _8;
|
||||
BOOST_INLINE_CONSTEXPR boost::arg<9> _9;
|
||||
|
||||
#else
|
||||
|
||||
boost::arg<1> _1;
|
||||
boost::arg<2> _2;
|
||||
boost::arg<3> _3;
|
||||
boost::arg<4> _4;
|
||||
boost::arg<5> _5;
|
||||
boost::arg<6> _6;
|
||||
boost::arg<7> _7;
|
||||
boost::arg<8> _8;
|
||||
boost::arg<9> _9;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<1> _1;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<2> _2;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<3> _3;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<4> _4;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<5> _5;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<6> _6;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<7> _7;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<8> _8;
|
||||
BOOST_STATIC_CONSTEXPR boost::arg<9> _9;
|
||||
|
||||
#endif
|
||||
|
||||
} // unnamed namespace
|
||||
} // namespace placeholders
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
|
||||
|
||||
@@ -2,135 +2,59 @@
|
||||
#define BOOST_BIND_PROTECT_HPP_INCLUDED
|
||||
|
||||
//
|
||||
// protect.hpp
|
||||
// protect.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright 2002, 2020 Peter Dimov
|
||||
// Copyright 2009 Steven Watanabe
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace _bi
|
||||
{
|
||||
|
||||
template<class F> class protected_bind_t
|
||||
template<class T> struct protect_make_void
|
||||
{
|
||||
public:
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class F, class E = void> struct protect_result_type
|
||||
{
|
||||
};
|
||||
|
||||
template<class F> struct protect_result_type< F, typename protect_make_void<typename F::result_type>::type >
|
||||
{
|
||||
typedef typename F::result_type result_type;
|
||||
};
|
||||
|
||||
explicit protected_bind_t(F f): f_(f)
|
||||
{
|
||||
}
|
||||
|
||||
result_type operator()()
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
result_type operator()() const
|
||||
{
|
||||
return f_();
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1)
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(A1 & a1) const
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3) const
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
template<class F> class protected_bind_t: public protect_result_type<F>
|
||||
{
|
||||
private:
|
||||
|
||||
F f_;
|
||||
|
||||
public:
|
||||
|
||||
explicit protected_bind_t( F f ): f_( f )
|
||||
{
|
||||
}
|
||||
|
||||
template<class... A> auto operator()( A&&... a ) -> decltype( f_( std::forward<A>(a)... ) )
|
||||
{
|
||||
return f_( std::forward<A>(a)... );
|
||||
}
|
||||
|
||||
template<class... A> auto operator()( A&&... a ) const -> decltype( f_( std::forward<A>(a)... ) )
|
||||
{
|
||||
return f_( std::forward<A>(a)... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace _bi
|
||||
|
||||
33
include/boost/bind/std_placeholders.hpp
Normal file
33
include/boost/bind/std_placeholders.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef BOOST_BIND_STD_PLACEHOLDERS_HPP_INCLUDED
|
||||
#define BOOST_BIND_STD_PLACEHOLDERS_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/is_placeholder.hpp>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_1)>::type > { enum _vt { value = 1 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_2)>::type > { enum _vt { value = 2 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_3)>::type > { enum _vt { value = 3 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_4)>::type > { enum _vt { value = 4 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_5)>::type > { enum _vt { value = 5 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_6)>::type > { enum _vt { value = 6 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_7)>::type > { enum _vt { value = 7 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_8)>::type > { enum _vt { value = 8 }; };
|
||||
template<> struct is_placeholder< typename std::decay<decltype(std::placeholders::_9)>::type > { enum _vt { value = 9 }; };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_STD_PLACEHOLDERS_HPP_INCLUDED
|
||||
31
include/boost/is_placeholder.hpp
Normal file
31
include/boost/is_placeholder.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
||||
#define BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined( _MSC_VER ) && ( _MSC_VER >= 1020 )
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// is_placeholder.hpp - TR1 is_placeholder metafunction
|
||||
//
|
||||
// Copyright (c) 2006 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class T > struct is_placeholder
|
||||
{
|
||||
enum _vt { value = 0 };
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
||||
@@ -1,319 +1,24 @@
|
||||
#ifndef BOOST_MEM_FN_HPP_INCLUDED
|
||||
#define BOOST_MEM_FN_HPP_INCLUDED
|
||||
|
||||
#if _MSC_VER+0 >= 1020
|
||||
#pragma once
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// mem_fn.hpp - a generalization of std::mem_fun[_ref]
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2001 David Abrahams
|
||||
// Copyright (c) 2009 Peter Dimov
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
#define BOOST_MEM_FN_CLASS_F , class F
|
||||
#define BOOST_MEM_FN_TYPEDEF(X)
|
||||
|
||||
namespace _mfi // mem_fun_impl
|
||||
{
|
||||
|
||||
template<class V> struct mf
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN return
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
}; // struct mf<V>
|
||||
|
||||
template<> struct mf<void>
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
}; // struct mf<void>
|
||||
|
||||
#undef BOOST_MEM_FN_CLASS_F
|
||||
#undef BOOST_MEM_FN_TYPEDEF_F
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
#else // #ifdef BOOST_NO_VOID_RETURNS
|
||||
|
||||
#define BOOST_MEM_FN_CLASS_F
|
||||
#define BOOST_MEM_FN_TYPEDEF(X) typedef X;
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN return
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
#undef BOOST_MEM_FN_CLASS_F
|
||||
#undef BOOST_MEM_FN_TYPEDEF
|
||||
|
||||
#endif // #ifdef BOOST_NO_VOID_RETURNS
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
// data member support
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
template<class R, class T> class dm
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R const & result_type;
|
||||
typedef T const * argument_type;
|
||||
|
||||
private:
|
||||
|
||||
typedef R (T::*F);
|
||||
F f_;
|
||||
|
||||
template<class U> R const & call(U & u, T const *) const
|
||||
{
|
||||
return (u.*f_);
|
||||
}
|
||||
|
||||
template<class U> R & call(U & u, T *) const
|
||||
{
|
||||
return (u.*f_);
|
||||
}
|
||||
|
||||
template<class U> R const & call(U & u, void const *) const
|
||||
{
|
||||
return (get_pointer(u)->*f_);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit dm(F f): f_(f) {}
|
||||
|
||||
R & operator()(T * p) const
|
||||
{
|
||||
return (p->*f_);
|
||||
}
|
||||
|
||||
R const & operator()(T const * p) const
|
||||
{
|
||||
return (p->*f_);
|
||||
}
|
||||
|
||||
template<class U> R const & operator()(U & u) const
|
||||
{
|
||||
return call(u, &u);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1300)
|
||||
|
||||
R & operator()(T & t) const
|
||||
{
|
||||
return (t.*f_);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R const & operator()(T const & t) const
|
||||
{
|
||||
return (t.*f_);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
|
||||
{
|
||||
return _mfi::dm<R, T>(f);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
#include <boost/bind/mem_fn.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED
|
||||
|
||||
12
index.html
12
index.html
@@ -1,10 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=bind.html">
|
||||
<meta http-equiv="refresh" content="0; URL=doc/html/bind.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="bind.html">bind.html</a> or
|
||||
<a href="mem_fn.html">mem_fn.html</a>.
|
||||
<a href="doc/html/bind.html">doc/html/bind.html</a> or
|
||||
<a href="doc/html/mem_fn.html">doc/html/mem_fn.html</a>.
|
||||
</body>
|
||||
</html>
|
||||
<!--
|
||||
© Copyright Beman Dawes, 2001
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
-->
|
||||
|
||||
423
mem_fn.html
423
mem_fn.html
@@ -1,399 +1,28 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: mem_fn.hpp documentation</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%">
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277">
|
||||
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86">
|
||||
</td>
|
||||
<td align="middle">
|
||||
<h1>mem_fn.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Contents</h2>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><a href="#Purpose">Purpose</a></h3>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><a href="#FAQ">Frequently Asked Questions</a></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q1">Can <b>mem_fn</b> be used instead of the
|
||||
standard <b>std::mem_fun[_ref]</b> adaptors?</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q2">Should I replace every occurence of <b>std::mem_fun[_ref]</b>
|
||||
with <b>mem_fn</b> in my existing code?</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q3">Does <b>mem_fn</b> work with COM methods?</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q4">Why isn't BOOST_MEM_FN_ENABLE_STDCALL
|
||||
defined automatically?</a></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><a href="#Interface">Interface</a></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Synopsis">Synopsis</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#CommonRequirements">Common requirements</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#get_pointer">get_pointer</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#mem_fn">mem_fn</a></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><a href="#Implementation">Implementation</a></h3>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Files">Files</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#Dependencies">Dependencies</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#NumberOfArguments">Number of Arguments</a></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><a href="#stdcall">"__stdcall" and
|
||||
"__fastcall" Support</a></h4>
|
||||
<h3 style="MARGIN-LEFT: 20pt"><a href="#Acknowledgements">Acknowledgements</a></h3>
|
||||
<h2><a name="Purpose">Purpose</a></h2>
|
||||
<p>
|
||||
<b>boost::mem_fn</b> is a generalization of the standard functions <b>std::mem_fun</b>
|
||||
and <b>std::mem_fun_ref</b>. It supports member function pointers with more
|
||||
than one argument, and the returned function object can take a pointer, a
|
||||
reference, or a smart pointer to an object instance as its first argument. <STRONG>mem_fn</STRONG>
|
||||
also supports pointers to data members by treating them as functions taking no
|
||||
arguments and returning a (const) reference to the member.
|
||||
</p>
|
||||
<p>
|
||||
The purpose of <b>mem_fn</b> is twofold. First, it allows users to invoke a
|
||||
member function on a container with the familiar
|
||||
</p>
|
||||
<pre>
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&Shape::draw));
|
||||
</pre>
|
||||
<p>
|
||||
syntax, even when the container stores smart pointers.
|
||||
</p>
|
||||
<p>
|
||||
Second, it can be used as a building block by library developers that want to
|
||||
treat a pointer to member function as a function object. A library might define
|
||||
an enhanced <b>for_each</b> algorithm with an overload of the form:
|
||||
</p>
|
||||
<pre>
|
||||
template<class It, class R, class T> void for_each(It first, It last, R (T::*pmf) ())
|
||||
{
|
||||
std::for_each(first, last, boost::mem_fn(pmf));
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
that will allow the convenient syntax:
|
||||
</p>
|
||||
<pre>
|
||||
for_each(v.begin(), v.end(), &Shape::draw);
|
||||
</pre>
|
||||
<p>
|
||||
When documenting the feature, the library author will simply state:
|
||||
</p>
|
||||
<h4 style="MARGIN-LEFT: 20pt">template<class It, class R, class T> void
|
||||
for_each(It first, It last, R (T::*pmf) ());</h4>
|
||||
<p style="MARGIN-LEFT: 20pt">
|
||||
<b>Effects:</b> equivalent to std::for_each(first, last, boost::mem_fn(pmf));
|
||||
</p>
|
||||
<p>
|
||||
where <b>boost::mem_fn</b> can be a link to this page. See <a href="bind.html">the
|
||||
documentation of <b>bind</b></a> for an example.
|
||||
</p>
|
||||
<p>
|
||||
<b>mem_fn</b> takes one argument, a pointer to a member, and returns a function
|
||||
object suitable for use with standard or user-defined algorithms:
|
||||
</p>
|
||||
<pre>
|
||||
struct X
|
||||
{
|
||||
void f();
|
||||
};
|
||||
|
||||
void g(std::vector<X> & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
void h(std::vector<X *> const & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
|
||||
void k(std::vector<boost::shared_ptr<X> > const & v)
|
||||
{
|
||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
||||
};
|
||||
</pre>
|
||||
<p>
|
||||
The returned function object takes the same arguments as the input member
|
||||
function plus a "flexible" first argument that represents the object instance.
|
||||
</p>
|
||||
<p>
|
||||
When the function object is invoked with a first argument <b>x</b> that is
|
||||
neither a pointer nor a reference to the appropriate class (<b>X</b> in the
|
||||
example above), it uses <tt>get_pointer(x)</tt> to obtain a pointer from <b>x</b>.
|
||||
Library authors can "register" their smart pointer classes by supplying an
|
||||
appropriate <b>get_pointer</b> overload, allowing <b>mem_fn</b> to recognize
|
||||
and support them.
|
||||
</p>
|
||||
<p>
|
||||
[Note: <b>get_pointer</b> is not restricted to return a pointer. Any object
|
||||
that can be used in a member function call expression <tt>(x->*pmf)(...)</tt>
|
||||
will work.]
|
||||
</p>
|
||||
<p>
|
||||
[Note: the library uses an unqualified call to <b>get_pointer</b>. Therefore,
|
||||
it will find, through argument-dependent lookup, <b>get_pointer</b> overloads
|
||||
that are defined in the same namespace as the corresponding smart pointer
|
||||
class, in addition to any <b>boost::get_pointer</b> overloads.]
|
||||
</p>
|
||||
<p>
|
||||
All function objects returned by <b>mem_fn</b> expose a <b>result_type</b> typedef
|
||||
that represents the return type of the member function. For data members, <STRONG>result_type</STRONG>
|
||||
is defined as a const reference to the type of the member.
|
||||
</p>
|
||||
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
|
||||
<h3><a name="Q1">Can <b>mem_fn</b> be used instead of the standard <b>std::mem_fun[_ref]</b>
|
||||
adaptors?</a></h3>
|
||||
<p>
|
||||
Yes. For simple uses, <b>mem_fn</b> provides additional functionality that the
|
||||
standard adaptors do not. Complicated expressions that use <b>std::bind1st</b>, <b>std::bind2nd</b>
|
||||
or <a href="../compose/index.htm"><b>Boost.Compose</b></a> along with the
|
||||
standard adaptors can be rewritten using <a href="bind.html"><b>boost::bind</b></a>
|
||||
that automatically takes advantage of <b>mem_fn</b>.
|
||||
</p>
|
||||
<h3><a name="Q2">Should I replace every occurence of <b>std::mem_fun[_ref]</b> with <b>mem_fn</b>
|
||||
in my existing code?</a></h3>
|
||||
<p>
|
||||
No, unless you have good reasons to do so. <b>mem_fn</b> is not 100% compatible
|
||||
with the standard adaptors, although it comes pretty close. In particular, <b>mem_fn</b>
|
||||
does not return objects of type <b>std::[const_]mem_fun[1][_ref]_t</b>, as the
|
||||
standard adaptors do, and it is not possible to fully describe the type of the
|
||||
first argument using the standard <b>argument_type</b> and <b>first_argument_type</b>
|
||||
nested typedefs. Libraries that need adaptable function objects in order to
|
||||
function might not like <b>mem_fn</b>.
|
||||
</p>
|
||||
<h3><a name="Q3">Does <b>mem_fn</b> work with COM methods?</a></h3>
|
||||
<p>
|
||||
Yes, if you <a href="#stdcall">#define BOOST_MEM_FN_ENABLE_STDCALL</a>.
|
||||
</p>
|
||||
<h3><a name="Q4">Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?</a></h3>
|
||||
<p>
|
||||
Non-portable extensions, in general, should default to off to prevent vendor
|
||||
lock-in. Had BOOST_MEM_FN_ENABLE_STDCALL been defined automatically, you could
|
||||
have accidentally taken advantage of it without realizing that your code is,
|
||||
perhaps, no longer portable.
|
||||
</p>
|
||||
<h2><a name="Interface">Interface</a></h2>
|
||||
<h3><a name="Synopsis">Synopsis</a></h3>
|
||||
<pre>
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> T * <a href="#get_pointer_1">get_pointer</a>(T * p);
|
||||
|
||||
template<class R, class T> <i>unspecified-1</i> <a href="#mem_fn_1">mem_fn</a>(R (T::*pmf) ());
|
||||
|
||||
template<class R, class T> <i>unspecified-2</i> <a href="#mem_fn_2">mem_fn</a>(R (T::*pmf) () const);
|
||||
|
||||
template<class R, class T> <i>unspecified-2-1</i> <a href="#mem_fn_2_1">mem_fn</a>(R T::*pm);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-3</i> <a href="#mem_fn_3">mem_fn</a>(R (T::*pmf) (A1));
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-4</i> <a href="#mem_fn_4">mem_fn</a>(R (T::*pmf) (A1) const);
|
||||
|
||||
template<class R, class T, class A1, class A2> <i>unspecified-5</i> <a href="#mem_fn_5">mem_fn</a>(R (T::*pmf) (A1, A2));
|
||||
|
||||
template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a href="#mem_fn_6">mem_fn</a>(R (T::*pmf) (A1, A2) const);
|
||||
|
||||
// implementation defined number of additional overloads for more arguments
|
||||
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="CommonRequirements">Common requirements</a></h3>
|
||||
<p>
|
||||
All <tt><i>unspecified-N</i></tt> types mentioned in the Synopsis are <b>CopyConstructible</b>
|
||||
and <b>Assignable</b>. Their copy constructors and assignment operators do not
|
||||
throw exceptions. <tt><i>unspecified-N</i>::result_type</tt> is defined as the
|
||||
return type of the member function pointer passed as an argument to <b>mem_fn</b>
|
||||
(<b>R</b> in the Synopsis.) <tt><i>unspecified-2-1</i>::result_type</tt> is
|
||||
defined as <tt>R const &</tt>.
|
||||
</p>
|
||||
<h3><a name="get_pointer">get_pointer</a></h3>
|
||||
<h4><a name="get_pointer_1">template<class T> T * get_pointer(T * p)</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> <tt>p</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3><a name="mem_fn">mem_fn</a></h3>
|
||||
<h4><a name="mem_fn_1">template<class R, class T> <i>unspecified-1</i> mem_fn(R
|
||||
(T::*pmf) ())</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
|
||||
is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i> is an l-value of type <STRONG>T </STRONG>
|
||||
or derived, <tt>(get_pointer(t)->*pmf)()</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="mem_fn_2">template<class R, class T> <i>unspecified-2</i> mem_fn(R
|
||||
(T::*pmf) () const)</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
|
||||
is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i> is of type <STRONG>T</STRONG>
|
||||
<EM>[const]<STRONG> </STRONG></EM>or derived, <tt>(get_pointer(t)->*pmf)()</tt>
|
||||
otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="mem_fn_2_1">template<class R, class T> <i>unspecified-2-1</i> mem_fn(R
|
||||
T::*pm)</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
|
||||
is equivalent to <tt>t.*pm</tt> when <i>t</i> is of type <STRONG>T</STRONG> <EM>[const]<STRONG>
|
||||
</STRONG></EM>or derived, <tt>get_pointer(t)->*pm</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="mem_fn_3">template<class R, class T, class A1> <i>unspecified-3</i> mem_fn(R
|
||||
(T::*pmf) (A1))</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1)</i></tt>
|
||||
is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i> is an l-value of type <STRONG>T
|
||||
</STRONG>or derived, <tt>(get_pointer(t)->*pmf)(a1)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="mem_fn_4">template<class R, class T, class A1> <i>unspecified-4</i> mem_fn(R
|
||||
(T::*pmf) (A1) const)</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1)</i></tt>
|
||||
is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i> is of type <STRONG>T</STRONG>
|
||||
<EM>[const]<STRONG> </STRONG></EM>or derived, <tt>(get_pointer(t)->*pmf)(a1)</tt>
|
||||
otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="mem_fn_5">template<class R, class T, class A1, class A2> <i>unspecified-5</i>
|
||||
mem_fn(R (T::*pmf) (A1, A2))</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1, a2)</i></tt>
|
||||
is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i> is an l-value of type <STRONG>
|
||||
T</STRONG> or derived, <tt>(get_pointer(t)->*pmf)(a1, a2)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="mem_fn_6">template<class R, class T, class A1, class A2> <i>unspecified-6</i>
|
||||
mem_fn(R (T::*pmf) (A1, A2) const)</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1, a2)</i></tt>
|
||||
is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i> is of type <STRONG>T</STRONG>
|
||||
<EM>[const]</EM> or derived, <tt>(get_pointer(t)->*pmf)(a1, a2)</tt> otherwise.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h2><a name="Implementation">Implementation</a></h2>
|
||||
<h3><a name="Files">Files</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="../../boost/mem_fn.hpp">boost/mem_fn.hpp</a>
|
||||
(main header)
|
||||
<li>
|
||||
<a href="../../boost/bind/mem_fn_cc.hpp">boost/bind/mem_fn_cc.hpp</a>
|
||||
(used by mem_fn.hpp, do not include directly)
|
||||
<li>
|
||||
<a href="../../boost/bind/mem_fn_vw.hpp">boost/bind/mem_fn_vw.hpp</a>
|
||||
(used by mem_fn.hpp, do not include directly)
|
||||
<li>
|
||||
<a href="../../boost/bind/mem_fn_template.hpp">boost/bind/mem_fn_template.hpp</a>
|
||||
(used by mem_fn.hpp, do not include directly)
|
||||
<li>
|
||||
<a href="test/mem_fn_test.cpp">libs/bind/test/mem_fn_test.cpp</a>
|
||||
(test)
|
||||
<li>
|
||||
<a href="test/mem_fn_derived_test.cpp">libs/bind/test/mem_fn_derived_test.cpp</a>
|
||||
(test with derived objects)
|
||||
<li>
|
||||
<a href="test/mem_fn_fastcall_test.cpp">libs/bind/test/mem_fn_fastcall_test.cpp</a>
|
||||
(test for __fastcall)
|
||||
<li>
|
||||
<a href="test/mem_fn_stdcall_test.cpp">libs/bind/test/mem_fn_stdcall_test.cpp</a>
|
||||
(test for __stdcall)
|
||||
<li>
|
||||
<a href="test/mem_fn_void_test.cpp">libs/bind/test/mem_fn_void_test.cpp</a> (test for
|
||||
void returns)</li>
|
||||
</ul>
|
||||
<h3><a name="Dependencies">Dependencies</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="../config/config.htm">Boost.Config</a></li>
|
||||
</ul>
|
||||
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
|
||||
<p>
|
||||
This implementation supports member functions with up to eight arguments. This
|
||||
is not an inherent limitation of the design, but an implementation detail.
|
||||
</p>
|
||||
<h3><a name="stdcall">"__stdcall" and "__fastcall" Support</a></h3>
|
||||
<p>
|
||||
Some platforms allow several types of member functions that differ by their <b>calling
|
||||
convention</b> (the rules by which the function is invoked: how are
|
||||
arguments passed, how is the return value handled, and who cleans up the stack
|
||||
- if any.)
|
||||
</p>
|
||||
<p>
|
||||
For example, Windows API functions and COM interface member functions use a
|
||||
calling convention known as <b>__stdcall</b>. Borland VCL components use <STRONG>__fastcall</STRONG>.
|
||||
</p>
|
||||
<p>
|
||||
To use <b>mem_fn</b> with <b>__stdcall</b> member functions, <b>#define</b> the
|
||||
macro <b>BOOST_MEM_FN_ENABLE_STDCALL</b> before including, directly or
|
||||
indirectly, <b><boost/mem_fn.hpp></b>.
|
||||
</p>
|
||||
<P>To use <B>mem_fn</B> with <B>__fastcall</B> member functions, <B>#define</B> the
|
||||
macro <B>BOOST_MEM_FN_ENABLE_FASTCALL</B> before including, directly or
|
||||
indirectly, <B><boost/mem_fn.hpp></B>.
|
||||
</P>
|
||||
<P>[Note: this is a non-portable extension. It is not part of the interface.]
|
||||
</P>
|
||||
<p>
|
||||
[Note: Some compilers provide only minimal support for the <b>__stdcall</b> keyword.]
|
||||
</p>
|
||||
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
|
||||
<p>
|
||||
Rene Jager's initial suggestion of using traits classes to make <b>mem_fn</b> adapt
|
||||
to user-defined smart pointers inspired the <b>get_pointer</b>-based design.
|
||||
</p>
|
||||
<p>
|
||||
Numerous improvements were suggested during the formal review period by Richard
|
||||
Crossley, Jens Maurer, Ed Brey, and others. Review manager was Darin Adler.
|
||||
</p>
|
||||
<p>
|
||||
Steve Anichini pointed out that COM interfaces use <b>__stdcall</b>.
|
||||
</p>
|
||||
<p>
|
||||
Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns on
|
||||
deficient compilers.
|
||||
</p>
|
||||
<p><br>
|
||||
<br>
|
||||
<br>
|
||||
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Permission
|
||||
to copy, use, modify, sell and distribute this document is granted provided
|
||||
this copyright notice appears in all copies. This document is provided "as is"
|
||||
without express or implied warranty, and with no claim as to its suitability
|
||||
for any purpose.</small></p>
|
||||
</body>
|
||||
<head>
|
||||
<title>Boost.MemberFunction</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="refresh" content="0; url=doc/html/mem_fn.html">
|
||||
<style>
|
||||
body {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
a {
|
||||
color: #00f;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="doc/html/mem_fn.html">doc/html/mem_fn.html</a>
|
||||
</p>
|
||||
<p>
|
||||
© 2001, 2002 Peter Dimov and Multi Media Ltd.<br>
|
||||
© 2003-2005 Peter Dimov
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
36
meta/libraries.json
Normal file
36
meta/libraries.json
Normal file
@@ -0,0 +1,36 @@
|
||||
[
|
||||
{
|
||||
"key": "bind",
|
||||
"name": "Bind",
|
||||
"authors": [
|
||||
"Peter Dimov"
|
||||
],
|
||||
"description": "boost::bind is a generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions.",
|
||||
"std": [
|
||||
"tr1"
|
||||
],
|
||||
"category": [
|
||||
"Function-objects"
|
||||
],
|
||||
"maintainers": [
|
||||
"Peter Dimov <pdimov -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "11"
|
||||
},
|
||||
{
|
||||
"key": "bind/mem_fn",
|
||||
"name": "Member Function",
|
||||
"authors": [
|
||||
"Peter Dimov"
|
||||
],
|
||||
"description": "Generalized binders for function/object/pointers and member functions.",
|
||||
"documentation": "mem_fn.html",
|
||||
"std": [
|
||||
"tr1"
|
||||
],
|
||||
"category": [
|
||||
"Function-objects"
|
||||
],
|
||||
"cxxstd": "11"
|
||||
}
|
||||
]
|
||||
195
ref.html
195
ref.html
@@ -1,195 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Boost: ref.hpp documentation</title>
|
||||
</head>
|
||||
<body bgcolor="White">
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277">
|
||||
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86">
|
||||
</td>
|
||||
<td align="center">
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td nowrap><h1>ref.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" nowrap><small> 1.00.0004 (2002-01-27)</small></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Files</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="../../boost/ref.hpp">ref.hpp</a>
|
||||
</ul>
|
||||
<h2>Purpose</h2>
|
||||
<p>
|
||||
The header <a href="../../boost/ref.hpp">boost/ref.hpp</a> defines the class
|
||||
template <b>boost::reference_wrapper<T></b>, the two functions <b>boost::ref</b>
|
||||
and <b>boost::cref</b> that return instances of <b>boost::reference_wrapper<T></b>,
|
||||
and the two traits classes <b>boost::is_reference_wrapper<T></b> and <b>boost::unwrap_reference<T></b>.
|
||||
</p>
|
||||
<p>
|
||||
The purpose of <b>boost::reference_wrapper<T></b> is to contain a
|
||||
reference to an object of type <b>T</b>. It is primarily used to "feed"
|
||||
references to function templates (algorithms) that take their parameter by
|
||||
value.
|
||||
</p>
|
||||
<p>
|
||||
To support this usage, <b>boost::reference_wrapper<T></b> provides an
|
||||
implicit conversion to <b>T &</b>. This usually allows the function
|
||||
templates to work on references unmodified.
|
||||
</p>
|
||||
<p>
|
||||
<b>boost::reference_wrapper<T></b> is both <b>CopyConstructible</b> and <b>Assignable</b>
|
||||
(ordinary references are not <b>Assignable</b>).
|
||||
</p>
|
||||
<p>
|
||||
The expression <b>boost::ref(x)</b> returns a <b>boost::reference_wrapper<X>(x)</b>
|
||||
where <b>X</b> is the type of <b>x</b>. Similarly, <b>boost::cref(x)</b> returns
|
||||
a <b>boost::reference_wrapper<X const>(x)</b>.
|
||||
</p>
|
||||
<p>
|
||||
The expression <b>boost::is_reference_wrapper<T>::value</b> is <b>true</b>
|
||||
if <b>T</b> is a <b>reference_wrapper</b>, and <b>false</b>
|
||||
otherwise.
|
||||
</p>
|
||||
<p>
|
||||
The type-expression <b>boost::unwrap_reference<T>::type</b> is <b>T::type</b>
|
||||
if <b>T</b> is a <b>reference_wrapper</b>, <b>T</b> otherwise.
|
||||
</p>
|
||||
<h2>Interface</h2>
|
||||
<h3>Synopsis</h3>
|
||||
<pre>
|
||||
namespace boost
|
||||
{
|
||||
template<class T> class <a href="#reference_wrapper">reference_wrapper</a>;
|
||||
template<class T> reference_wrapper<T> <a href="#ref">ref</a>(T & t);
|
||||
template<class T> reference_wrapper<T const> <a href="#cref">cref</a>(T const & t);
|
||||
template<class T> class is_reference_wrapper<T const>;
|
||||
template<class T> class unwrap_reference<T const>;
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="reference_wrapper">reference_wrapper</a></h3>
|
||||
<pre>
|
||||
template<class T> class reference_wrapper
|
||||
{
|
||||
public:
|
||||
typedef T type;
|
||||
|
||||
explicit <a href="#rt_construct">reference_wrapper</a>(T & t);
|
||||
|
||||
<a href="#rt_operator">operator T &</a> () const;
|
||||
|
||||
T & <a href="#rt_get">get</a>() const;
|
||||
T* <a href="#rt_get_pointer">get_pointer</a>() const;
|
||||
};
|
||||
</pre>
|
||||
<h4><a name="rt_construct">explicit reference_wrapper(T & t)</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Effects:</b> Constructs a <b>reference_wrapper</b> object that stores a
|
||||
reference to <b>t</b>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="rt_operator">operator T & () const</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> the stored reference.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="rt_get">T & get() const</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> the stored reference.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h4><a name="rt_get_pointer">T* get_pointer() const</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> a pointer to the stored object.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3><a name="ref">ref</a></h3>
|
||||
<pre>
|
||||
template<class T> reference_wrapper<T> ref(T & t);
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> <tt>reference_wrapper<T>(t)</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3><a name="cref">cref</a></h3>
|
||||
<pre>
|
||||
template<class T> reference_wrapper<T const> cref(T const & t);
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Returns:</b> <tt>reference_wrapper<T const>(t)</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Throws:</b> Nothing.
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3><a name="is_reference_wrapper">is_reference_wrapper</a></h3>
|
||||
<pre>
|
||||
template<class T> class is_reference_wrapper<T const>
|
||||
{
|
||||
public:
|
||||
static bool value = <i>unspecified</i>;
|
||||
};
|
||||
</pre>
|
||||
Value is <b>true</b> iff <tt>T</tt> is a specialization of <tt>reference_wrapper</tt>.
|
||||
<h3><a name="unwrap_reference">unwrap_reference</a></h3>
|
||||
<pre>
|
||||
template<class T> class unwrap_reference<T const>
|
||||
{
|
||||
public:
|
||||
typedef <i>unspecified</i> type;
|
||||
};
|
||||
</pre>
|
||||
<tt>type</tt> is equivalent to <tt>T::type</tt> if <tt>T</tt> is a
|
||||
specialization of <tt>reference_wrapper</tt>. Otherwise <tt>type</tt> is
|
||||
equivalent to <tt>T</tt>.
|
||||
<h2>Acknowledgements</h2>
|
||||
<p>
|
||||
<b>ref</b> and <b>cref</b> were originally part of the Boost.Tuple library by <a href="../../people/jaakko_jarvi.htm">
|
||||
Jaakko Järvi</a>. They were "promoted to <b>boost::</b> status" by <a href="../../people/peter_dimov.htm">
|
||||
Peter Dimov</a> because they are generally useful. <a href="../../people/doug_gregor.html">
|
||||
Douglas Gregor</a> and <a href="../../people/dave_abrahams.htm">Dave Abrahams</a>
|
||||
contributed <tt>is_reference_wrapper</tt> and <tt>unwrap_reference</tt>.
|
||||
</p>
|
||||
<p><br>
|
||||
<br>
|
||||
<br>
|
||||
<small>Copyright © 2001 by Peter Dimov and Multi Media Ltd. Permission to
|
||||
copy, use, modify, sell and distribute this document is granted provided this
|
||||
copyright notice appears in all copies. This document is provided "as
|
||||
is" without express or implied warranty, and with no claim as to its
|
||||
suitability for any purpose.</small></p>
|
||||
</body>
|
||||
</html>
|
||||
11
test/CMakeLists.txt
Normal file
11
test/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::bind Boost::core Boost::function Boost::smart_ptr)
|
||||
|
||||
endif()
|
||||
26
test/Jamfile
26
test/Jamfile
@@ -1,26 +0,0 @@
|
||||
# Boost.Bind Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003 Peter Dimov
|
||||
#
|
||||
# Permission to copy, use, modify, sell and distribute this software
|
||||
# is granted provided this copyright notice appears in all copies.
|
||||
# This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
subproject libs/bind/test ;
|
||||
|
||||
# bring in rules for testing
|
||||
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
|
||||
include testing.jam ;
|
||||
|
||||
# Make tests run by default.
|
||||
DEPENDS all : bind ;
|
||||
|
||||
{
|
||||
test-suite "bind"
|
||||
: [ run bind_test.cpp ]
|
||||
[ run mem_fn_test.cpp ]
|
||||
[ run mem_fn_void_test.cpp ]
|
||||
[ run mem_fn_derived_test.cpp ]
|
||||
;
|
||||
}
|
||||
126
test/Jamfile.v2
Normal file
126
test/Jamfile.v2
Normal file
@@ -0,0 +1,126 @@
|
||||
# Boost.Bind Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003-2006, 2017 Peter Dimov
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See
|
||||
# accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
local gcc-flags = -Wundef ;
|
||||
|
||||
project
|
||||
: default-build
|
||||
|
||||
<warnings>pedantic
|
||||
|
||||
: requirements
|
||||
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
|
||||
<toolset>gcc:<cxxflags>$(gcc-flags)
|
||||
<toolset>clang:<cxxflags>$(gcc-flags)
|
||||
|
||||
<library>/boost/bind//boost_bind
|
||||
<library>/boost/core//boost_core
|
||||
<library>/boost/function//boost_function
|
||||
<library>/boost/smart_ptr//boost_smart_ptr
|
||||
;
|
||||
|
||||
# quick test (for CI)
|
||||
run quick.cpp ;
|
||||
|
||||
# full test suite
|
||||
run bind_test.cpp ;
|
||||
run bind_dm_test.cpp ;
|
||||
run bind_eq_test.cpp ;
|
||||
run bind_const_test.cpp ;
|
||||
run bind_cv_test.cpp ;
|
||||
run bind_stateful_test.cpp ;
|
||||
run bind_dm2_test.cpp ;
|
||||
run bind_not_test.cpp ;
|
||||
run bind_rel_test.cpp ;
|
||||
run bind_function_test.cpp ;
|
||||
run bind_lookup_problem_test.cpp ;
|
||||
run bind_rv_sp_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
compile bind_unary_addr.cpp ;
|
||||
run bind_dm3_test.cpp ;
|
||||
run bind_visit_test.cpp ;
|
||||
run bind_placeholder_test.cpp ;
|
||||
run bind_rvalue_test.cpp ;
|
||||
run bind_and_or_test.cpp ;
|
||||
run bind_void_test.cpp ;
|
||||
run bind_void_dm_test.cpp ;
|
||||
run bind_void_mf_test.cpp ;
|
||||
run mem_fn_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run mem_fn_void_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run mem_fn_derived_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run mem_fn_eq_test.cpp ;
|
||||
run mem_fn_dm_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run mem_fn_rv_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run ref_fn_test.cpp ;
|
||||
run bind_fnobj2_test.cpp ;
|
||||
run bind_fn2_test.cpp ;
|
||||
run bind_mf2_test.cpp ;
|
||||
run bind_eq2_test.cpp ;
|
||||
run mem_fn_ref_test.cpp ;
|
||||
run bind_ref_test.cpp ;
|
||||
run bind_eq3_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run protect_test.cpp ;
|
||||
run mem_fn_unary_addr_test.cpp ;
|
||||
run bind_function2_test.cpp ;
|
||||
run bind_fwd_test.cpp ;
|
||||
run bind_fwd2_test.cpp ;
|
||||
run bind_no_placeholders_test.cpp ;
|
||||
run placeholder_const_ref_test.cpp ;
|
||||
run bind_function_ap_test.cpp ;
|
||||
run bind_type_test.cpp ;
|
||||
run bind_unique_ptr_test.cpp ;
|
||||
run bind_nested_rv_test.cpp
|
||||
: : : <toolset>gcc-4.7:<build>no <toolset>msvc-12.0:<build>no ;
|
||||
compile arg_copy_test.cpp ;
|
||||
compile-fail arg_copy_fail.cpp
|
||||
: <warnings>off ;
|
||||
run placeholder_std_bind_test.cpp ;
|
||||
run bind_fastcall_test.cpp ;
|
||||
run bind_stdcall_test.cpp ;
|
||||
run bind_cdecl_mf_test.cpp ;
|
||||
run bind_fastcall_mf_test.cpp ;
|
||||
run bind_stdcall_mf_test.cpp ;
|
||||
run mem_fn_cdecl_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run mem_fn_fastcall_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run mem_fn_stdcall_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run bind_noexcept_test.cpp ;
|
||||
run bind_noexcept_mf_test.cpp ;
|
||||
run global_placeholders.cpp ;
|
||||
run mem_fn_noexcept_test.cpp
|
||||
: : : <toolset>msvc-12.0:<build>no ;
|
||||
run bind_cpp20_test.cpp ;
|
||||
run protect_test2.cpp ;
|
||||
run protect_cpp20_test.cpp ;
|
||||
run bind_noexcept_mf2_test.cpp ;
|
||||
run std_placeholders_test.cpp ;
|
||||
run apply_test.cpp ;
|
||||
run apply_test2.cpp ;
|
||||
run apply_rv_test.cpp ;
|
||||
run apply_rv_test2.cpp ;
|
||||
run bind_over_test.cpp ;
|
||||
run bind_over_mf_test.cpp ;
|
||||
run bind_over_mf2_test.cpp ;
|
||||
run mem_fn_cdecl_ref_test.cpp ;
|
||||
run mem_fn_stdcall_ref_test.cpp ;
|
||||
run mem_fn_fastcall_ref_test.cpp ;
|
||||
77
test/apply_rv_test.cpp
Normal file
77
test/apply_rv_test.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include<boost/bind/apply.hpp>
|
||||
#include<boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_RVALUE_REFERENCES is defined")
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
struct F
|
||||
{
|
||||
public:
|
||||
|
||||
int operator()( int & x ) const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int operator()( int && x ) const
|
||||
{
|
||||
return -x;
|
||||
}
|
||||
};
|
||||
|
||||
int& get_lvalue_arg()
|
||||
{
|
||||
static int a = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
int get_prvalue_arg()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
F& get_lvalue_f()
|
||||
{
|
||||
static F f;
|
||||
return f;
|
||||
}
|
||||
|
||||
F get_prvalue_f()
|
||||
{
|
||||
return F();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::placeholders;
|
||||
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_lvalue_f), boost::bind(get_lvalue_arg))(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_lvalue_f), boost::bind(get_prvalue_arg))(), -2 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_prvalue_f), boost::bind(get_lvalue_arg))(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_prvalue_f), boost::bind(get_prvalue_arg))(), -2 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F&>(), _1), boost::bind(boost::apply<int&>(), _2))(get_lvalue_f, get_lvalue_arg), 1 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F&>(), _1), boost::bind(boost::apply<int>(), _2))(get_lvalue_f, get_prvalue_arg), -2 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F>(), _1), boost::bind(boost::apply<int&>(), _2))(get_prvalue_f, get_lvalue_arg), 1 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F>(), _1), boost::bind(boost::apply<int>(), _2))(get_prvalue_f, get_prvalue_arg), -2 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
92
test/apply_rv_test2.cpp
Normal file
92
test/apply_rv_test2.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include<boost/bind/apply.hpp>
|
||||
#include<boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_RVALUE_REFERENCES is defined")
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined")
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_NO_CXX11_REF_QUALIFIERS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_REF_QUALIFIERS is defined")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
struct F
|
||||
{
|
||||
public:
|
||||
|
||||
int operator()( int & x ) &
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int operator()( int && x ) &
|
||||
{
|
||||
return -x;
|
||||
}
|
||||
|
||||
int operator()( int & x ) &&
|
||||
{
|
||||
return x + 10;
|
||||
}
|
||||
|
||||
int operator()( int && x ) &&
|
||||
{
|
||||
return -x - 10;
|
||||
}
|
||||
};
|
||||
|
||||
int& get_lvalue_arg()
|
||||
{
|
||||
static int a = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
int get_prvalue_arg()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
F& get_lvalue_f()
|
||||
{
|
||||
static F f;
|
||||
return f;
|
||||
}
|
||||
|
||||
F get_prvalue_f()
|
||||
{
|
||||
return F();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::placeholders;
|
||||
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_lvalue_f), boost::bind(get_lvalue_arg))(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_lvalue_f), boost::bind(get_prvalue_arg))(), -2 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_prvalue_f), boost::bind(get_lvalue_arg))(), 11 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(get_prvalue_f), boost::bind(get_prvalue_arg))(), -12 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F&>(), _1), boost::bind(boost::apply<int&>(), _2))(get_lvalue_f, get_lvalue_arg), 1 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F&>(), _1), boost::bind(boost::apply<int>(), _2))(get_lvalue_f, get_prvalue_arg), -2 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F>(), _1), boost::bind(boost::apply<int&>(), _2))(get_prvalue_f, get_lvalue_arg), 11 );
|
||||
BOOST_TEST_EQ( boost::bind(boost::apply<int>(), boost::bind(boost::apply<F>(), _1), boost::bind(boost::apply<int>(), _2))(get_prvalue_f, get_prvalue_arg), -12 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
29
test/apply_test.cpp
Normal file
29
test/apply_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/bind/apply.hpp>
|
||||
#include <boost/bind/protect.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _1 ) ), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _2 ) ), 1, 2 )(), 2 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _3 ) ), 1, 2, 3 )(), 3 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _4 ) ), 1, 2, 3, 4 )(), 4 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _5 ) ), 1, 2, 3, 4, 5 )(), 5 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _6 ) ), 1, 2, 3, 4, 5, 6 )(), 6 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _7 ) ), 1, 2, 3, 4, 5, 6, 7 )(), 7 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::apply<int>(), boost::protect( boost::bind( f, _8 ) ), 1, 2, 3, 4, 5, 6, 7, 8 )(), 8 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
14
test/apply_test2.cpp
Normal file
14
test/apply_test2.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/bind/apply.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(void, boost::apply<void>::result_type);
|
||||
BOOST_TEST_TRAIT_SAME(int&, boost::apply<int&>::result_type);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
19
test/arg_copy_fail.cpp
Normal file
19
test/arg_copy_fail.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// arg_copy_fail.cpp - arg<1> to arg<2>
|
||||
//
|
||||
// Copyright 2016 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/bind/arg.hpp>
|
||||
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::arg<1> a1(( boost::arg<2>() ));
|
||||
(void)a1;
|
||||
}
|
||||
34
test/arg_copy_test.cpp
Normal file
34
test/arg_copy_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// arg_copy_test.cpp - copying a custom placeholder _1 to arg<1>
|
||||
//
|
||||
// Copyright 2016 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/is_placeholder.hpp>
|
||||
#include <boost/bind/arg.hpp>
|
||||
|
||||
//
|
||||
|
||||
template<int I> struct ph
|
||||
{
|
||||
};
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<int I> struct is_placeholder< ::ph<I> >
|
||||
{
|
||||
enum _vt { value = I };
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::arg<1> a1 = ph<1>();
|
||||
(void)a1;
|
||||
}
|
||||
77
test/bind_and_or_test.cpp
Normal file
77
test/bind_and_or_test.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_and_or_test.cpp - &&, || operators
|
||||
//
|
||||
// Copyright (c) 2008 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
bool f( bool x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
bool g( bool x )
|
||||
{
|
||||
return !x;
|
||||
}
|
||||
|
||||
bool h()
|
||||
{
|
||||
BOOST_ERROR( "Short-circuit evaluation failure" );
|
||||
return false;
|
||||
}
|
||||
|
||||
template< class F, class A1, class A2, class R > void test( F f, A1 a1, A2 a2, R r )
|
||||
{
|
||||
BOOST_TEST( f( a1, a2 ) == r );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// &&
|
||||
|
||||
test( boost::bind( f, true ) && boost::bind( g, true ), false, false, f( true ) && g( true ) );
|
||||
test( boost::bind( f, true ) && boost::bind( g, false ), false, false, f( true ) && g( false ) );
|
||||
|
||||
test( boost::bind( f, false ) && boost::bind( h ), false, false, f( false ) && h() );
|
||||
|
||||
test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, true, f( true ) && g( true ) );
|
||||
test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, false, f( true ) && g( false ) );
|
||||
|
||||
test( boost::bind( f, _1 ) && boost::bind( h ), false, false, f( false ) && h() );
|
||||
|
||||
// ||
|
||||
|
||||
test( boost::bind( f, false ) || boost::bind( g, true ), false, false, f( false ) || g( true ) );
|
||||
test( boost::bind( f, false ) || boost::bind( g, false ), false, false, f( false ) || g( false ) );
|
||||
|
||||
test( boost::bind( f, true ) || boost::bind( h ), false, false, f( true ) || h() );
|
||||
|
||||
test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, true, f( false ) || g( true ) );
|
||||
test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, false, f( false ) || g( false ) );
|
||||
|
||||
test( boost::bind( f, _1 ) || boost::bind( h ), true, false, f( true ) || h() );
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
165
test/bind_cdecl_mf_test.cpp
Normal file
165
test/bind_cdecl_mf_test.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_cdecl_mf_test.cpp - test for bind.hpp + __cdecl (member functions)
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#define BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int __cdecl f0() { f1(17); return 0; }
|
||||
int __cdecl g0() const { g1(17); return 0; }
|
||||
|
||||
int __cdecl f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
|
||||
int __cdecl g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
|
||||
int __cdecl f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
|
||||
int __cdecl g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
|
||||
|
||||
int __cdecl f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
|
||||
int __cdecl g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
|
||||
|
||||
int __cdecl f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
|
||||
int __cdecl g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
|
||||
|
||||
int __cdecl f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
|
||||
int __cdecl g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
|
||||
|
||||
int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
|
||||
int __cdecl g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
|
||||
|
||||
int __cdecl f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
|
||||
int __cdecl g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
|
||||
|
||||
int __cdecl f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
|
||||
int __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
|
||||
};
|
||||
|
||||
void member_function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
X x;
|
||||
|
||||
// 0
|
||||
|
||||
bind(&X::f0, &x)();
|
||||
bind(&X::f0, ref(x))();
|
||||
|
||||
bind(&X::g0, &x)();
|
||||
bind(&X::g0, x)();
|
||||
bind(&X::g0, ref(x))();
|
||||
|
||||
// 1
|
||||
|
||||
bind(&X::f1, &x, 1)();
|
||||
bind(&X::f1, ref(x), 1)();
|
||||
|
||||
bind(&X::g1, &x, 1)();
|
||||
bind(&X::g1, x, 1)();
|
||||
bind(&X::g1, ref(x), 1)();
|
||||
|
||||
// 2
|
||||
|
||||
bind(&X::f2, &x, 1, 2)();
|
||||
bind(&X::f2, ref(x), 1, 2)();
|
||||
|
||||
bind(&X::g2, &x, 1, 2)();
|
||||
bind(&X::g2, x, 1, 2)();
|
||||
bind(&X::g2, ref(x), 1, 2)();
|
||||
|
||||
// 3
|
||||
|
||||
bind(&X::f3, &x, 1, 2, 3)();
|
||||
bind(&X::f3, ref(x), 1, 2, 3)();
|
||||
|
||||
bind(&X::g3, &x, 1, 2, 3)();
|
||||
bind(&X::g3, x, 1, 2, 3)();
|
||||
bind(&X::g3, ref(x), 1, 2, 3)();
|
||||
|
||||
// 4
|
||||
|
||||
bind(&X::f4, &x, 1, 2, 3, 4)();
|
||||
bind(&X::f4, ref(x), 1, 2, 3, 4)();
|
||||
|
||||
bind(&X::g4, &x, 1, 2, 3, 4)();
|
||||
bind(&X::g4, x, 1, 2, 3, 4)();
|
||||
bind(&X::g4, ref(x), 1, 2, 3, 4)();
|
||||
|
||||
// 5
|
||||
|
||||
bind(&X::f5, &x, 1, 2, 3, 4, 5)();
|
||||
bind(&X::f5, ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
bind(&X::g5, &x, 1, 2, 3, 4, 5)();
|
||||
bind(&X::g5, x, 1, 2, 3, 4, 5)();
|
||||
bind(&X::g5, ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
// 6
|
||||
|
||||
bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
bind(&X::g6, x, 1, 2, 3, 4, 5, 6)();
|
||||
bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
// 7
|
||||
|
||||
bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
// 8
|
||||
|
||||
bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
175
test/bind_const_test.cpp
Normal file
175
test/bind_const_test.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_const_test.cpp - test const bind objects
|
||||
//
|
||||
// Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2001 David Abrahams
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
long f_0()
|
||||
{
|
||||
return 17041L;
|
||||
}
|
||||
|
||||
long f_1(long a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
long f_2(long a, long b)
|
||||
{
|
||||
return a + 10 * b;
|
||||
}
|
||||
|
||||
long f_3(long a, long b, long c)
|
||||
{
|
||||
return a + 10 * b + 100 * c;
|
||||
}
|
||||
|
||||
long f_4(long a, long b, long c, long d)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d;
|
||||
}
|
||||
|
||||
long f_5(long a, long b, long c, long d, long e)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
||||
}
|
||||
|
||||
long f_6(long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
||||
}
|
||||
|
||||
long f_7(long a, long b, long c, long d, long e, long f, long g)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
||||
}
|
||||
|
||||
long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
||||
}
|
||||
|
||||
long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
long global_result;
|
||||
|
||||
void fv_0()
|
||||
{
|
||||
global_result = 17041L;
|
||||
}
|
||||
|
||||
void fv_1(long a)
|
||||
{
|
||||
global_result = a;
|
||||
}
|
||||
|
||||
void fv_2(long a, long b)
|
||||
{
|
||||
global_result = a + 10 * b;
|
||||
}
|
||||
|
||||
void fv_3(long a, long b, long c)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c;
|
||||
}
|
||||
|
||||
void fv_4(long a, long b, long c, long d)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d;
|
||||
}
|
||||
|
||||
void fv_5(long a, long b, long c, long d, long e)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
||||
}
|
||||
|
||||
void fv_6(long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
||||
}
|
||||
|
||||
void fv_7(long a, long b, long c, long d, long e, long f, long g)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
||||
}
|
||||
|
||||
void fv_8(long a, long b, long c, long d, long e, long f, long g, long h)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
||||
}
|
||||
|
||||
void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
template<class F, class A> long test(F const & f, A const & a)
|
||||
{
|
||||
return f(a);
|
||||
}
|
||||
|
||||
template<class F, class A> long testv(F const & f, A const & a)
|
||||
{
|
||||
f(a);
|
||||
return global_result;
|
||||
}
|
||||
|
||||
void function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
int const i = 1;
|
||||
|
||||
BOOST_TEST( test( bind(f_0), i ) == 17041L );
|
||||
BOOST_TEST( test( bind(f_1, _1), i ) == 1L );
|
||||
BOOST_TEST( test( bind(f_2, _1, 2), i ) == 21L );
|
||||
BOOST_TEST( test( bind(f_3, _1, 2, 3), i ) == 321L );
|
||||
BOOST_TEST( test( bind(f_4, _1, 2, 3, 4), i ) == 4321L );
|
||||
BOOST_TEST( test( bind(f_5, _1, 2, 3, 4, 5), i ) == 54321L );
|
||||
BOOST_TEST( test( bind(f_6, _1, 2, 3, 4, 5, 6), i ) == 654321L );
|
||||
BOOST_TEST( test( bind(f_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L );
|
||||
BOOST_TEST( test( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L );
|
||||
BOOST_TEST( test( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L );
|
||||
|
||||
BOOST_TEST( testv( bind(fv_0), i ) == 17041L );
|
||||
BOOST_TEST( testv( bind(fv_1, _1), i ) == 1L );
|
||||
BOOST_TEST( testv( bind(fv_2, _1, 2), i ) == 21L );
|
||||
BOOST_TEST( testv( bind(fv_3, _1, 2, 3), i ) == 321L );
|
||||
BOOST_TEST( testv( bind(fv_4, _1, 2, 3, 4), i ) == 4321L );
|
||||
BOOST_TEST( testv( bind(fv_5, _1, 2, 3, 4, 5), i ) == 54321L );
|
||||
BOOST_TEST( testv( bind(fv_6, _1, 2, 3, 4, 5, 6), i ) == 654321L );
|
||||
BOOST_TEST( testv( bind(fv_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L );
|
||||
BOOST_TEST( testv( bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L );
|
||||
BOOST_TEST( testv( bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
42
test/bind_cpp20_test.cpp
Normal file
42
test/bind_cpp20_test.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <functional>
|
||||
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( boost::bind( std::plus<int>(), 1, 2 )(), 3 );
|
||||
BOOST_TEST_EQ( boost::bind( std::minus<int>(), 1, 2 )(), -1 );
|
||||
BOOST_TEST_EQ( boost::bind( std::multiplies<int>(), 1, 2 )(), 2 );
|
||||
BOOST_TEST_EQ( boost::bind( std::divides<int>(), 1, 2 )(), 0 );
|
||||
BOOST_TEST_EQ( boost::bind( std::modulus<int>(), 1, 2 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( std::negate<int>(), 1 )(), -1 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( std::equal_to<int>(), 1, 2 )(), false );
|
||||
BOOST_TEST_EQ( boost::bind( std::not_equal_to<int>(), 1, 2 )(), true );
|
||||
BOOST_TEST_EQ( boost::bind( std::greater<int>(), 1, 2 )(), false );
|
||||
BOOST_TEST_EQ( boost::bind( std::less<int>(), 1, 2 )(), true );
|
||||
BOOST_TEST_EQ( boost::bind( std::greater_equal<int>(), 1, 2 )(), false );
|
||||
BOOST_TEST_EQ( boost::bind( std::less_equal<int>(), 1, 2 )(), true );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( std::logical_and<int>(), 1, 2 )(), true );
|
||||
BOOST_TEST_EQ( boost::bind( std::logical_or<int>(), 1, 2 )(), true );
|
||||
BOOST_TEST_EQ( boost::bind( std::logical_not<int>(), 1 )(), false );
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1600)
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( std::bit_and<int>(), 1, 2 )(), 0 );
|
||||
BOOST_TEST_EQ( boost::bind( std::bit_or<int>(), 1, 2 )(), 3 );
|
||||
BOOST_TEST_EQ( boost::bind( std::bit_xor<int>(), 1, 2 )(), 3 );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
155
test/bind_cv_test.cpp
Normal file
155
test/bind_cv_test.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_cv_test.cpp
|
||||
//
|
||||
// Copyright (c) 2004 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
// SGI-related compilers have odd compiler-synthesized ctors dtors
|
||||
#ifdef __PATHSCALE__
|
||||
X() {}
|
||||
~X() {}
|
||||
#endif
|
||||
|
||||
int operator()()
|
||||
{
|
||||
return 17041;
|
||||
}
|
||||
|
||||
int operator()() const
|
||||
{
|
||||
return -17041;
|
||||
}
|
||||
|
||||
int operator()(int x1)
|
||||
{
|
||||
return x1;
|
||||
}
|
||||
|
||||
int operator()(int x1) const
|
||||
{
|
||||
return -x1;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2)
|
||||
{
|
||||
return x1+x2;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2) const
|
||||
{
|
||||
return -(x1+x2);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3)
|
||||
{
|
||||
return x1+x2+x3;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3) const
|
||||
{
|
||||
return -(x1+x2+x3);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4)
|
||||
{
|
||||
return x1+x2+x3+x4;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4) const
|
||||
{
|
||||
return -(x1+x2+x3+x4);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5)
|
||||
{
|
||||
return x1+x2+x3+x4+x5;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5) const
|
||||
{
|
||||
return -(x1+x2+x3+x4+x5);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6)
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6) const
|
||||
{
|
||||
return -(x1+x2+x3+x4+x5+x6);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7)
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6+x7;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) const
|
||||
{
|
||||
return -(x1+x2+x3+x4+x5+x6+x7);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8)
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6+x7+x8;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) const
|
||||
{
|
||||
return -(x1+x2+x3+x4+x5+x6+x7+x8);
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9)
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6+x7+x8+x9;
|
||||
}
|
||||
|
||||
int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) const
|
||||
{
|
||||
return -(x1+x2+x3+x4+x5+x6+x7+x8+x9);
|
||||
}
|
||||
};
|
||||
|
||||
template<class F> void test(F f, int r)
|
||||
{
|
||||
F const & cf = f;
|
||||
BOOST_TEST( cf() == -r );
|
||||
BOOST_TEST( f() == r );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test( boost::bind<int>( X() ), 17041 );
|
||||
test( boost::bind<int>( X(), 1 ), 1 );
|
||||
test( boost::bind<int>( X(), 1, 2 ), 1+2 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3 ), 1+2+3 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3, 4 ), 1+2+3+4 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3, 4, 5 ), 1+2+3+4+5 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6 ), 1+2+3+4+5+6 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7 ), 1+2+3+4+5+6+7 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 1+2+3+4+5+6+7+8 );
|
||||
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 1+2+3+4+5+6+7+8+9 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
63
test/bind_dm2_test.cpp
Normal file
63
test/bind_dm2_test.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_dm2_test.cpp - data members, advanced uses
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int m;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
char m[ 64 ];
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
X x = { 0 };
|
||||
X * px = &x;
|
||||
|
||||
boost::bind< int& >( &X::m, _1 )( px ) = 42;
|
||||
|
||||
BOOST_TEST( x.m == 42 );
|
||||
|
||||
boost::bind< int& >( &X::m, boost::ref(x) )() = 17041;
|
||||
|
||||
BOOST_TEST( x.m == 17041 );
|
||||
|
||||
X const * pcx = &x;
|
||||
|
||||
BOOST_TEST( boost::bind< long >( &X::m, _1 )( pcx ) == 17041L );
|
||||
BOOST_TEST( boost::bind< long >( &X::m, pcx )() == 17041L );
|
||||
|
||||
Y y = { "test" };
|
||||
std::string v( "test" );
|
||||
|
||||
BOOST_TEST( boost::bind< char const* >( &Y::m, &y )() == v );
|
||||
BOOST_TEST( boost::bind< std::string >( &Y::m, &y )() == v );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
44
test/bind_dm3_test.cpp
Normal file
44
test/bind_dm3_test.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_dm3_test.cpp - data members (regression 1.31 - 1.32)
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 130000 && BOOST_GCC < 150000
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113256
|
||||
# pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
#endif
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <utility>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<int, int> pair_type;
|
||||
|
||||
pair_type pair( 10, 20 );
|
||||
|
||||
int const & x = boost::bind( &pair_type::first, _1 )( pair );
|
||||
|
||||
BOOST_TEST( &pair.first == &x );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
66
test/bind_dm_test.cpp
Normal file
66
test/bind_dm_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_dm_test.cpp - data members
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int m;
|
||||
};
|
||||
|
||||
X f( int v )
|
||||
{
|
||||
X r = { v };
|
||||
return r;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
X x = { 17041 };
|
||||
X * px = &x;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( x ) == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( px ) == 17041 );
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, x )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, px )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, boost::ref(x) )() == 17041 );
|
||||
|
||||
|
||||
X const cx = x;
|
||||
X const * pcx = &cx;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( cx ) == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( pcx ) == 17041 );
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, cx )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, pcx )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, boost::ref(cx) )() == 17041 );
|
||||
|
||||
int const v = 42;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, boost::bind( f, _1 ) )( v ) == v );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
53
test/bind_eq2_test.cpp
Normal file
53
test/bind_eq2_test.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_eq2_test.cpp - boost::bind equality operator
|
||||
//
|
||||
// Copyright (c) 2004, 2005, 2009 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/function_equal.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
void f( int )
|
||||
{
|
||||
}
|
||||
|
||||
int g( int i )
|
||||
{
|
||||
return i + 5;
|
||||
}
|
||||
|
||||
template< class F > void test_self_equal( F f )
|
||||
{
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
using boost::function_equal;
|
||||
#endif
|
||||
|
||||
BOOST_TEST( function_equal( f, f ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_self_equal( boost::bind( f, _1 ) );
|
||||
test_self_equal( boost::bind( g, _1 ) );
|
||||
test_self_equal( boost::bind( f, boost::bind( g, _1 ) ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
49
test/bind_eq3_test.cpp
Normal file
49
test/bind_eq3_test.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_eq3_test.cpp - function_equal with bind and weak_ptr
|
||||
//
|
||||
// Copyright (c) 2004, 2005, 2009 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/function_equal.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
int f( boost::weak_ptr<void> wp )
|
||||
{
|
||||
return wp.use_count();
|
||||
}
|
||||
|
||||
template< class F > void test_self_equal( F f )
|
||||
{
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
using boost::function_equal;
|
||||
#endif
|
||||
|
||||
BOOST_TEST( function_equal( f, f ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_self_equal( boost::bind( f, _1 ) );
|
||||
test_self_equal( boost::bind( f, boost::weak_ptr<void>() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
404
test/bind_eq_test.cpp
Normal file
404
test/bind_eq_test.cpp
Normal file
@@ -0,0 +1,404 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_eq_test.cpp - boost::bind equality operator
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int i_;
|
||||
|
||||
explicit X(int i): i_(i)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(X const & rhs) const
|
||||
{
|
||||
return i_ == rhs.i_;
|
||||
}
|
||||
};
|
||||
|
||||
// f_*
|
||||
|
||||
int f_0()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_1(X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_2(X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_3(X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_4(X, X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_5(X, X, X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_6(X, X, X, X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_7(X, X, X, X, X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_8(X, X, X, X, X, X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f_9(X, X, X, X, X, X, X, X, X)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// fv_*
|
||||
|
||||
void fv_0()
|
||||
{
|
||||
}
|
||||
|
||||
void fv_1(X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_2(X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_3(X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_4(X, X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_5(X, X, X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_6(X, X, X, X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_7(X, X, X, X, X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_8(X, X, X, X, X, X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
void fv_9(X, X, X, X, X, X, X, X, X)
|
||||
{
|
||||
}
|
||||
|
||||
template<class F> void test_eq(F f1, F f2)
|
||||
{
|
||||
BOOST_TEST( function_equal( f1, f2 ) );
|
||||
}
|
||||
|
||||
template<class F> void test_ne(F f1, F f2)
|
||||
{
|
||||
BOOST_TEST( !function_equal( f1, f2 ) );
|
||||
}
|
||||
|
||||
// 0
|
||||
|
||||
template<class F> void test_0(F f)
|
||||
{
|
||||
test_eq( boost::bind(f), boost::bind(f) );
|
||||
}
|
||||
|
||||
// 1
|
||||
|
||||
template<class F, class V> void test_1_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1), boost::bind(f, v1) );
|
||||
test_ne( boost::bind(f, v1), boost::bind(f, v2) );
|
||||
}
|
||||
|
||||
template<class F> void test_1(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1), boost::bind(f, _1) );
|
||||
|
||||
test_1_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_1_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 2
|
||||
|
||||
template<class F, class V> void test_2_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1), boost::bind(f, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1), boost::bind(f, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1), boost::bind(f, v2, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_2(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2), boost::bind(f, _1, _2) );
|
||||
|
||||
test_2_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_2_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 3
|
||||
|
||||
template<class F, class V> void test_3_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1), boost::bind(f, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1), boost::bind(f, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1), boost::bind(f, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1), boost::bind(f, v2, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_3(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3), boost::bind(f, _1, _2, _3) );
|
||||
|
||||
test_3_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_3_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 4
|
||||
|
||||
template<class F, class V> void test_4_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_4(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3, _4), boost::bind(f, _1, _2, _3, _4) );
|
||||
|
||||
test_4_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_4_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 5
|
||||
|
||||
template<class F, class V> void test_5_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_5(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3, _4, _5), boost::bind(f, _1, _2, _3, _4, _5) );
|
||||
|
||||
test_5_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_5_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 6
|
||||
|
||||
template<class F, class V> void test_6_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_6(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6), boost::bind(f, _1, _2, _3, _4, _5, _6) );
|
||||
|
||||
test_6_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_6_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 7
|
||||
|
||||
template<class F, class V> void test_7_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_7(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6, _7), boost::bind(f, _1, _2, _3, _4, _5, _6, _7) );
|
||||
|
||||
test_7_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_7_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 8
|
||||
|
||||
template<class F, class V> void test_8_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_8(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6, _7, _8), boost::bind(f, _1, _2, _3, _4, _5, _6, _7, _8) );
|
||||
|
||||
test_8_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_8_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
// 9
|
||||
|
||||
template<class F, class V> void test_9_(F f, V v1, V v2)
|
||||
{
|
||||
test_eq( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v2) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v2, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v1, v2, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v1, v2, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v1, v2, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v1, v2, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v1, v2, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v1, v2, v1, v1, v1, v1, v1, v1, v1) );
|
||||
test_ne( boost::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), boost::bind(f, v2, v1, v1, v1, v1, v1, v1, v1, v1) );
|
||||
}
|
||||
|
||||
template<class F> void test_9(F f)
|
||||
{
|
||||
test_eq( boost::bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9), boost::bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9) );
|
||||
|
||||
test_9_( f, X(1), X(2) );
|
||||
|
||||
X a(0), b(0);
|
||||
test_9_( f, boost::ref(a), boost::ref(b) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// 0
|
||||
|
||||
test_0( f_0 );
|
||||
test_0( fv_0 );
|
||||
|
||||
// 1
|
||||
|
||||
test_1( f_1 );
|
||||
test_1( fv_1 );
|
||||
|
||||
// 2
|
||||
|
||||
test_2( f_2 );
|
||||
test_2( fv_2 );
|
||||
|
||||
// 3
|
||||
|
||||
test_3( f_3 );
|
||||
test_3( fv_3 );
|
||||
|
||||
// 4
|
||||
|
||||
test_4( f_4 );
|
||||
test_4( fv_4 );
|
||||
|
||||
// 5
|
||||
|
||||
test_5( f_5 );
|
||||
test_5( fv_5 );
|
||||
|
||||
// 6
|
||||
|
||||
test_6( f_6 );
|
||||
test_6( fv_6 );
|
||||
|
||||
// 7
|
||||
|
||||
test_7( f_7 );
|
||||
test_7( fv_7 );
|
||||
|
||||
// 8
|
||||
|
||||
test_8( f_8 );
|
||||
test_8( fv_8 );
|
||||
|
||||
// 9
|
||||
|
||||
test_9( f_9 );
|
||||
test_9( fv_9 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
@@ -10,27 +20,17 @@
|
||||
//
|
||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#define BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
@@ -161,3 +161,5 @@ int main()
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
@@ -10,27 +20,17 @@
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#define BOOST_BIND_ENABLE_FASTCALL
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
@@ -107,3 +107,5 @@ int main()
|
||||
function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
162
test/bind_fn2_test.cpp
Normal file
162
test/bind_fn2_test.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_fn2_test.cpp - test for functions w/ the type<> syntax
|
||||
//
|
||||
// Copyright (c) 2005, 2008 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
long global_result;
|
||||
|
||||
// long
|
||||
|
||||
long f_0()
|
||||
{
|
||||
return global_result = 17041L;
|
||||
}
|
||||
|
||||
long f_1(long a)
|
||||
{
|
||||
return global_result = a;
|
||||
}
|
||||
|
||||
long f_2(long a, long b)
|
||||
{
|
||||
return global_result = a + 10 * b;
|
||||
}
|
||||
|
||||
long f_3(long a, long b, long c)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c;
|
||||
}
|
||||
|
||||
long f_4(long a, long b, long c, long d)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c + 1000 * d;
|
||||
}
|
||||
|
||||
long f_5(long a, long b, long c, long d, long e)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
||||
}
|
||||
|
||||
long f_6(long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
||||
}
|
||||
|
||||
long f_7(long a, long b, long c, long d, long e, long f, long g)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
||||
}
|
||||
|
||||
long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
||||
}
|
||||
|
||||
long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
|
||||
{
|
||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
// void
|
||||
|
||||
void fv_0()
|
||||
{
|
||||
global_result = 17041L;
|
||||
}
|
||||
|
||||
void fv_1(long a)
|
||||
{
|
||||
global_result = a;
|
||||
}
|
||||
|
||||
void fv_2(long a, long b)
|
||||
{
|
||||
global_result = a + 10 * b;
|
||||
}
|
||||
|
||||
void fv_3(long a, long b, long c)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c;
|
||||
}
|
||||
|
||||
void fv_4(long a, long b, long c, long d)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d;
|
||||
}
|
||||
|
||||
void fv_5(long a, long b, long c, long d, long e)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
||||
}
|
||||
|
||||
void fv_6(long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
||||
}
|
||||
|
||||
void fv_7(long a, long b, long c, long d, long e, long f, long g)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
||||
}
|
||||
|
||||
void fv_8(long a, long b, long c, long d, long e, long f, long g, long h)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
||||
}
|
||||
|
||||
void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
|
||||
{
|
||||
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
void function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
bind( type<void>(), f_0 )(); BOOST_TEST( global_result == 17041L );
|
||||
bind( type<void>(), f_1, 1 )(); BOOST_TEST( global_result == 1L );
|
||||
bind( type<void>(), f_2, 1, 2 )(); BOOST_TEST( global_result == 21L );
|
||||
bind( type<void>(), f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L );
|
||||
bind( type<void>(), f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L );
|
||||
bind( type<void>(), f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L );
|
||||
bind( type<void>(), f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L );
|
||||
bind( type<void>(), f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L );
|
||||
bind( type<void>(), f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L );
|
||||
bind( type<void>(), f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L );
|
||||
|
||||
bind( type<void>(), fv_0 )(); BOOST_TEST( global_result == 17041L );
|
||||
bind( type<void>(), fv_1, 1 )(); BOOST_TEST( global_result == 1L );
|
||||
bind( type<void>(), fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L );
|
||||
bind( type<void>(), fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L );
|
||||
bind( type<void>(), fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L );
|
||||
bind( type<void>(), fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L );
|
||||
bind( type<void>(), fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L );
|
||||
bind( type<void>(), fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L );
|
||||
bind( type<void>(), fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L );
|
||||
bind( type<void>(), fv_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
67
test/bind_fnobj2_test.cpp
Normal file
67
test/bind_fnobj2_test.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_fnobj2_test.cpp - test for function objects w/ the type<> syntax
|
||||
//
|
||||
// Copyright (c) 2005, 2008 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int operator()() const { operator()(17); return 0; }
|
||||
int operator()(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
int operator()(int a1, int a2) const { operator()(a1); operator()(a2); return 0; }
|
||||
int operator()(int a1, int a2, int a3) const { operator()(a1, a2); operator()(a3); return 0; }
|
||||
int operator()(int a1, int a2, int a3, int a4) const { operator()(a1, a2, a3); operator()(a4); return 0; }
|
||||
int operator()(int a1, int a2, int a3, int a4, int a5) const { operator()(a1, a2, a3, a4); operator()(a5); return 0; }
|
||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6) const { operator()(a1, a2, a3, a4, a5); operator()(a6); return 0; }
|
||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { operator()(a1, a2, a3, a4, a5, a6); operator()(a7); return 0; }
|
||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { operator()(a1, a2, a3, a4, a5, a6, a7); operator()(a8); return 0; }
|
||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) const { operator()(a1, a2, a3, a4, a5, a6, a7, a8); operator()(a9); return 0; }
|
||||
};
|
||||
|
||||
void function_object_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
X x;
|
||||
|
||||
bind( type<void>(), ref(x) )();
|
||||
bind( type<void>(), ref(x), 1 )();
|
||||
bind( type<void>(), ref(x), 1, 2 )();
|
||||
bind( type<void>(), ref(x), 1, 2, 3 )();
|
||||
bind( type<void>(), ref(x), 1, 2, 3, 4 )();
|
||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5 )();
|
||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6 )();
|
||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )();
|
||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7, 8, 9 )();
|
||||
|
||||
BOOST_TEST( x.hash == 9932 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
function_object_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
130
test/bind_function2_test.cpp
Normal file
130
test/bind_function2_test.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ( defined(BOOST_GCC) && BOOST_GCC < 40600 )
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test for GCC 4.4 -std=c++0x" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// bind_function2_test.cpp - regression test
|
||||
//
|
||||
// Copyright (c) 2015 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
void fv1( int & a )
|
||||
{
|
||||
a = 17041;
|
||||
}
|
||||
|
||||
void fv2( int & a, int b )
|
||||
{
|
||||
a = b;
|
||||
}
|
||||
|
||||
void fv3( int & a, int b, int c )
|
||||
{
|
||||
a = b + c;
|
||||
}
|
||||
|
||||
void fv4( int & a, int b, int c, int d )
|
||||
{
|
||||
a = b + c + d;
|
||||
}
|
||||
|
||||
void fv5( int & a, int b, int c, int d, int e )
|
||||
{
|
||||
a = b + c + d + e;
|
||||
}
|
||||
|
||||
void fv6( int & a, int b, int c, int d, int e, int f )
|
||||
{
|
||||
a = b + c + d + e + f;
|
||||
}
|
||||
|
||||
void fv7( int & a, int b, int c, int d, int e, int f, int g )
|
||||
{
|
||||
a = b + c + d + e + f + g;
|
||||
}
|
||||
|
||||
void fv8( int & a, int b, int c, int d, int e, int f, int g, int h )
|
||||
{
|
||||
a = b + c + d + e + f + g + h;
|
||||
}
|
||||
|
||||
void fv9( int & a, int b, int c, int d, int e, int f, int g, int h, int i )
|
||||
{
|
||||
a = b + c + d + e + f + g + h + i;
|
||||
}
|
||||
|
||||
void function_test()
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
{
|
||||
boost::function<void(int&)> fw1 = boost::bind( fv1, _1 );
|
||||
fw1( x ); BOOST_TEST( x == 17041 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int)> fw2 = boost::bind( fv2, _1, _2 );
|
||||
fw2( x, 1 ); BOOST_TEST( x == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int)> fw3 = boost::bind( fv3, _1, _2, _3 );
|
||||
fw3( x, 1, 2 ); BOOST_TEST( x == 1+2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int, int)> fw4 = boost::bind( fv4, _1, _2, _3, _4 );
|
||||
fw4( x, 1, 2, 3 ); BOOST_TEST( x == 1+2+3 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int, int, int)> fw5 = boost::bind( fv5, _1, _2, _3, _4, _5 );
|
||||
fw5( x, 1, 2, 3, 4 ); BOOST_TEST( x == 1+2+3+4 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int, int, int, int)> fw6 = boost::bind( fv6, _1, _2, _3, _4, _5, _6 );
|
||||
fw6( x, 1, 2, 3, 4, 5 ); BOOST_TEST( x == 1+2+3+4+5 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int, int, int, int, int)> fw7 = boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 );
|
||||
fw7( x, 1, 2, 3, 4, 5, 6 ); BOOST_TEST( x == 1+2+3+4+5+6 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int, int, int, int, int, int)> fw8 = boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 );
|
||||
fw8( x, 1, 2, 3, 4, 5, 6, 7 ); BOOST_TEST( x == 1+2+3+4+5+6+7 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(int&, int, int, int, int, int, int, int, int)> fw9 = boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 );
|
||||
fw9( x, 1, 2, 3, 4, 5, 6, 7, 8 ); BOOST_TEST( x == 1+2+3+4+5+6+7+8 );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
241
test/bind_function_ap_test.cpp
Normal file
241
test/bind_function_ap_test.cpp
Normal file
@@ -0,0 +1,241 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
//
|
||||
// bind_function_ap_test.cpp - regression test
|
||||
//
|
||||
// Copyright (c) 2015 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(BOOST_NO_AUTO_PTR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_AUTO_PTR is defined" )
|
||||
int main() {}
|
||||
|
||||
#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ( defined(BOOST_GCC) && BOOST_GCC < 40600 )
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test for GCC 4.4 -std=c++0x" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#if defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 406 )
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined( __clang__ ) && defined( __has_warning )
|
||||
# if __has_warning( "-Wdeprecated-declarations" )
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <memory>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
void fv1( std::auto_ptr<int> p1 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
}
|
||||
|
||||
void fv2( std::auto_ptr<int> p1, std::auto_ptr<int> p2 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
}
|
||||
|
||||
void fv3( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
}
|
||||
|
||||
void fv4( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
BOOST_TEST( *p4 == 4 );
|
||||
}
|
||||
|
||||
void fv5( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
BOOST_TEST( *p4 == 4 );
|
||||
BOOST_TEST( *p5 == 5 );
|
||||
}
|
||||
|
||||
void fv6( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
BOOST_TEST( *p4 == 4 );
|
||||
BOOST_TEST( *p5 == 5 );
|
||||
BOOST_TEST( *p6 == 6 );
|
||||
}
|
||||
|
||||
void fv7( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
BOOST_TEST( *p4 == 4 );
|
||||
BOOST_TEST( *p5 == 5 );
|
||||
BOOST_TEST( *p6 == 6 );
|
||||
BOOST_TEST( *p7 == 7 );
|
||||
}
|
||||
|
||||
void fv8( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7, std::auto_ptr<int> p8 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
BOOST_TEST( *p4 == 4 );
|
||||
BOOST_TEST( *p5 == 5 );
|
||||
BOOST_TEST( *p6 == 6 );
|
||||
BOOST_TEST( *p7 == 7 );
|
||||
BOOST_TEST( *p8 == 8 );
|
||||
}
|
||||
|
||||
void fv9( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7, std::auto_ptr<int> p8, std::auto_ptr<int> p9 )
|
||||
{
|
||||
BOOST_TEST( *p1 == 1 );
|
||||
BOOST_TEST( *p2 == 2 );
|
||||
BOOST_TEST( *p3 == 3 );
|
||||
BOOST_TEST( *p4 == 4 );
|
||||
BOOST_TEST( *p5 == 5 );
|
||||
BOOST_TEST( *p6 == 6 );
|
||||
BOOST_TEST( *p7 == 7 );
|
||||
BOOST_TEST( *p8 == 8 );
|
||||
BOOST_TEST( *p9 == 9 );
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>)> fw1 = boost::bind( fv1, _1 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
|
||||
fw1( p1 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>)> fw2 = boost::bind( fv2, _1, _2 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
|
||||
fw2( p1, p2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw3 = boost::bind( fv3, _1, _2, _3 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
|
||||
fw3( p1, p2, p3 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw4 = boost::bind( fv4, _1, _2, _3, _4 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
std::auto_ptr<int> p4( new int(4) );
|
||||
|
||||
fw4( p1, p2, p3, p4 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw5 = boost::bind( fv5, _1, _2, _3, _4, _5 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
std::auto_ptr<int> p4( new int(4) );
|
||||
std::auto_ptr<int> p5( new int(5) );
|
||||
|
||||
fw5( p1, p2, p3, p4, p5 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw6 = boost::bind( fv6, _1, _2, _3, _4, _5, _6 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
std::auto_ptr<int> p4( new int(4) );
|
||||
std::auto_ptr<int> p5( new int(5) );
|
||||
std::auto_ptr<int> p6( new int(6) );
|
||||
|
||||
fw6( p1, p2, p3, p4, p5, p6 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw7 = boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
std::auto_ptr<int> p4( new int(4) );
|
||||
std::auto_ptr<int> p5( new int(5) );
|
||||
std::auto_ptr<int> p6( new int(6) );
|
||||
std::auto_ptr<int> p7( new int(7) );
|
||||
|
||||
fw7( p1, p2, p3, p4, p5, p6, p7 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw8 = boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
std::auto_ptr<int> p4( new int(4) );
|
||||
std::auto_ptr<int> p5( new int(5) );
|
||||
std::auto_ptr<int> p6( new int(6) );
|
||||
std::auto_ptr<int> p7( new int(7) );
|
||||
std::auto_ptr<int> p8( new int(8) );
|
||||
|
||||
fw8( p1, p2, p3, p4, p5, p6, p7, p8 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw9 = boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 );
|
||||
|
||||
std::auto_ptr<int> p1( new int(1) );
|
||||
std::auto_ptr<int> p2( new int(2) );
|
||||
std::auto_ptr<int> p3( new int(3) );
|
||||
std::auto_ptr<int> p4( new int(4) );
|
||||
std::auto_ptr<int> p5( new int(5) );
|
||||
std::auto_ptr<int> p6( new int(6) );
|
||||
std::auto_ptr<int> p7( new int(7) );
|
||||
std::auto_ptr<int> p8( new int(8) );
|
||||
std::auto_ptr<int> p9( new int(9) );
|
||||
|
||||
fw9( p1, p2, p3, p4, p5, p6, p7, p8, p9 );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
69
test/bind_function_test.cpp
Normal file
69
test/bind_function_test.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_function_test.cpp - function<>
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int g( int x )
|
||||
{
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::function0<int> fn;
|
||||
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
fn = boost::bind( f, 1 );
|
||||
|
||||
BOOST_TEST( fn() == 1 );
|
||||
|
||||
BOOST_TEST( fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
fn = boost::bind( f, 2 );
|
||||
|
||||
BOOST_TEST( fn() == 2 );
|
||||
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
fn = boost::bind( g, 1 );
|
||||
|
||||
BOOST_TEST( fn() == 2 );
|
||||
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
123
test/bind_fwd2_test.cpp
Normal file
123
test/bind_fwd2_test.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// bind_fwd2_test.cpp - forwarding test for 2 arguments
|
||||
//
|
||||
// Copyright (c) 2015 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
int fv1( int const & a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
void fv2_1( int & a, int const & b )
|
||||
{
|
||||
a = b;
|
||||
}
|
||||
|
||||
void fv2_2( int const & a, int & b )
|
||||
{
|
||||
b = a;
|
||||
}
|
||||
|
||||
int fv2_3( int const & a, int const & b )
|
||||
{
|
||||
return a+b;
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
{
|
||||
int const a = 1;
|
||||
int r = boost::bind( fv1, _1 )( a );
|
||||
BOOST_TEST( r == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int r = boost::bind( fv1, _1 )( 1 );
|
||||
BOOST_TEST( r == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 1;
|
||||
int const b = 2;
|
||||
|
||||
boost::bind( fv2_1, _1, _2 )( a, b );
|
||||
|
||||
BOOST_TEST( a == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 1;
|
||||
|
||||
boost::bind( fv2_1, _1, _2 )( a, 2 );
|
||||
|
||||
BOOST_TEST( a == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int const a = 1;
|
||||
int b = 2;
|
||||
|
||||
boost::bind( fv2_2, _1, _2 )( a, b );
|
||||
|
||||
BOOST_TEST( b == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int b = 2;
|
||||
|
||||
boost::bind( fv2_2, _1, _2 )( 1, b );
|
||||
|
||||
BOOST_TEST( b == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int const a = 1;
|
||||
int const b = 2;
|
||||
|
||||
int r = boost::bind( fv2_3, _1, _2 )( a, b );
|
||||
|
||||
BOOST_TEST( r == 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int const a = 1;
|
||||
|
||||
int r = boost::bind( fv2_3, _1, _2 )( a, 2 );
|
||||
|
||||
BOOST_TEST( r == 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int const b = 2;
|
||||
|
||||
int r = boost::bind( fv2_3, _1, _2 )( 1, b );
|
||||
|
||||
BOOST_TEST( r == 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int r = boost::bind( fv2_3, _1, _2 )( 1, 2 );
|
||||
|
||||
BOOST_TEST( r == 3 );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
252
test/bind_fwd_test.cpp
Normal file
252
test/bind_fwd_test.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// bind_fwd_test.cpp - forwarding test
|
||||
//
|
||||
// Copyright (c) 2015 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
void fv1( int & a )
|
||||
{
|
||||
a = 1;
|
||||
}
|
||||
|
||||
void fv2( int & a, int & b )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
}
|
||||
|
||||
void fv3( int & a, int & b, int & c )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
}
|
||||
|
||||
void fv4( int & a, int & b, int & c, int & d )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
d = 4;
|
||||
}
|
||||
|
||||
void fv5( int & a, int & b, int & c, int & d, int & e )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
d = 4;
|
||||
e = 5;
|
||||
}
|
||||
|
||||
void fv6( int & a, int & b, int & c, int & d, int & e, int & f )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
d = 4;
|
||||
e = 5;
|
||||
f = 6;
|
||||
}
|
||||
|
||||
void fv7( int & a, int & b, int & c, int & d, int & e, int & f, int & g )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
d = 4;
|
||||
e = 5;
|
||||
f = 6;
|
||||
g = 7;
|
||||
}
|
||||
|
||||
void fv8( int & a, int & b, int & c, int & d, int & e, int & f, int & g, int & h )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
d = 4;
|
||||
e = 5;
|
||||
f = 6;
|
||||
g = 7;
|
||||
h = 8;
|
||||
}
|
||||
|
||||
void fv9( int & a, int & b, int & c, int & d, int & e, int & f, int & g, int & h, int & i )
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
d = 4;
|
||||
e = 5;
|
||||
f = 6;
|
||||
g = 7;
|
||||
h = 8;
|
||||
i = 9;
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
{
|
||||
int a = 0;
|
||||
|
||||
boost::bind( fv1, _1 )( a );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
|
||||
boost::bind( fv2, _1, _2 )( a, b );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
|
||||
boost::bind( fv3, _1, _2, _3 )( a, b, c );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
|
||||
boost::bind( fv4, _1, _2, _3, _4 )( a, b, c, d );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
BOOST_TEST( d == 4 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
int e = 0;
|
||||
|
||||
boost::bind( fv5, _1, _2, _3, _4, _5 )( a, b, c, d, e );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
BOOST_TEST( d == 4 );
|
||||
BOOST_TEST( e == 5 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
int e = 0;
|
||||
int f = 0;
|
||||
|
||||
boost::bind( fv6, _1, _2, _3, _4, _5, _6 )( a, b, c, d, e, f );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
BOOST_TEST( d == 4 );
|
||||
BOOST_TEST( e == 5 );
|
||||
BOOST_TEST( f == 6 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
int e = 0;
|
||||
int f = 0;
|
||||
int g = 0;
|
||||
|
||||
boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 )( a, b, c, d, e, f, g );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
BOOST_TEST( d == 4 );
|
||||
BOOST_TEST( e == 5 );
|
||||
BOOST_TEST( f == 6 );
|
||||
BOOST_TEST( g == 7 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
int e = 0;
|
||||
int f = 0;
|
||||
int g = 0;
|
||||
int h = 0;
|
||||
|
||||
boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 )( a, b, c, d, e, f, g, h );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
BOOST_TEST( d == 4 );
|
||||
BOOST_TEST( e == 5 );
|
||||
BOOST_TEST( f == 6 );
|
||||
BOOST_TEST( g == 7 );
|
||||
BOOST_TEST( h == 8 );
|
||||
}
|
||||
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
int e = 0;
|
||||
int f = 0;
|
||||
int g = 0;
|
||||
int h = 0;
|
||||
int i = 0;
|
||||
|
||||
boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 )( a, b, c, d, e, f, g, h, i );
|
||||
|
||||
BOOST_TEST( a == 1 );
|
||||
BOOST_TEST( b == 2 );
|
||||
BOOST_TEST( c == 3 );
|
||||
BOOST_TEST( d == 4 );
|
||||
BOOST_TEST( e == 5 );
|
||||
BOOST_TEST( f == 6 );
|
||||
BOOST_TEST( g == 7 );
|
||||
BOOST_TEST( h == 8 );
|
||||
BOOST_TEST( i == 9 );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
40
test/bind_lookup_problem_test.cpp
Normal file
40
test/bind_lookup_problem_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// bind_lookup_problem_test.cpp
|
||||
//
|
||||
// Copyright (C) Markus Schoepflin 2005.
|
||||
//
|
||||
// Use, modification, and distribution are subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
|
||||
template<class T> void value();
|
||||
|
||||
void f0() { }
|
||||
void f1(int) { }
|
||||
void f2(int, int) { }
|
||||
void f3(int, int, int) { }
|
||||
void f4(int, int, int, int) { }
|
||||
void f5(int, int, int, int, int) { }
|
||||
void f6(int, int, int, int, int, int) { }
|
||||
void f7(int, int, int, int, int, int, int) { }
|
||||
void f8(int, int, int, int, int, int, int, int) { }
|
||||
void f9(int, int, int, int, int, int, int, int, int) { }
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f0);
|
||||
boost::bind(f1, 0);
|
||||
boost::bind(f2, 0, 0);
|
||||
boost::bind(f3, 0, 0, 0);
|
||||
boost::bind(f4, 0, 0, 0, 0);
|
||||
boost::bind(f5, 0, 0, 0, 0, 0);
|
||||
boost::bind(f6, 0, 0, 0, 0, 0, 0);
|
||||
boost::bind(f7, 0, 0, 0, 0, 0, 0, 0);
|
||||
boost::bind(f8, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
boost::bind(f9, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
153
test/bind_mf2_test.cpp
Normal file
153
test/bind_mf2_test.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_mf2_test.cpp - test for member functions w/ the type<> syntax
|
||||
//
|
||||
// Copyright (c) 2005, 2008 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int f0() { f1(17); return 0; }
|
||||
int g0() const { g1(17); return 0; }
|
||||
|
||||
int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
|
||||
int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
|
||||
int f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
|
||||
int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
|
||||
|
||||
int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
|
||||
int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
|
||||
|
||||
int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
|
||||
int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
|
||||
|
||||
int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
|
||||
int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
|
||||
|
||||
int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
|
||||
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
|
||||
|
||||
int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
|
||||
int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
|
||||
|
||||
int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
|
||||
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
|
||||
};
|
||||
|
||||
void member_function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
X x;
|
||||
|
||||
// 0
|
||||
|
||||
bind( type<void>(), &X::f0, &x )();
|
||||
bind( type<void>(), &X::f0, ref(x) )();
|
||||
|
||||
bind( type<void>(), &X::g0, &x )();
|
||||
bind( type<void>(), &X::g0, x )();
|
||||
bind( type<void>(), &X::g0, ref(x) )();
|
||||
|
||||
// 1
|
||||
|
||||
bind( type<void>(), &X::f1, &x, 1 )();
|
||||
bind( type<void>(), &X::f1, ref(x), 1 )();
|
||||
|
||||
bind( type<void>(), &X::g1, &x, 1 )();
|
||||
bind( type<void>(), &X::g1, x, 1 )();
|
||||
bind( type<void>(), &X::g1, ref(x), 1 )();
|
||||
|
||||
// 2
|
||||
|
||||
bind( type<void>(), &X::f2, &x, 1, 2 )();
|
||||
bind( type<void>(), &X::f2, ref(x), 1, 2 )();
|
||||
|
||||
bind( type<void>(), &X::g2, &x, 1, 2 )();
|
||||
bind( type<void>(), &X::g2, x, 1, 2 )();
|
||||
bind( type<void>(), &X::g2, ref(x), 1, 2 )();
|
||||
|
||||
// 3
|
||||
|
||||
bind( type<void>(), &X::f3, &x, 1, 2, 3 )();
|
||||
bind( type<void>(), &X::f3, ref(x), 1, 2, 3 )();
|
||||
|
||||
bind( type<void>(), &X::g3, &x, 1, 2, 3 )();
|
||||
bind( type<void>(), &X::g3, x, 1, 2, 3 )();
|
||||
bind( type<void>(), &X::g3, ref(x), 1, 2, 3 )();
|
||||
|
||||
// 4
|
||||
|
||||
bind( type<void>(), &X::f4, &x, 1, 2, 3, 4 )();
|
||||
bind( type<void>(), &X::f4, ref(x), 1, 2, 3, 4 )();
|
||||
|
||||
bind( type<void>(), &X::g4, &x, 1, 2, 3, 4 )();
|
||||
bind( type<void>(), &X::g4, x, 1, 2, 3, 4 )();
|
||||
bind( type<void>(), &X::g4, ref(x), 1, 2, 3, 4 )();
|
||||
|
||||
// 5
|
||||
|
||||
bind( type<void>(), &X::f5, &x, 1, 2, 3, 4, 5 )();
|
||||
bind( type<void>(), &X::f5, ref(x), 1, 2, 3, 4, 5 )();
|
||||
|
||||
bind( type<void>(), &X::g5, &x, 1, 2, 3, 4, 5 )();
|
||||
bind( type<void>(), &X::g5, x, 1, 2, 3, 4, 5 )();
|
||||
bind( type<void>(), &X::g5, ref(x), 1, 2, 3, 4, 5 )();
|
||||
|
||||
// 6
|
||||
|
||||
bind( type<void>(), &X::f6, &x, 1, 2, 3, 4, 5, 6 )();
|
||||
bind( type<void>(), &X::f6, ref(x), 1, 2, 3, 4, 5, 6 )();
|
||||
|
||||
bind( type<void>(), &X::g6, &x, 1, 2, 3, 4, 5, 6 )();
|
||||
bind( type<void>(), &X::g6, x, 1, 2, 3, 4, 5, 6 )();
|
||||
bind( type<void>(), &X::g6, ref(x), 1, 2, 3, 4, 5, 6 )();
|
||||
|
||||
// 7
|
||||
|
||||
bind( type<void>(), &X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind( type<void>(), &X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
bind( type<void>(), &X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind( type<void>(), &X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind( type<void>(), &X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
// 8
|
||||
|
||||
bind( type<void>(), &X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )();
|
||||
bind( type<void>(), &X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )();
|
||||
|
||||
bind( type<void>(), &X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )();
|
||||
bind( type<void>(), &X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 )();
|
||||
bind( type<void>(), &X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )();
|
||||
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
179
test/bind_nested_rv_test.cpp
Normal file
179
test/bind_nested_rv_test.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// bind_nested_rv_test.cpp
|
||||
//
|
||||
// Copyright (c) 2016 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
bool f1( boost::shared_ptr<int> p1 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f2( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f3( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f4( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
BOOST_TEST( p4 != 0 && *p4 == 4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f5( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
BOOST_TEST( p4 != 0 && *p4 == 4 );
|
||||
BOOST_TEST( p5 != 0 && *p5 == 5 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f6( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
BOOST_TEST( p4 != 0 && *p4 == 4 );
|
||||
BOOST_TEST( p5 != 0 && *p5 == 5 );
|
||||
BOOST_TEST( p6 != 0 && *p6 == 6 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f7( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6, boost::shared_ptr<int> p7 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
BOOST_TEST( p4 != 0 && *p4 == 4 );
|
||||
BOOST_TEST( p5 != 0 && *p5 == 5 );
|
||||
BOOST_TEST( p6 != 0 && *p6 == 6 );
|
||||
BOOST_TEST( p7 != 0 && *p7 == 7 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f8( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6, boost::shared_ptr<int> p7, boost::shared_ptr<int> p8 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
BOOST_TEST( p4 != 0 && *p4 == 4 );
|
||||
BOOST_TEST( p5 != 0 && *p5 == 5 );
|
||||
BOOST_TEST( p6 != 0 && *p6 == 6 );
|
||||
BOOST_TEST( p7 != 0 && *p7 == 7 );
|
||||
BOOST_TEST( p8 != 0 && *p8 == 8 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool f9( boost::shared_ptr<int> p1, boost::shared_ptr<int> p2, boost::shared_ptr<int> p3, boost::shared_ptr<int> p4, boost::shared_ptr<int> p5, boost::shared_ptr<int> p6, boost::shared_ptr<int> p7, boost::shared_ptr<int> p8, boost::shared_ptr<int> p9 )
|
||||
{
|
||||
BOOST_TEST( p1 != 0 && *p1 == 1 );
|
||||
BOOST_TEST( p2 != 0 && *p2 == 2 );
|
||||
BOOST_TEST( p3 != 0 && *p3 == 3 );
|
||||
BOOST_TEST( p4 != 0 && *p4 == 4 );
|
||||
BOOST_TEST( p5 != 0 && *p5 == 5 );
|
||||
BOOST_TEST( p6 != 0 && *p6 == 6 );
|
||||
BOOST_TEST( p7 != 0 && *p7 == 7 );
|
||||
BOOST_TEST( p8 != 0 && *p8 == 8 );
|
||||
BOOST_TEST( p9 != 0 && *p9 == 9 );
|
||||
return true;
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>)> f( f1 );
|
||||
|
||||
( boost::bind( f, _1 ) && boost::bind( f1, _1 ) )( boost::make_shared<int>( 1 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f2 );
|
||||
|
||||
( boost::bind( f, _1, _2 ) && boost::bind( f2, _1, _2 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f3 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3 ) && boost::bind( f3, _1, _2, _3 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f3 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3 ) && boost::bind( f3, _1, _2, _3 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f4 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3, _4 ) && boost::bind( f4, _1, _2, _3, _4 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f5 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3, _4, _5 ) && boost::bind( f5, _1, _2, _3, _4, _5 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f6 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3, _4, _5, _6 ) && boost::bind( f6, _1, _2, _3, _4, _5, _6 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f7 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3, _4, _5, _6, _7 ) && boost::bind( f7, _1, _2, _3, _4, _5, _6, _7 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ), boost::make_shared<int>( 7 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f8 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3, _4, _5, _6, _7, _8 ) && boost::bind( f8, _1, _2, _3, _4, _5, _6, _7, _8 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ), boost::make_shared<int>( 7 ), boost::make_shared<int>( 8 ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<bool(boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>, boost::shared_ptr<int>)> f( f9 );
|
||||
|
||||
( boost::bind( f, _1, _2, _3, _4, _5, _6, _7, _8, _9 ) && boost::bind( f9, _1, _2, _3, _4, _5, _6, _7, _8, _9 ) )( boost::make_shared<int>( 1 ), boost::make_shared<int>( 2 ), boost::make_shared<int>( 3 ), boost::make_shared<int>( 4 ), boost::make_shared<int>( 5 ), boost::make_shared<int>( 6 ), boost::make_shared<int>( 7 ), boost::make_shared<int>( 8 ), boost::make_shared<int>( 9 ) );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
99
test/bind_no_placeholders_test.cpp
Normal file
99
test/bind_no_placeholders_test.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// bind_no_placeholders_test.cpp - test for BOOST_BIND_NO_PLACEHOLDERS
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2001 David Abrahams
|
||||
// Copyright (c) 2015 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#define BOOST_BIND_NO_PLACEHOLDERS
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
long f_0()
|
||||
{
|
||||
return 17041L;
|
||||
}
|
||||
|
||||
long f_1(long a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
long f_2(long a, long b)
|
||||
{
|
||||
return a + 10 * b;
|
||||
}
|
||||
|
||||
long f_3(long a, long b, long c)
|
||||
{
|
||||
return a + 10 * b + 100 * c;
|
||||
}
|
||||
|
||||
long f_4(long a, long b, long c, long d)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d;
|
||||
}
|
||||
|
||||
long f_5(long a, long b, long c, long d, long e)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
||||
}
|
||||
|
||||
long f_6(long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
||||
}
|
||||
|
||||
long f_7(long a, long b, long c, long d, long e, long f, long g)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
||||
}
|
||||
|
||||
long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
||||
}
|
||||
|
||||
long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
void function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
arg<1> _1;
|
||||
arg<2> _2;
|
||||
arg<3> _3;
|
||||
arg<4> _4;
|
||||
arg<5> _5;
|
||||
arg<6> _6;
|
||||
arg<7> _7;
|
||||
arg<8> _8;
|
||||
arg<9> _9;
|
||||
|
||||
BOOST_TEST( bind(f_0)() == 17041L );
|
||||
BOOST_TEST( bind(f_1, _1)(1) == 1L );
|
||||
BOOST_TEST( bind(f_2, _1, _2)(1, 2) == 21L );
|
||||
BOOST_TEST( bind(f_3, _1, _2, _3)(1, 2, 3) == 321L );
|
||||
BOOST_TEST( bind(f_4, _1, _2, _3, _4)(1, 2, 3, 4) == 4321L );
|
||||
BOOST_TEST( bind(f_5, _1, _2, _3, _4, _5)(1, 2, 3, 4, 5) == 54321L );
|
||||
BOOST_TEST( bind(f_6, _1, _2, _3, _4, _5, _6)(1, 2, 3, 4, 5, 6) == 654321L );
|
||||
BOOST_TEST( bind(f_7, _1, _2, _3, _4, _5, _6, _7)(1, 2, 3, 4, 5, 6, 7) == 7654321L );
|
||||
BOOST_TEST( bind(f_8, _1, _2, _3, _4, _5, _6, _7, _8)(1, 2, 3, 4, 5, 6, 7, 8) == 87654321L );
|
||||
BOOST_TEST( bind(f_9, _1, _2, _3, _4, _5, _6, _7, _8, _9)(1, 2, 3, 4, 5, 6, 7, 8, 9) == 987654321L );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
154
test/bind_noexcept_mf2_test.cpp
Normal file
154
test/bind_noexcept_mf2_test.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// bind_noexcept_mf2_test.cpp - noexcept member functions w/ the type<> syntax
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int f0() noexcept { f1(17); return 0; }
|
||||
int g0() const noexcept { g1(17); return 0; }
|
||||
|
||||
int f1(int a1) noexcept { hash = (hash * 17041 + a1) % 32768; return 0; }
|
||||
int g1(int a1) const noexcept { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
|
||||
int f2(int a1, int a2) noexcept { f1(a1); f1(a2); return 0; }
|
||||
int g2(int a1, int a2) const noexcept { g1(a1); g1(a2); return 0; }
|
||||
|
||||
int f3(int a1, int a2, int a3) noexcept { f2(a1, a2); f1(a3); return 0; }
|
||||
int g3(int a1, int a2, int a3) const noexcept { g2(a1, a2); g1(a3); return 0; }
|
||||
|
||||
int f4(int a1, int a2, int a3, int a4) noexcept { f3(a1, a2, a3); f1(a4); return 0; }
|
||||
int g4(int a1, int a2, int a3, int a4) const noexcept { g3(a1, a2, a3); g1(a4); return 0; }
|
||||
|
||||
int f5(int a1, int a2, int a3, int a4, int a5) noexcept { f4(a1, a2, a3, a4); f1(a5); return 0; }
|
||||
int g5(int a1, int a2, int a3, int a4, int a5) const noexcept { g4(a1, a2, a3, a4); g1(a5); return 0; }
|
||||
|
||||
int f6(int a1, int a2, int a3, int a4, int a5, int a6) noexcept { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
|
||||
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const noexcept { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
|
||||
|
||||
int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) noexcept { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
|
||||
int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const noexcept { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
|
||||
|
||||
int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) noexcept { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
|
||||
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const noexcept { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
|
||||
};
|
||||
|
||||
void member_function_test()
|
||||
{
|
||||
X x;
|
||||
|
||||
// 0
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f0, &x)();
|
||||
boost::bind(boost::type<void>(), &X::f0, boost::ref(x))();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g0, &x)();
|
||||
boost::bind(boost::type<void>(), &X::g0, x)();
|
||||
boost::bind(boost::type<void>(), &X::g0, boost::ref(x))();
|
||||
|
||||
// 1
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f1, &x, 1)();
|
||||
boost::bind(boost::type<void>(), &X::f1, boost::ref(x), 1)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g1, &x, 1)();
|
||||
boost::bind(boost::type<void>(), &X::g1, x, 1)();
|
||||
boost::bind(boost::type<void>(), &X::g1, boost::ref(x), 1)();
|
||||
|
||||
// 2
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f2, &x, 1, 2)();
|
||||
boost::bind(boost::type<void>(), &X::f2, boost::ref(x), 1, 2)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g2, &x, 1, 2)();
|
||||
boost::bind(boost::type<void>(), &X::g2, x, 1, 2)();
|
||||
boost::bind(boost::type<void>(), &X::g2, boost::ref(x), 1, 2)();
|
||||
|
||||
// 3
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f3, &x, 1, 2, 3)();
|
||||
boost::bind(boost::type<void>(), &X::f3, boost::ref(x), 1, 2, 3)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g3, &x, 1, 2, 3)();
|
||||
boost::bind(boost::type<void>(), &X::g3, x, 1, 2, 3)();
|
||||
boost::bind(boost::type<void>(), &X::g3, boost::ref(x), 1, 2, 3)();
|
||||
|
||||
// 4
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f4, &x, 1, 2, 3, 4)();
|
||||
boost::bind(boost::type<void>(), &X::f4, boost::ref(x), 1, 2, 3, 4)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g4, &x, 1, 2, 3, 4)();
|
||||
boost::bind(boost::type<void>(), &X::g4, x, 1, 2, 3, 4)();
|
||||
boost::bind(boost::type<void>(), &X::g4, boost::ref(x), 1, 2, 3, 4)();
|
||||
|
||||
// 5
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f5, &x, 1, 2, 3, 4, 5)();
|
||||
boost::bind(boost::type<void>(), &X::f5, boost::ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g5, &x, 1, 2, 3, 4, 5)();
|
||||
boost::bind(boost::type<void>(), &X::g5, x, 1, 2, 3, 4, 5)();
|
||||
boost::bind(boost::type<void>(), &X::g5, boost::ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
// 6
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
boost::bind(boost::type<void>(), &X::f6, boost::ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
boost::bind(boost::type<void>(), &X::g6, x, 1, 2, 3, 4, 5, 6)();
|
||||
boost::bind(boost::type<void>(), &X::g6, boost::ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
// 7
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
boost::bind(boost::type<void>(), &X::f7, boost::ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
boost::bind(boost::type<void>(), &X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
boost::bind(boost::type<void>(), &X::g7, boost::ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
// 8
|
||||
|
||||
boost::bind(boost::type<void>(), &X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
boost::bind(boost::type<void>(), &X::f8, boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
boost::bind(boost::type<void>(), &X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
boost::bind(boost::type<void>(), &X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
boost::bind(boost::type<void>(), &X::g8, boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
154
test/bind_noexcept_mf_test.cpp
Normal file
154
test/bind_noexcept_mf_test.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// bind_noexcept_mf_test.cpp
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int f0() noexcept { f1(17); return 0; }
|
||||
int g0() const noexcept { g1(17); return 0; }
|
||||
|
||||
int f1(int a1) noexcept { hash = (hash * 17041 + a1) % 32768; return 0; }
|
||||
int g1(int a1) const noexcept { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
|
||||
int f2(int a1, int a2) noexcept { f1(a1); f1(a2); return 0; }
|
||||
int g2(int a1, int a2) const noexcept { g1(a1); g1(a2); return 0; }
|
||||
|
||||
int f3(int a1, int a2, int a3) noexcept { f2(a1, a2); f1(a3); return 0; }
|
||||
int g3(int a1, int a2, int a3) const noexcept { g2(a1, a2); g1(a3); return 0; }
|
||||
|
||||
int f4(int a1, int a2, int a3, int a4) noexcept { f3(a1, a2, a3); f1(a4); return 0; }
|
||||
int g4(int a1, int a2, int a3, int a4) const noexcept { g3(a1, a2, a3); g1(a4); return 0; }
|
||||
|
||||
int f5(int a1, int a2, int a3, int a4, int a5) noexcept { f4(a1, a2, a3, a4); f1(a5); return 0; }
|
||||
int g5(int a1, int a2, int a3, int a4, int a5) const noexcept { g4(a1, a2, a3, a4); g1(a5); return 0; }
|
||||
|
||||
int f6(int a1, int a2, int a3, int a4, int a5, int a6) noexcept { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
|
||||
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const noexcept { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
|
||||
|
||||
int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) noexcept { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
|
||||
int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const noexcept { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
|
||||
|
||||
int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) noexcept { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
|
||||
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const noexcept { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
|
||||
};
|
||||
|
||||
void member_function_test()
|
||||
{
|
||||
X x;
|
||||
|
||||
// 0
|
||||
|
||||
boost::bind(&X::f0, &x)();
|
||||
boost::bind(&X::f0, boost::ref(x))();
|
||||
|
||||
boost::bind(&X::g0, &x)();
|
||||
boost::bind(&X::g0, x)();
|
||||
boost::bind(&X::g0, boost::ref(x))();
|
||||
|
||||
// 1
|
||||
|
||||
boost::bind(&X::f1, &x, 1)();
|
||||
boost::bind(&X::f1, boost::ref(x), 1)();
|
||||
|
||||
boost::bind(&X::g1, &x, 1)();
|
||||
boost::bind(&X::g1, x, 1)();
|
||||
boost::bind(&X::g1, boost::ref(x), 1)();
|
||||
|
||||
// 2
|
||||
|
||||
boost::bind(&X::f2, &x, 1, 2)();
|
||||
boost::bind(&X::f2, boost::ref(x), 1, 2)();
|
||||
|
||||
boost::bind(&X::g2, &x, 1, 2)();
|
||||
boost::bind(&X::g2, x, 1, 2)();
|
||||
boost::bind(&X::g2, boost::ref(x), 1, 2)();
|
||||
|
||||
// 3
|
||||
|
||||
boost::bind(&X::f3, &x, 1, 2, 3)();
|
||||
boost::bind(&X::f3, boost::ref(x), 1, 2, 3)();
|
||||
|
||||
boost::bind(&X::g3, &x, 1, 2, 3)();
|
||||
boost::bind(&X::g3, x, 1, 2, 3)();
|
||||
boost::bind(&X::g3, boost::ref(x), 1, 2, 3)();
|
||||
|
||||
// 4
|
||||
|
||||
boost::bind(&X::f4, &x, 1, 2, 3, 4)();
|
||||
boost::bind(&X::f4, boost::ref(x), 1, 2, 3, 4)();
|
||||
|
||||
boost::bind(&X::g4, &x, 1, 2, 3, 4)();
|
||||
boost::bind(&X::g4, x, 1, 2, 3, 4)();
|
||||
boost::bind(&X::g4, boost::ref(x), 1, 2, 3, 4)();
|
||||
|
||||
// 5
|
||||
|
||||
boost::bind(&X::f5, &x, 1, 2, 3, 4, 5)();
|
||||
boost::bind(&X::f5, boost::ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
boost::bind(&X::g5, &x, 1, 2, 3, 4, 5)();
|
||||
boost::bind(&X::g5, x, 1, 2, 3, 4, 5)();
|
||||
boost::bind(&X::g5, boost::ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
// 6
|
||||
|
||||
boost::bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
boost::bind(&X::f6, boost::ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
boost::bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
boost::bind(&X::g6, x, 1, 2, 3, 4, 5, 6)();
|
||||
boost::bind(&X::g6, boost::ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
// 7
|
||||
|
||||
boost::bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
boost::bind(&X::f7, boost::ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
boost::bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
boost::bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
boost::bind(&X::g7, boost::ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
// 8
|
||||
|
||||
boost::bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
boost::bind(&X::f8, boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
boost::bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
boost::bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
boost::bind(&X::g8, boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
99
test/bind_noexcept_test.cpp
Normal file
99
test/bind_noexcept_test.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// bind_noexcept_test.cpp
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
|
||||
long f_0() noexcept
|
||||
{
|
||||
return 17041L;
|
||||
}
|
||||
|
||||
long f_1(long a) noexcept
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
long f_2(long a, long b) noexcept
|
||||
{
|
||||
return a + 10 * b;
|
||||
}
|
||||
|
||||
long f_3(long a, long b, long c) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c;
|
||||
}
|
||||
|
||||
long f_4(long a, long b, long c, long d) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d;
|
||||
}
|
||||
|
||||
long f_5(long a, long b, long c, long d, long e) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
||||
}
|
||||
|
||||
long f_6(long a, long b, long c, long d, long e, long f) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
||||
}
|
||||
|
||||
long f_7(long a, long b, long c, long d, long e, long f, long g) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
||||
}
|
||||
|
||||
long f_8(long a, long b, long c, long d, long e, long f, long g, long h) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
||||
}
|
||||
|
||||
long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) noexcept
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
void function_test()
|
||||
{
|
||||
int const i = 1;
|
||||
|
||||
BOOST_TEST( boost::bind(f_0)(i) == 17041L );
|
||||
BOOST_TEST( boost::bind(f_1, _1)(i) == 1L );
|
||||
BOOST_TEST( boost::bind(f_2, _1, 2)(i) == 21L );
|
||||
BOOST_TEST( boost::bind(f_3, _1, 2, 3)(i) == 321L );
|
||||
BOOST_TEST( boost::bind(f_4, _1, 2, 3, 4)(i) == 4321L );
|
||||
BOOST_TEST( boost::bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L );
|
||||
BOOST_TEST( boost::bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L );
|
||||
BOOST_TEST( boost::bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
|
||||
BOOST_TEST( boost::bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
|
||||
BOOST_TEST( boost::bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
50
test/bind_not_test.cpp
Normal file
50
test/bind_not_test.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_not_test.cpp - operator!
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
template<class F, class A1, class R> void test( F f, A1 a1, R r )
|
||||
{
|
||||
BOOST_TEST( f(a1) == r );
|
||||
}
|
||||
|
||||
bool f( bool v )
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
int g( int v )
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test( !boost::bind( f, true ), 0, !f( true ) );
|
||||
test( !boost::bind( g, _1 ), 5, !g( 5 ) );
|
||||
test( boost::bind( f, !boost::bind( f, true ) ), 0, f( !f( true ) ) );
|
||||
test( boost::bind( f, !boost::bind( f, _1 ) ), true, f( !f( true ) ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
93
test/bind_over_mf2_test.cpp
Normal file
93
test/bind_over_mf2_test.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// bind_over_mf2_test.cpp - overloaded member functions, type<> syntax
|
||||
//
|
||||
// Copyright 2017, 2024 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int f() { return 17041; }
|
||||
int f( int x1 ) { return x1; }
|
||||
int f( int x1, int x2 ) { return x1+x2; }
|
||||
int f( int x1, int x2, int x3 ) { return x1+x2+x3; }
|
||||
int f( int x1, int x2, int x3, int x4 ) { return x1+x2+x3+x4; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5 ) { return x1+x2+x3+x4+x5; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6 ) { return x1+x2+x3+x4+x5+x6; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) { return x1+x2+x3+x4+x5+x6+x7; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8 ) { return x1+x2+x3+x4+x5+x6+x7+x8; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9 ) { return x1+x2+x3+x4+x5+x6+x7+x8+x9; }
|
||||
|
||||
int g() const { return 17041; }
|
||||
int g( int x1 ) const { return x1; }
|
||||
int g( int x1, int x2 ) const { return x1+x2; }
|
||||
int g( int x1, int x2, int x3 ) const { return x1+x2+x3; }
|
||||
int g( int x1, int x2, int x3, int x4 ) const { return x1+x2+x3+x4; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5 ) const { return x1+x2+x3+x4+x5; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6 ) const { return x1+x2+x3+x4+x5+x6; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) const { return x1+x2+x3+x4+x5+x6+x7; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8 ) const { return x1+x2+x3+x4+x5+x6+x7+x8; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9 ) const { return x1+x2+x3+x4+x5+x6+x7+x8+x9; }
|
||||
};
|
||||
|
||||
void overloaded_member_function_test()
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
X const* pcx = &x;
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<int>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( boost::type<long>(), &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
overloaded_member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
112
test/bind_over_mf_test.cpp
Normal file
112
test/bind_over_mf_test.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// bind_over_mf_test.cpp - overloaded member functions
|
||||
//
|
||||
// Copyright 2017, 2024 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int f() { return 17041; }
|
||||
int f( int x1 ) { return x1; }
|
||||
int f( int x1, int x2 ) { return x1+x2; }
|
||||
int f( int x1, int x2, int x3 ) { return x1+x2+x3; }
|
||||
int f( int x1, int x2, int x3, int x4 ) { return x1+x2+x3+x4; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5 ) { return x1+x2+x3+x4+x5; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6 ) { return x1+x2+x3+x4+x5+x6; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) { return x1+x2+x3+x4+x5+x6+x7; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8 ) { return x1+x2+x3+x4+x5+x6+x7+x8; }
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9 ) { return x1+x2+x3+x4+x5+x6+x7+x8+x9; }
|
||||
|
||||
int g() const { return 17041; }
|
||||
int g( int x1 ) const { return x1; }
|
||||
int g( int x1, int x2 ) const { return x1+x2; }
|
||||
int g( int x1, int x2, int x3 ) const { return x1+x2+x3; }
|
||||
int g( int x1, int x2, int x3, int x4 ) const { return x1+x2+x3+x4; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5 ) const { return x1+x2+x3+x4+x5; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6 ) const { return x1+x2+x3+x4+x5+x6; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7 ) const { return x1+x2+x3+x4+x5+x6+x7; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8 ) const { return x1+x2+x3+x4+x5+x6+x7+x8; }
|
||||
int g( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9 ) const { return x1+x2+x3+x4+x5+x6+x7+x8+x9; }
|
||||
};
|
||||
|
||||
void overloaded_member_function_test()
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::f, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
X const* pcx = &x;
|
||||
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind<int>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind<long>( &X::g, pcx, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
overloaded_member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
86
test/bind_over_test.cpp
Normal file
86
test/bind_over_test.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// bind_over_test.cpp - overloaded functions
|
||||
//
|
||||
// Copyright 2017, 2024 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
int f()
|
||||
{
|
||||
return 17041;
|
||||
}
|
||||
|
||||
int f( int x1 )
|
||||
{
|
||||
return x1;
|
||||
}
|
||||
|
||||
int f( int x1, int x2 )
|
||||
{
|
||||
return x1+x2;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3 )
|
||||
{
|
||||
return x1+x2+x3;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3, int x4 )
|
||||
{
|
||||
return x1+x2+x3+x4;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3, int x4, int x5 )
|
||||
{
|
||||
return x1+x2+x3+x4+x5;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6 )
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7 )
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6+x7;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8 )
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6+x7+x8;
|
||||
}
|
||||
|
||||
int f( int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9 )
|
||||
{
|
||||
return x1+x2+x3+x4+x5+x6+x7+x8+x9;
|
||||
}
|
||||
|
||||
void overloaded_function_test()
|
||||
{
|
||||
BOOST_TEST_EQ( boost::bind( f )(), 17041 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2 )(), 1+2 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3 )(), 1+2+3 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4 )(), 1+2+3+4 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5 )(), 1+2+3+4+5 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6 )(), 1+2+3+4+5+6 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6, 7 )(), 1+2+3+4+5+6+7 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6, 7, 8 )(), 1+2+3+4+5+6+7+8 );
|
||||
BOOST_TEST_EQ( boost::bind( f, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(), 1+2+3+4+5+6+7+8+9 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
overloaded_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
72
test/bind_placeholder_test.cpp
Normal file
72
test/bind_placeholder_test.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined( BOOST_MSVC )
|
||||
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
|
||||
#endif
|
||||
|
||||
// bind_placeholder_test.cpp - test custom placeholders
|
||||
//
|
||||
// Copyright (c) 2006 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//
|
||||
|
||||
long f( long a, long b, long c, long d, long e, long f, long g, long h, long i )
|
||||
{
|
||||
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
||||
}
|
||||
|
||||
template< int I > struct custom_placeholder
|
||||
{
|
||||
};
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< int I > struct is_placeholder< custom_placeholder< I > >
|
||||
{
|
||||
enum { value = I };
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
int const x1 = 1;
|
||||
int const x2 = 2;
|
||||
int const x3 = 3;
|
||||
int const x4 = 4;
|
||||
int const x5 = 5;
|
||||
int const x6 = 6;
|
||||
int const x7 = 7;
|
||||
int const x8 = 8;
|
||||
int const x9 = 9;
|
||||
|
||||
custom_placeholder<1> p1;
|
||||
custom_placeholder<2> p2;
|
||||
custom_placeholder<3> p3;
|
||||
custom_placeholder<4> p4;
|
||||
custom_placeholder<5> p5;
|
||||
custom_placeholder<6> p6;
|
||||
custom_placeholder<7> p7;
|
||||
custom_placeholder<8> p8;
|
||||
custom_placeholder<9> p9;
|
||||
|
||||
BOOST_TEST(
|
||||
boost::bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
|
||||
( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
47
test/bind_ref_test.cpp
Normal file
47
test/bind_ref_test.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// bind_ref_test.cpp - reference_wrapper
|
||||
//
|
||||
// Copyright (c) 2009 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// -Warray-bounds false positive under GCC 14 UBSAN
|
||||
// ./boost/bind/mem_fn.hpp:74:59: error: array subscript 'int (**)(...)[0]' is partly outside array bounds of 'X [1]' [-Werror=array-bounds=]
|
||||
// 74 | return (get_pointer( std::forward<U>( u ) )->*pm_)( std::forward<A>( a )... );
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int f( int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int g( int x ) const
|
||||
{
|
||||
return -x;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 );
|
||||
BOOST_TEST( boost::bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
90
test/bind_rel_test.cpp
Normal file
90
test/bind_rel_test.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_rel_test.cpp - ==, !=, <, <=, >, >= operators
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::placeholders;
|
||||
|
||||
//
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x + x;
|
||||
}
|
||||
|
||||
int g( int x )
|
||||
{
|
||||
return 2 * x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 4;
|
||||
int y = x + x;
|
||||
|
||||
// bind op value
|
||||
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == y )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != y )( x ) ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < y )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) < y + 1 )( x ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > y )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) > y - 1 )( x ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) <= y - 1 )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= y )( x ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= y + 1 )( x ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) >= y + 1 )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= y )( x ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= y - 1 )( x ) );
|
||||
|
||||
// bind op ref
|
||||
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == boost::ref( y ) )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != boost::ref( y ) )( x ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < boost::ref( y ) )( x ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > boost::ref( y ) )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= boost::ref( y ) )( x ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= boost::ref( y ) )( x ) );
|
||||
|
||||
// bind op placeholder
|
||||
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == _2 )( x, y ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != _2 )( x, y ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < _2 )( x, y ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > _2 )( x, y ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= _2 )( x, y ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= _2 )( x, y ) );
|
||||
|
||||
// bind op bind
|
||||
|
||||
// important: bind( f, _1 ) and bind( g, _1 ) have the same type
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == boost::bind( g, _1 ) )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != boost::bind( g, _1 ) )( x ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < boost::bind( g, _1 ) )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= boost::bind( g, _1 ) )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > boost::bind( g, _1 ) )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= boost::bind( g, _1 ) )( x ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
55
test/bind_rv_sp_test.cpp
Normal file
55
test/bind_rv_sp_test.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// bind_rv_sp_test.cpp - smart pointer returned by value from an inner bind
|
||||
//
|
||||
// Copyright (c) 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
//
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
|
||||
X( int v ): v_( v )
|
||||
{
|
||||
}
|
||||
|
||||
int f()
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
boost::shared_ptr<X> f()
|
||||
{
|
||||
return boost::shared_ptr<X>( new X( 42 ) );
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::f, boost::bind( &Y::f, &y ) )() == 42 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user