mirror of
https://github.com/boostorg/utility.git
synced 2025-06-25 12:01:38 +02:00
Compare commits
593 Commits
svn-branch
...
boost-1.76
Author | SHA1 | Date | |
---|---|---|---|
7aafdf92a0 | |||
a7570d7608 | |||
37168a3f4b | |||
e56171989a | |||
f00a5bf0d3 | |||
a4feaf4f24 | |||
688628f764 | |||
8faf831bd1 | |||
25cb7aa122 | |||
0ae5cebc7f | |||
1caa002121 | |||
691f3238d7 | |||
8b6da499a3 | |||
6e6d0777e8 | |||
64fffa0f97 | |||
5da340a2a4 | |||
9a4cff038b | |||
0c059a50ad | |||
bdc5b5cf3a | |||
86e7caefea | |||
7953ba56ba | |||
46f72656b3 | |||
e3a2a06011 | |||
a4752e066d | |||
957aeba2e9 | |||
2b436d7d50 | |||
882c9c86c4 | |||
c81d8e3990 | |||
75276a055d | |||
309e6a1b31 | |||
9eeb7f85c5 | |||
62c34f51f6 | |||
6a1917ceec | |||
47c9f69ffe | |||
7b74d2d494 | |||
57da5f0c18 | |||
dabf53a703 | |||
ff56b3649e | |||
31e0ae4c37 | |||
5fe9df91c0 | |||
f03b681d01 | |||
e120a83d1e | |||
424fea5881 | |||
53d9aa9d2f | |||
6b62dcc504 | |||
91ebdcd1dd | |||
e8d2b2ba76 | |||
ce64b13846 | |||
32c50e0814 | |||
05dda09fd3 | |||
a4cafcc75d | |||
796fb965be | |||
08da98a551 | |||
57b027f1cd | |||
db05c11f50 | |||
3d2a7f0c17 | |||
8858bad352 | |||
fc135e0d72 | |||
ebe44296ca | |||
bdf55e0b6f | |||
d4170ccdb5 | |||
e2d115db97 | |||
15cfa44937 | |||
473be2e4c1 | |||
6ad6bc005c | |||
7709f0e430 | |||
eacea4664d | |||
1fe5af5264 | |||
d2fb06e6a0 | |||
73baeb7a63 | |||
56f13625b1 | |||
ac4e8da91d | |||
426836d860 | |||
82df2b82fc | |||
f8a243bcff | |||
51f7f7f53e | |||
5f535a151c | |||
c88936800d | |||
96fbce5759 | |||
9d46de1578 | |||
976a4d2fc1 | |||
ea81279b35 | |||
7d101d420c | |||
d8acfef27b | |||
d7ae336915 | |||
b74f49f1e5 | |||
5977f11be8 | |||
ad0fc7c9d3 | |||
a6c175e2c3 | |||
874ca2307b | |||
5220260145 | |||
2f5a6fbcf1 | |||
51ba9f1b45 | |||
5cef1403b0 | |||
81ce4693f6 | |||
fb2f110eb4 | |||
2ed5ee9588 | |||
88c36c1941 | |||
0b2409a942 | |||
62b39548be | |||
2722fdcda3 | |||
792d0538d2 | |||
06ae661775 | |||
d9d076874e | |||
e25d85446e | |||
5bc9e47688 | |||
ec50f22b8b | |||
592382dc61 | |||
6cf9c22cf1 | |||
33475f87e4 | |||
21261a8630 | |||
7d60e8e378 | |||
10ff4d4fcd | |||
89bf74beee | |||
bfdcce0f97 | |||
330b49d602 | |||
68b26cddbe | |||
6c4ab93573 | |||
0876da45db | |||
00f02167e3 | |||
9960d9f395 | |||
ccfd741c0a | |||
c5c479d49c | |||
3e8f73c6ac | |||
38121f2af3 | |||
38b536ff05 | |||
9ae6492af9 | |||
816607e212 | |||
a3ab942bc2 | |||
0f1f793caf | |||
ff445c0ece | |||
9fae8be166 | |||
b90a28f0e1 | |||
febca584d9 | |||
21dc552cf9 | |||
fda210f597 | |||
3d853b0e83 | |||
4814d1ebfe | |||
e5932ebb08 | |||
93a2e25092 | |||
39577f86d1 | |||
8392991c46 | |||
c5b1256650 | |||
c56dd13592 | |||
181f302ee4 | |||
287844fe76 | |||
3982b6d633 | |||
0b492bee9c | |||
a9236d00a9 | |||
4313bfc323 | |||
f61c94e812 | |||
1dfacff7ec | |||
a25ac4550b | |||
d767054a79 | |||
08a1b7da61 | |||
8ab8e36dcf | |||
1caa745dd7 | |||
cf5ad341ed | |||
1f6de83fe2 | |||
cb6500161b | |||
13610caa36 | |||
6bcf4f92bf | |||
fa8301a56a | |||
7306c8c359 | |||
492fd7f091 | |||
4fbd789253 | |||
4522603132 | |||
cae8d90d65 | |||
2ec0488e2a | |||
520dff9270 | |||
8e24c798ad | |||
651a869d4f | |||
7a8f16efdc | |||
2fa70612bb | |||
f1edd107eb | |||
c185d2dfa9 | |||
4531b2a2a6 | |||
51e482edfe | |||
61d07273fc | |||
42d56fbd51 | |||
6a1e97f870 | |||
c0fdaba925 | |||
87bc4c8dce | |||
34c11cb995 | |||
beab2e74ca | |||
10b8041472 | |||
1ed9aaa2a4 | |||
5a54e21ec5 | |||
8e06104836 | |||
45d884ffd7 | |||
329ca0bae8 | |||
afd9ab17ec | |||
036f6b9107 | |||
da239df58d | |||
46b3739b79 | |||
c5fc075d07 | |||
5ce9683858 | |||
991539725e | |||
df8e0c2dae | |||
f5869d0f82 | |||
db7bba3259 | |||
379e2111e2 | |||
d1bfa8e7b0 | |||
de0e18ca0a | |||
8ae3bfa961 | |||
d4b5fde5a8 | |||
9c4d2843da | |||
ad61f347e4 | |||
b434003b13 | |||
50eafe2027 | |||
87b8e03ca9 | |||
d595357b41 | |||
79d9d9f514 | |||
c48f86c9e4 | |||
514e5299ca | |||
3bac7b132a | |||
9382b69eb1 | |||
52a64d6aec | |||
a292dba021 | |||
e25bd18bd8 | |||
80895c071c | |||
f90812f1d9 | |||
244c343efe | |||
14e9e95c17 | |||
fd9f12b8f1 | |||
96da5105ab | |||
ad98ca9c3c | |||
dfad2950ea | |||
44a98b121b | |||
d5e86bb576 | |||
65d9a78735 | |||
12d17bc26d | |||
03047e3f00 | |||
468fb2dd5f | |||
e97577a0ae | |||
a90bc68a7f | |||
b39e4e5aea | |||
37c8f45edc | |||
4dc9659097 | |||
3d1646cf51 | |||
adf57817ec | |||
1fd5883b34 | |||
fc4bc227b5 | |||
bcd50e9105 | |||
0f5ae0e73c | |||
e33f8b0055 | |||
497198c624 | |||
9df000eece | |||
8e4054467e | |||
7ae5e14681 | |||
b051dd665b | |||
eca8d9f1ef | |||
b813232bba | |||
15021632dc | |||
9baf33dd16 | |||
e02523e286 | |||
6bb1ce9b7b | |||
9092b9277b | |||
d09b37d3ef | |||
f3bb2a493c | |||
71b501a0b0 | |||
547c562464 | |||
91aab126e1 | |||
0d605befd4 | |||
4080fe22e3 | |||
1057ff4d9e | |||
2eda3f5299 | |||
9cb31aee6e | |||
2e4007413e | |||
98bb9e6300 | |||
1cdb78c30a | |||
1ab9131bca | |||
d51799518b | |||
f9540f360c | |||
c1fdb477c1 | |||
e0e16be802 | |||
9284a64936 | |||
6e2c1b6b53 | |||
e4d622019f | |||
05af0deaed | |||
1b2cd6378b | |||
9383bbc283 | |||
00d151828c | |||
f0c62e9e00 | |||
1730c1319b | |||
71205b6e84 | |||
856b01240a | |||
98d793152c | |||
611395441e | |||
dc8ffe92b8 | |||
c55d5ca7de | |||
943af35553 | |||
b35ef27b35 | |||
3cca2755cf | |||
124f4ea879 | |||
93f6e3473b | |||
0f43c44e97 | |||
4a08e3d0bf | |||
3d650b7f92 | |||
0568a114a8 | |||
7148d6c95e | |||
1cfe3145b4 | |||
7d8353f46a | |||
57d65d6a94 | |||
ac9f617f7f | |||
1920623a4f | |||
b6a55f878c | |||
a4e332c4c0 | |||
e9bbb50eb4 | |||
e8440e8855 | |||
c0cca9e8cc | |||
d63444f22e | |||
1f23425baa | |||
a89b0101fc | |||
ff0cb36416 | |||
37c5395e7a | |||
fb2d391928 | |||
3558d61c51 | |||
ad5cf8cf08 | |||
a201cbe646 | |||
2fc827ad23 | |||
8036d4370f | |||
88e7d86270 | |||
5fe00c4322 | |||
6b9f0103d5 | |||
eb613e1b16 | |||
923caf4410 | |||
36bc0a72ac | |||
d5cacff7c6 | |||
b9411f807f | |||
4111de6f68 | |||
df9315101e | |||
2637dfcc59 | |||
a7e8d28621 | |||
acf8b66a4f | |||
7aa68731b4 | |||
c11e08b6b7 | |||
2cfe775694 | |||
799b066e7d | |||
9fa5d63525 | |||
2a6cd0c9c4 | |||
5825b6c329 | |||
54c78121c2 | |||
2891cb52d6 | |||
0db9276e8c | |||
d6cb9a9176 | |||
ef0f82f62b | |||
9a16aaa2b9 | |||
e763315b55 | |||
87b3643647 | |||
c9d56eed6e | |||
e36315c151 | |||
fe653d0a9a | |||
26b39384e3 | |||
9525d062b3 | |||
6d196c4244 | |||
e83682c091 | |||
1d146d010a | |||
5684a2f2b3 | |||
95d2c38379 | |||
1aa48ea698 | |||
7d23c75eef | |||
d01eb82fb7 | |||
86791caf0e | |||
3279399fe3 | |||
87875cadda | |||
c58748cfd9 | |||
58bb88d4bd | |||
11d50ecb9f | |||
636283d7c2 | |||
1df0bf80bc | |||
8176af84e1 | |||
71e78a0081 | |||
f7e4b0e399 | |||
b7d4b6edae | |||
fb1d2effef | |||
94b91e8c92 | |||
d7cf3628f7 | |||
a4b8043e68 | |||
b273cd3914 | |||
ca7db1f361 | |||
b4a08fc80e | |||
9da96d9737 | |||
a991936c96 | |||
6239e685a2 | |||
2a7e81e07f | |||
e601fcb9c9 | |||
f29a5db08e | |||
22743ee125 | |||
e3c982287a | |||
13da21e7b1 | |||
82e1111bb8 | |||
b3ffef536d | |||
9339b32178 | |||
3770221507 | |||
e2c98762db | |||
e6cb3a77ee | |||
bbccfbbab4 | |||
8af4250c3c | |||
e30889304c | |||
b4dee80e61 | |||
74a6a693d3 | |||
bf713ad47a | |||
76b17c497b | |||
a47dce770c | |||
dab1e8e522 | |||
3de5974419 | |||
7eb1536590 | |||
583422cda2 | |||
9339431e03 | |||
ee146a02a1 | |||
c131cbd0b2 | |||
f2349baf7d | |||
f8bef7ba95 | |||
e54cbf3053 | |||
8745ca628a | |||
ba61e9d796 | |||
d5291d08b8 | |||
afe74fffbc | |||
61755605af | |||
cd12e322bd | |||
09a0137016 | |||
a1d3ec6c53 | |||
5be3004e6c | |||
d387905150 | |||
b514e40733 | |||
8cb975feb7 | |||
ffe151458e | |||
4003a9f74a | |||
211eb04f33 | |||
e57213b298 | |||
b02677375f | |||
61a6015b5a | |||
51f9adbfa1 | |||
682032a340 | |||
eaaf17a88f | |||
48cfd42123 | |||
76aa5d2f27 | |||
67afd7e315 | |||
75cf20cace | |||
ce67dde4f0 | |||
a69e872a91 | |||
91385ac627 | |||
61e9b93f7c | |||
d97b303777 | |||
e3640e45c2 | |||
3900e8ece4 | |||
e27fc4a853 | |||
b7cd171b2b | |||
f7aa9a8935 | |||
0af1959b30 | |||
5f0cf4f5de | |||
0282c8a141 | |||
b2e6a82adb | |||
6725719bd9 | |||
390372294a | |||
ffbbf38e12 | |||
9e73b2c6ae | |||
97e11b024e | |||
118e473a3d | |||
d4b6193f94 | |||
633832e872 | |||
d420c98a53 | |||
862cb2a4e0 | |||
d153ab4daa | |||
561f83b991 | |||
b012f16ee5 | |||
3d96ab26d4 | |||
8652bf51ec | |||
57124703f9 | |||
53f6d10652 | |||
ebe853ff2f | |||
487a5c1ea5 | |||
9168cb9c61 | |||
e1991374ae | |||
c4338b1ce8 | |||
ddd8a58ae0 | |||
d0ee9a7c28 | |||
10e83b490b | |||
4b24dba257 | |||
28061ba3a8 | |||
5d53e3f837 | |||
e86ce1cb1f | |||
f15c96ffb0 | |||
a487f72329 | |||
9f08ed6de0 | |||
2077d0dace | |||
7f2348269b | |||
6b6e1c3252 | |||
55f303baec | |||
d264005c11 | |||
2cde009bb1 | |||
7bfb7c8a61 | |||
5c42397244 | |||
782c132d99 | |||
36899afa3f | |||
7e3e326faf | |||
7019e18149 | |||
49faf23433 | |||
62836f2928 | |||
1ecf3ceb74 | |||
2aa48414c9 | |||
d215f2176c | |||
c286d62223 | |||
3fd0ea6e75 | |||
b050431638 | |||
b311fcefb2 | |||
899c92420c | |||
64a0e0cb20 | |||
ece6992540 | |||
6098304ea8 | |||
28fff2d821 | |||
0ce3885d59 | |||
1823481d96 | |||
cce5d77d2b | |||
3c5c2bc107 | |||
7a036f6f3a | |||
e632b0fb1f | |||
17bee9d43f | |||
177ee78bbb | |||
f1ec0c4d04 | |||
4a564744fe | |||
492a8ad213 | |||
8827b8ed8b | |||
8849fbc52d | |||
67f3ca090a | |||
8efae71f4a | |||
50bc75a802 | |||
ad0bcf4a00 | |||
f1c86c35c4 | |||
a5b85eda07 | |||
bafe37fdab | |||
be50b95508 | |||
96d573d6ca | |||
9b52e49fda | |||
2412b864d6 | |||
94865eabe6 | |||
50268d1b29 | |||
ad9108c1dc | |||
ab479794f3 | |||
691e4b6c34 | |||
28596e678d | |||
1beca24dd8 | |||
721764937f | |||
a511007d0f | |||
8ce58b1675 | |||
97b8966337 | |||
9ed68b8321 | |||
79bbf71d0d | |||
ac93de7c1b | |||
88099a882f | |||
d731b8e1c5 | |||
ac1567b3fc | |||
c1fd670480 | |||
01274cf6ac | |||
8080673977 | |||
a470b591fb | |||
e1a63495b6 | |||
7300ac83f1 | |||
882d38c2c7 | |||
33041ad664 | |||
6a2aa822f8 | |||
d5554eb6d7 | |||
13bdfb8bbd | |||
74462349c2 | |||
09ab16bfc1 | |||
ec46e40809 | |||
b3a971e7e9 | |||
7ddb559887 | |||
ea8c99b1d5 | |||
56b0846099 | |||
42e0001370 | |||
cd8f85afee | |||
bddd52c4b9 | |||
6aa648d315 | |||
8f03aeac4e | |||
3bb2568fad | |||
01e91a3799 | |||
55f3c351a3 | |||
9ff18c2c96 | |||
d5ea07c737 | |||
aa0096bf42 | |||
005c2f3cc8 | |||
09f7aab52d | |||
30a40f9f76 | |||
d9f8bae673 | |||
3c7b409460 | |||
ee3551e8dc | |||
95da2e90de | |||
6dd93ab916 | |||
505d419a1b | |||
d968b5f5b9 | |||
d809d4e832 |
382
.travis.yml
Normal file
382
.travis.yml
Normal file
@ -0,0 +1,382 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2019 Andrey Semashev
|
||||
# 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
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
# gcc, Linux
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc-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
|
||||
dist: trusty
|
||||
compiler: gcc-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
|
||||
dist: xenial
|
||||
compiler: gcc-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
|
||||
dist: xenial
|
||||
compiler: gcc-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
|
||||
dist: xenial
|
||||
compiler: gcc-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-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: xenial
|
||||
compiler: gcc-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-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
|
||||
dist: bionic
|
||||
compiler: gcc-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: gcc-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-10
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
# clang, Linux
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.5 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.6 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.7 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-6-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.8 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-6-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-4
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
- libstdc++-6-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-5
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
- libstdc++-7-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-6
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libstdc++-8-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
- libstdc++-8-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
- libstdc++-8-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
- libstdc++-9-dev
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
- libstdc++-9-dev
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20 CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
- libc++-10-dev
|
||||
- libc++abi-10-dev
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
# clang, OS X
|
||||
# OS X builds are slow on Travis CI
|
||||
# - os: osx
|
||||
# env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
# osx_image: xcode9.4
|
||||
#
|
||||
# - os: osx
|
||||
# env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
# osx_image: xcode10.3
|
||||
|
||||
- os: osx
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17
|
||||
osx_image: xcode11.2
|
||||
|
||||
install:
|
||||
- GIT_FETCH_JOBS=8
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_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 init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/io
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/container_hash
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/detail
|
||||
- git submodule update --jobs $GIT_FETCH_JOBS
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/utility
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
|
||||
- ./b2 -j $BUILD_JOBS libs/utility/test toolset=$TOOLSET cxxstd=$CXXSTD ${CXXFLAGS:+cxxflags="$CXXFLAGS"} ${LINKFLAGS:+linkflags="$LINKFLAGS"}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
@ -85,7 +85,7 @@
|
||||
<hr>
|
||||
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||
"../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
|
||||
height="31" width="88"></a></p>
|
||||
|
||||
<p>Revised
|
||||
|
28
CMakeLists.txt
Normal file
28
CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Copyright 2018 Andrey Semashev
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
# Partial (add_subdirectory only) and experimental CMake support
|
||||
# Subject to change; please do not rely on the contents of this file yet.
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(BoostUtility LANGUAGES CXX)
|
||||
|
||||
add_library(boost_utility INTERFACE)
|
||||
add_library(Boost::utility ALIAS boost_utility)
|
||||
|
||||
target_include_directories(boost_utility INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_utility
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::io
|
||||
Boost::preprocessor
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
)
|
@ -509,7 +509,7 @@ Returns the largest size that this Collection can ever have. <A href="#8">[8]</A
|
||||
<hr>
|
||||
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||
"../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
|
||||
height="31" width="88"></a></p>
|
||||
|
||||
<p>Revised
|
||||
|
@ -160,7 +160,7 @@ t.~T()
|
||||
<hr>
|
||||
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||
"../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
|
||||
height="31" width="88"></a></p>
|
||||
|
||||
<p>Revised
|
||||
|
@ -185,7 +185,7 @@
|
||||
<hr>
|
||||
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||
"../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
|
||||
height="31" width="88"></a></p>
|
||||
|
||||
<p>Revised
|
||||
|
@ -70,7 +70,7 @@
|
||||
<hr>
|
||||
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||
"../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
|
||||
height="31" width="88"></a></p>
|
||||
|
||||
<p>Revised
|
||||
|
@ -57,10 +57,7 @@ aliasing.
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign=top>Validity Test</TD>
|
||||
<TD VAlign=top> <tt>t</tt><br>
|
||||
<tt>t != 0</tt><br>
|
||||
<tt>!!t</tt>
|
||||
</TD>
|
||||
<TD VAlign=top> <tt>bool(t)</tt></TD>
|
||||
<TD VAlign=top> bool </TD>
|
||||
<TD VAlign=top>If the pointee is valid returns true.<br>
|
||||
If the pointee is invalid returns false.</TD>
|
||||
@ -68,9 +65,7 @@ aliasing.
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign=top>Invalidity Test</TD>
|
||||
<TD VAlign=top> <tt>t == 0</tt><br>
|
||||
<tt>!t</tt>
|
||||
</TD>
|
||||
<TD VAlign=top> <tt>!t</tt></TD>
|
||||
<TD VAlign=top> bool </TD>
|
||||
<TD VAlign=top>If the pointee is valid returns false.<br>
|
||||
If the pointee is invalid returns true.</TD>
|
||||
@ -145,14 +140,20 @@ objects are is implemented in <a href="../../boost/utility/compare_pointees.hpp"
|
||||
so direct usage of relational operators with the implied aliasing of shallow semantics
|
||||
-as with pointers- should not be used with generic code written for this concept.</p>
|
||||
|
||||
<h3>Acknowledgements</h3>
|
||||
<p>Based on the original concept developed by Augustus Saunders.
|
||||
|
||||
<br>
|
||||
</p>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2003</TD><TD>
|
||||
<A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>,
|
||||
based on the original concept developed by Augustus Saunders.
|
||||
<A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>
|
||||
</TD></TR></TABLE>
|
||||
|
||||
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
24
README.md
Normal file
24
README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# 
|
||||
|
||||
Boost.Utility, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides a number of smaller components, too small to be called libraries in their own right. See the documentation for the list of components.
|
||||
|
||||
### Directories
|
||||
|
||||
* **doc** - Documentation sources
|
||||
* **include** - Interface headers of Boost.Utility
|
||||
* **test** - Boost.Utility unit tests
|
||||
|
||||
### More information
|
||||
|
||||
* [Documentation](https://boost.org/libs/utility)
|
||||
* [Report bugs](https://github.com/boostorg/utility/issues/new). Be sure to mention Boost version, Boost.Utility component, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
|
||||
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
### Build status
|
||||
|
||||
Master: [](https://travis-ci.org/boostorg/utility)
|
||||
Develop: [](https://travis-ci.org/boostorg/utility)
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
@ -1,94 +0,0 @@
|
||||
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
|
||||
// Douglas Gregor (gregod@cs.rpi.edu)
|
||||
//
|
||||
// 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)
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
|
||||
#include <boost/utility/addressof.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>
|
||||
|
||||
template<class T> void scalar_test( T * = 0 )
|
||||
{
|
||||
T* px = new T();
|
||||
|
||||
T& x = *px;
|
||||
BOOST_TEST( boost::addressof(x) == px );
|
||||
|
||||
const T& cx = *px;
|
||||
const T* pcx = boost::addressof(cx);
|
||||
BOOST_TEST( pcx == px );
|
||||
|
||||
volatile T& vx = *px;
|
||||
volatile T* pvx = boost::addressof(vx);
|
||||
BOOST_TEST( pvx == px );
|
||||
|
||||
const volatile T& cvx = *px;
|
||||
const volatile T* pcvx = boost::addressof(cvx);
|
||||
BOOST_TEST( pcvx == px );
|
||||
|
||||
delete px;
|
||||
}
|
||||
|
||||
template<class T> void array_test( T * = 0 )
|
||||
{
|
||||
T nrg[3] = {1,2,3};
|
||||
T (*pnrg)[3] = &nrg;
|
||||
BOOST_TEST( boost::addressof(nrg) == pnrg );
|
||||
|
||||
T const cnrg[3] = {1,2,3};
|
||||
T const (*pcnrg)[3] = &cnrg;
|
||||
BOOST_TEST( boost::addressof(cnrg) == pcnrg );
|
||||
}
|
||||
|
||||
struct addressable
|
||||
{
|
||||
addressable( int = 0 )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct useless_type {};
|
||||
|
||||
class nonaddressable {
|
||||
public:
|
||||
|
||||
nonaddressable( int = 0 )
|
||||
{
|
||||
}
|
||||
|
||||
void dummy(); // Silence GCC warning: all member of class are private
|
||||
|
||||
private:
|
||||
|
||||
useless_type operator&() const;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
scalar_test<char>();
|
||||
scalar_test<int>();
|
||||
scalar_test<addressable>();
|
||||
scalar_test<nonaddressable>();
|
||||
|
||||
array_test<char>();
|
||||
array_test<int>();
|
||||
array_test<addressable>();
|
||||
array_test<nonaddressable>();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
89
appveyor.yml
Normal file
89
appveyor.yml
Normal file
@ -0,0 +1,89 @@
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Copyright 2019 Andrey Semashev
|
||||
# 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:
|
||||
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
- TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: clang-win
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
ADDPATH: C:\mingw\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
|
||||
install:
|
||||
- set GIT_FETCH_JOBS=8
|
||||
- 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 init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/io
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/container_hash
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/detail
|
||||
- git submodule update --jobs %GIT_FETCH_JOBS%
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\utility\
|
||||
- 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 -j %NUMBER_OF_PROCESSORS% libs/utility/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
55
assert.html
55
assert.html
@ -1,55 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: assert.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"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
|
||||
</td>
|
||||
<td align="center">
|
||||
<h1>assert.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
The header <STRONG><boost/assert.hpp></STRONG> defines the macro <b>BOOST_ASSERT</b>,
|
||||
which is similar to the standard <STRONG>assert</STRONG> macro defined in <STRONG><cassert></STRONG>.
|
||||
The macro is intended to be used in Boost libraries.
|
||||
</p>
|
||||
<P>By default, <tt>BOOST_ASSERT(expr)</tt> is equivalent to <tt>assert(expr)</tt>.</P>
|
||||
<P>When the macro <STRONG>BOOST_DISABLE_ASSERTS</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||
is included, <tt>BOOST_ASSERT(expr)</tt> is defined as <tt>((void)0)</tt>. This
|
||||
allows users to selectively disable <STRONG>BOOST_ASSERT</STRONG> without
|
||||
affecting the definition of the standard <STRONG>assert</STRONG>.</P>
|
||||
<P>When the macro <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||
is included, <tt>BOOST_ASSERT(expr)</tt> evaluates <b>expr</b> and, if the
|
||||
result is false, evaluates the expression</P>
|
||||
<P><tt>::boost::assertion_failed(#expr, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>,
|
||||
__FILE__, __LINE__)</tt></P>
|
||||
<P><STRONG>assertion_failed</STRONG> is declared in <STRONG><boost/assert.hpp></STRONG>
|
||||
as</P>
|
||||
<pre>
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void assertion_failed(char const * expr, char const * function, char const * file, long line);
|
||||
|
||||
}
|
||||
</pre>
|
||||
<p>but it is never defined. The user is expected to supply an appropriate
|
||||
definition.</p>
|
||||
<P>As is the case with <STRONG><cassert></STRONG>, <STRONG><boost/assert.hpp></STRONG>
|
||||
can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT</STRONG>
|
||||
will be redefined each time as specified above.</P>
|
||||
<p><br>
|
||||
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||
</body>
|
||||
</html>
|
109
assert_test.cpp
109
assert_test.cpp
@ -1,109 +0,0 @@
|
||||
//
|
||||
// assert_test.cpp - a test for boost/assert.hpp
|
||||
//
|
||||
// Copyright (c) 2002 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)
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_default()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_ASSERT(1);
|
||||
BOOST_ASSERT(x);
|
||||
BOOST_ASSERT(x == 1);
|
||||
BOOST_ASSERT(&x);
|
||||
}
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_ASSERT(1);
|
||||
BOOST_ASSERT(x);
|
||||
BOOST_ASSERT(x == 1);
|
||||
BOOST_ASSERT(&x);
|
||||
|
||||
BOOST_ASSERT(0);
|
||||
BOOST_ASSERT(!x);
|
||||
BOOST_ASSERT(x == 0);
|
||||
|
||||
void * p = 0;
|
||||
|
||||
BOOST_ASSERT(p);
|
||||
|
||||
// supress warnings
|
||||
p = &x;
|
||||
p = &p;
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
int handler_invoked = 0;
|
||||
|
||||
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
|
||||
{
|
||||
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using std::printf;
|
||||
#endif
|
||||
|
||||
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
|
||||
++handler_invoked;
|
||||
}
|
||||
|
||||
struct X
|
||||
{
|
||||
static void f()
|
||||
{
|
||||
BOOST_ASSERT(0);
|
||||
}
|
||||
};
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_ASSERT(1);
|
||||
BOOST_ASSERT(x);
|
||||
BOOST_ASSERT(x == 1);
|
||||
BOOST_ASSERT(&x);
|
||||
|
||||
BOOST_ASSERT(0);
|
||||
BOOST_ASSERT(!x);
|
||||
BOOST_ASSERT(x == 0);
|
||||
|
||||
void * p = 0;
|
||||
|
||||
BOOST_ASSERT(p);
|
||||
|
||||
X::f();
|
||||
|
||||
BOOST_ASSERT(handler_invoked == 5);
|
||||
BOOST_TEST(handler_invoked == 5);
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_disabled();
|
||||
test_handler();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,371 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: Base-from-Member Idiom Documentation</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="white" link="blue" text="black" vlink="purple" alink="red">
|
||||
<h1><img src="../../boost.png" alt="C++ Boost" align="middle"
|
||||
width="277" height="86">Base-from-Member Idiom</h1>
|
||||
|
||||
<p>The class template <code>boost::base_from_member</code> provides
|
||||
a workaround for a class that needs to initialize a base class with a
|
||||
member. The class template is in <cite><a
|
||||
href="../../boost/utility/base_from_member.hpp">boost/utility/base_from_member.hpp</a></cite>
|
||||
which is included in <i><a href="../../boost/utility.hpp">boost/utility.hpp</a></i>.</p>
|
||||
|
||||
<p>There is test/example code in <cite><a
|
||||
href="base_from_member_test.cpp">base_from_member_test.cpp</a></cite>.</p>
|
||||
|
||||
<h2><a name="contents">Contents</a></h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="#contents">Contents</a></li>
|
||||
<li><a href="#rationale">Rationale</a></li>
|
||||
<li><a href="#synopsis">Synopsis</a></li>
|
||||
<li><a href="#usage">Usage</a></li>
|
||||
<li><a href="#example">Example</a></li>
|
||||
<li><a href="#credits">Credits</a>
|
||||
<ul>
|
||||
<li><a href="#contributors">Contributors</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="rationale">Rationale</a></h2>
|
||||
|
||||
<p>When developing a class, sometimes a base class needs to be
|
||||
initialized with a member of the current class. As a naïve
|
||||
example:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
#include <streambuf> <i>// for std::streambuf</i>
|
||||
#include <ostream> <i>// for std::ostream</i>
|
||||
|
||||
class fdoutbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit fdoutbuf( int fd );
|
||||
//...
|
||||
};
|
||||
|
||||
class fdostream
|
||||
: public std::ostream
|
||||
{
|
||||
protected:
|
||||
fdoutbuf buf;
|
||||
public:
|
||||
explicit fdostream( int fd )
|
||||
: buf( fd ), std::ostream( &buf )
|
||||
{}
|
||||
//...
|
||||
};
|
||||
</pre></blockquote>
|
||||
|
||||
<p>This is undefined because C++'s initialization order mandates that
|
||||
the base class is initialized before the member it uses. <a
|
||||
href="http://www.moocat.org">R. Samuel Klatchko</a> developed a way
|
||||
around this by using the initialization order in his favor. Base
|
||||
classes are intialized in order of declaration, so moving the desired
|
||||
member to another base class, that is initialized before the desired
|
||||
base class, can ensure proper initialization.</p>
|
||||
|
||||
<p>A custom base class can be made for this idiom:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
#include <streambuf> <i>// for std::streambuf</i>
|
||||
#include <ostream> <i>// for std::ostream</i>
|
||||
|
||||
class fdoutbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit fdoutbuf( int fd );
|
||||
//...
|
||||
};
|
||||
|
||||
struct fdostream_pbase
|
||||
{
|
||||
fdoutbuf sbuffer;
|
||||
|
||||
explicit fdostream_pbase( int fd )
|
||||
: sbuffer( fd )
|
||||
{}
|
||||
};
|
||||
|
||||
class fdostream
|
||||
: private fdostream_pbase
|
||||
, public std::ostream
|
||||
{
|
||||
typedef fdostream_pbase pbase_type;
|
||||
typedef std::ostream base_type;
|
||||
|
||||
public:
|
||||
explicit fdostream( int fd )
|
||||
: pbase_type( fd ), base_type( &sbuffer )
|
||||
{}
|
||||
//...
|
||||
};
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Other projects can use similar custom base classes. The technique
|
||||
is basic enough to make a template, with a sample template class in
|
||||
this library. The main template parameter is the type of the enclosed
|
||||
member. The template class has several (explicit) constructor member
|
||||
templates, which implicitly type the constructor arguments and pass them
|
||||
to the member. The template class uses implicit copy construction and
|
||||
assignment, cancelling them if the enclosed member is non-copyable.</p>
|
||||
|
||||
<p>Manually coding a base class may be better if the construction
|
||||
and/or copying needs are too complex for the supplied template class,
|
||||
or if the compiler is not advanced enough to use it.</p>
|
||||
|
||||
<p>Since base classes are unnamed, a class cannot have multiple (direct)
|
||||
base classes of the same type. The supplied template class has an
|
||||
extra template parameter, an integer, that exists solely to provide type
|
||||
differentiation. This parameter has a default value so a single use of a
|
||||
particular member type does not need to concern itself with the integer.</p>
|
||||
|
||||
<h2><a name="synopsis">Synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
#ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY
|
||||
#define BOOST_BASE_FROM_MEMBER_MAX_ARITY 10
|
||||
#endif
|
||||
|
||||
template < typename MemberType, int UniqueID = 0 >
|
||||
class boost::base_from_member
|
||||
{
|
||||
protected:
|
||||
MemberType member;
|
||||
|
||||
base_from_member();
|
||||
|
||||
template< typename T1 >
|
||||
explicit base_from_member( T1 x1 );
|
||||
|
||||
template< typename T1, typename T2 >
|
||||
base_from_member( T1 x1, T2 x2 );
|
||||
|
||||
//...
|
||||
|
||||
template< typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8, typename T9,
|
||||
typename T10 >
|
||||
base_from_member( T1 x1, T2 x2, T3 x3, T4 x4, T5 x5, T6 x6, T7 x7,
|
||||
T8 x8, T9 x9, T10 x10 );
|
||||
};
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The class template has a first template parameter
|
||||
<var>MemberType</var> representing the type of the based-member.
|
||||
It has a last template parameter <var>UniqueID</var>, that is an
|
||||
<code>int</code>, to differentiate between multiple base classes that use
|
||||
the same based-member type. The last template parameter has a default
|
||||
value of zero if it is omitted. The class template has a protected
|
||||
data member called <var>member</var> that the derived class can use
|
||||
for later base classes (or itself).</p>
|
||||
|
||||
<p>There is a default constructor and several constructor member
|
||||
templates. These constructor templates can take as many arguments
|
||||
(currently up to ten) as possible and pass them to a constructor of
|
||||
the data member. Since C++ does not allow any way to explicitly state
|
||||
the template parameters of a templated constructor, make sure that
|
||||
the arguments are already close as possible to the actual type used in
|
||||
the data member's desired constructor.</p>
|
||||
|
||||
<p>The <var>BOOST_BASE_FROM_MEMBER_MAX_ARITY</var> macro constant specifies
|
||||
the maximum argument length for the constructor templates. The constant
|
||||
may be overridden if more (or less) argument configurations are needed. The
|
||||
constant may be read for code that is expandable like the class template and
|
||||
needs to maintain the same maximum size. (Example code would be a class that
|
||||
uses this class template as a base class for a member with a flexible set of
|
||||
constructors.)</p>
|
||||
|
||||
<h2><a name="usage">Usage</a></h2>
|
||||
|
||||
<p>With the starting example, the <code>fdoutbuf</code> sub-object needs
|
||||
to be encapsulated in a base class that is inheirited before
|
||||
<code>std::ostream</code>.</p>
|
||||
|
||||
<blockquote><pre>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
|
||||
#include <streambuf> <i>// for std::streambuf</i>
|
||||
#include <ostream> <i>// for std::ostream</i>
|
||||
|
||||
class fdoutbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit fdoutbuf( int fd );
|
||||
//...
|
||||
};
|
||||
|
||||
class fdostream
|
||||
: private boost::base_from_member<fdoutbuf>
|
||||
, public std::ostream
|
||||
{
|
||||
// Helper typedef's
|
||||
typedef boost::base_from_member<fdoutbuf> pbase_type;
|
||||
typedef std::ostream base_type;
|
||||
|
||||
public:
|
||||
explicit fdostream( int fd )
|
||||
: pbase_type( fd ), base_type( &member )
|
||||
{}
|
||||
//...
|
||||
};
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The base-from-member idiom is an implementation detail, so it
|
||||
should not be visible to the clients (or any derived classes) of
|
||||
<code>fdostream</code>. Due to the initialization order, the
|
||||
<code>fdoutbuf</code> sub-object will get initialized before the
|
||||
<code>std::ostream</code> sub-object does, making the former
|
||||
sub-object safe to use in the latter sub-object's construction. Since the
|
||||
<code>fdoutbuf</code> sub-object of the final type is the only sub-object
|
||||
with the name "member," that name can be used
|
||||
unqualified within the final class.</p>
|
||||
|
||||
<h2><a name="example">Example</a></h2>
|
||||
|
||||
<p>The base-from-member class templates should commonly involve
|
||||
only one base-from-member sub-object, usually for attaching a
|
||||
stream-buffer to an I/O stream. The next example demonstrates how
|
||||
to use multiple base-from-member sub-objects and the resulting
|
||||
qualification issues.</p>
|
||||
|
||||
<blockquote><pre>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
|
||||
#include <cstddef> <i>// for NULL</i>
|
||||
|
||||
struct an_int
|
||||
{
|
||||
int y;
|
||||
|
||||
an_int( float yf );
|
||||
};
|
||||
|
||||
class switcher
|
||||
{
|
||||
public:
|
||||
switcher();
|
||||
switcher( double, int * );
|
||||
//...
|
||||
};
|
||||
|
||||
class flow_regulator
|
||||
{
|
||||
public:
|
||||
flow_regulator( switcher &, switcher & );
|
||||
//...
|
||||
};
|
||||
|
||||
template < unsigned Size >
|
||||
class fan
|
||||
{
|
||||
public:
|
||||
explicit fan( switcher );
|
||||
//...
|
||||
};
|
||||
|
||||
class system
|
||||
: private boost::base_from_member<an_int>
|
||||
, private boost::base_from_member<switcher>
|
||||
, private boost::base_from_member<switcher, 1>
|
||||
, private boost::base_from_member<switcher, 2>
|
||||
, protected flow_regulator
|
||||
, public fan<6>
|
||||
{
|
||||
// Helper typedef's
|
||||
typedef boost::base_from_member<an_int> pbase0_type;
|
||||
typedef boost::base_from_member<switcher> pbase1_type;
|
||||
typedef boost::base_from_member<switcher, 1> pbase2_type;
|
||||
typedef boost::base_from_member<switcher, 2> pbase3_type;
|
||||
|
||||
typedef flow_regulator base1_type;
|
||||
typedef fan<6> base2_type;
|
||||
|
||||
public:
|
||||
system( double x );
|
||||
//...
|
||||
};
|
||||
|
||||
system::system( double x )
|
||||
: pbase0_type( 0.2 )
|
||||
, pbase1_type()
|
||||
, pbase2_type( -16, &this->pbase0_type::member )
|
||||
, pbase3_type( x, static_cast<int *>(NULL) )
|
||||
, base1_type( pbase3_type::member, pbase1_type::member )
|
||||
, base2_type( pbase2_type::member )
|
||||
{
|
||||
//...
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The final class has multiple sub-objects with the name
|
||||
"member," so any use of that name needs qualification by
|
||||
a name of the appropriate base type. (Using <code>typedef</code>s
|
||||
ease mentioning the base types.) However, the fix introduces a new
|
||||
problem when a pointer is needed. Using the address operator with
|
||||
a sub-object qualified with its class's name results in a pointer-to-member
|
||||
(here, having a type of <code>an_int boost::base_from_member<an_int,
|
||||
0> :: *</code>) instead of a pointer to the member (having a type of
|
||||
<code>an_int *</code>). The new problem is fixed by qualifying the
|
||||
sub-object with "<code>this-></code>," and is needed just
|
||||
for pointers, and not for references or values.</p>
|
||||
|
||||
<p>There are some argument conversions in the initialization. The
|
||||
constructor argument for <code>pbase0_type</code> is converted from
|
||||
<code>double</code> to <code>float</code>. The first constructor
|
||||
argument for <code>pbase2_type</code> is converted from <code>int</code>
|
||||
to <code>double</code>. The second constructor argument for
|
||||
<code>pbase3_type</code> is a special case of necessary conversion; all
|
||||
forms of the null-pointer literal in C++ also look like compile-time
|
||||
integral expressions, so C++ always interprets such code as an integer
|
||||
when it has overloads that can take either an integer or a pointer. The
|
||||
last conversion is necessary for the compiler to call a constructor form
|
||||
with the exact pointer type used in <code>switcher</code>'s constructor.</p>
|
||||
|
||||
<h2><a name="credits">Credits</a></h2>
|
||||
|
||||
<h3><a name="contributors">Contributors</a></h3>
|
||||
|
||||
<dl>
|
||||
<dt><a href="../../people/ed_brey.htm">Ed Brey</a>
|
||||
<dd>Suggested some interface changes.
|
||||
|
||||
<dt><a href="http://www.moocat.org">R. Samuel Klatchko</a> (<a
|
||||
href="mailto:rsk@moocat.org">rsk@moocat.org</a>, <a
|
||||
href="mailto:rsk@brightmail.com">rsk@brightmail.com</a>)
|
||||
<dd>Invented the idiom of how to use a class member for initializing
|
||||
a base class.
|
||||
|
||||
<dt><a href="../../people/dietmar_kuehl.htm">Dietmar Kuehl</a>
|
||||
<dd>Popularized the base-from-member idiom in his
|
||||
<a href="http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/">IOStream
|
||||
example classes</a>.
|
||||
|
||||
<dt>Jonathan Turkanis
|
||||
<dd>Supplied an implementation of generating the constructor templates that
|
||||
can be controlled and automated with macros. The implementation uses
|
||||
the <a href="../preprocessor/index.html">Preprocessor library</a>.
|
||||
|
||||
<dt><a href="../../people/daryle_walker.html">Daryle Walker</a>
|
||||
<dd>Started the library. Contributed the test file <cite><a
|
||||
href="base_from_member_test.cpp">base_from_member_test.cpp</a></cite>.
|
||||
</dl>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Revised: 28 August 2004</p>
|
||||
|
||||
<p>Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and distribution
|
||||
are subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
||||
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,258 +0,0 @@
|
||||
// (C) Copyright David Abrahams 2000.
|
||||
// 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 <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <stdlib.h> // for rand(). Would use cstdlib but VC6.4 doesn't put it in std::
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <boost/detail/binary_search.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2)
|
||||
# define USE_SSTREAM
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSTREAM
|
||||
# include <sstream>
|
||||
#else
|
||||
# include <strstream>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// In order to get ADL to find the comparison operators defined below, they have
|
||||
struct mystring : std::string
|
||||
{
|
||||
typedef std::string base;
|
||||
|
||||
mystring(std::string const& x)
|
||||
: base(x) {}
|
||||
};
|
||||
|
||||
typedef std::vector<mystring> string_vector;
|
||||
|
||||
const std::size_t sequence_length = 1000;
|
||||
|
||||
unsigned random_number()
|
||||
{
|
||||
return static_cast<unsigned>(::rand()) % sequence_length;
|
||||
}
|
||||
|
||||
# ifndef USE_SSTREAM
|
||||
class unfreezer {
|
||||
public:
|
||||
unfreezer(std::ostrstream& s) : m_stream(s) {}
|
||||
~unfreezer() { m_stream.freeze(false); }
|
||||
private:
|
||||
std::ostrstream& m_stream;
|
||||
};
|
||||
# endif
|
||||
|
||||
template <class T>
|
||||
void push_back_random_number_string(T& seq)
|
||||
{
|
||||
unsigned value = random_number();
|
||||
# if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2)
|
||||
std::ostringstream s;
|
||||
s << value;
|
||||
seq.push_back(s.str());
|
||||
# else
|
||||
std::ostrstream s;
|
||||
auto unfreezer unfreeze(s);
|
||||
s << value << char(0);
|
||||
seq.push_back(std::string(s.str()));
|
||||
# endif
|
||||
}
|
||||
|
||||
inline unsigned to_int(unsigned x) { return x; }
|
||||
inline unsigned to_int(const std::string& x) { return atoi(x.c_str()); }
|
||||
|
||||
struct cmp
|
||||
{
|
||||
template <class A1, class A2>
|
||||
inline bool operator()(const A1& a1, const A2& a2) const
|
||||
{
|
||||
return to_int(a1) < to_int(a2);
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator<(const mystring& x, const unsigned y)
|
||||
{
|
||||
return to_int(x) < y;
|
||||
}
|
||||
|
||||
inline bool operator<(const unsigned y, const mystring& x)
|
||||
{
|
||||
return y < to_int(x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void sort_by_value(T& x);
|
||||
|
||||
template <class T>
|
||||
void sort_by_value_(T& v, long)
|
||||
{
|
||||
std::sort(v.begin(), v.end(), cmp());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void random_sorted_sequence(T& seq)
|
||||
{
|
||||
seq.clear();
|
||||
for (std::size_t i = 0; i < sequence_length; ++i)
|
||||
{
|
||||
push_back_random_number_string(seq);
|
||||
}
|
||||
sort_by_value(seq);
|
||||
}
|
||||
|
||||
template <class T, class A>
|
||||
void sort_by_value_(std::list<T,A>& l, int)
|
||||
{
|
||||
# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) && !defined(__SGI_STL_PORT)
|
||||
// VC6's standard lib doesn't have a template member function for list::sort()
|
||||
std::vector<T> seq;
|
||||
seq.reserve(sequence_length);
|
||||
std::copy(l.begin(), l.end(), std::back_inserter(seq));
|
||||
sort_by_value(seq);
|
||||
std::copy(seq.begin(), seq.end(), l.begin());
|
||||
# else
|
||||
l.sort(cmp());
|
||||
# endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void sort_by_value(T& x)
|
||||
{
|
||||
(sort_by_value_)(x, 1);
|
||||
}
|
||||
|
||||
// A way to select the comparisons with/without a Compare parameter for testing.
|
||||
template <class Compare> struct searches
|
||||
{
|
||||
template <class Iterator, class Key>
|
||||
static Iterator lower_bound(Iterator start, Iterator finish, Key key, Compare cmp)
|
||||
{ return boost::detail::lower_bound(start, finish, key, cmp); }
|
||||
|
||||
template <class Iterator, class Key>
|
||||
static Iterator upper_bound(Iterator start, Iterator finish, Key key, Compare cmp)
|
||||
{ return boost::detail::upper_bound(start, finish, key, cmp); }
|
||||
|
||||
template <class Iterator, class Key>
|
||||
static std::pair<Iterator, Iterator> equal_range(Iterator start, Iterator finish, Key key, Compare cmp)
|
||||
{ return boost::detail::equal_range(start, finish, key, cmp); }
|
||||
|
||||
template <class Iterator, class Key>
|
||||
static bool binary_search(Iterator start, Iterator finish, Key key, Compare cmp)
|
||||
{ return boost::detail::binary_search(start, finish, key, cmp); }
|
||||
};
|
||||
|
||||
struct no_compare {};
|
||||
|
||||
template <> struct searches<no_compare>
|
||||
{
|
||||
template <class Iterator, class Key>
|
||||
static Iterator lower_bound(Iterator start, Iterator finish, Key key, no_compare)
|
||||
{ return boost::detail::lower_bound(start, finish, key); }
|
||||
|
||||
template <class Iterator, class Key>
|
||||
static Iterator upper_bound(Iterator start, Iterator finish, Key key, no_compare)
|
||||
{ return boost::detail::upper_bound(start, finish, key); }
|
||||
|
||||
template <class Iterator, class Key>
|
||||
static std::pair<Iterator, Iterator> equal_range(Iterator start, Iterator finish, Key key, no_compare)
|
||||
{ return boost::detail::equal_range(start, finish, key); }
|
||||
|
||||
template <class Iterator, class Key>
|
||||
static bool binary_search(Iterator start, Iterator finish, Key key, no_compare)
|
||||
{ return boost::detail::binary_search(start, finish, key); }
|
||||
};
|
||||
|
||||
template <class Sequence, class Compare>
|
||||
void test_loop(Sequence& x, Compare cmp, unsigned long test_count)
|
||||
{
|
||||
typedef typename Sequence::const_iterator const_iterator;
|
||||
|
||||
for (unsigned long i = 0; i < test_count; ++i)
|
||||
{
|
||||
random_sorted_sequence(x);
|
||||
const const_iterator start = x.begin();
|
||||
const const_iterator finish = x.end();
|
||||
|
||||
unsigned key = random_number();
|
||||
const const_iterator l = searches<Compare>::lower_bound(start, finish, key, cmp);
|
||||
const const_iterator u = searches<Compare>::upper_bound(start, finish, key, cmp);
|
||||
|
||||
bool found_l = false;
|
||||
bool found_u = false;
|
||||
std::size_t index = 0;
|
||||
std::size_t count = 0;
|
||||
unsigned last_value = 0;
|
||||
for (const_iterator p = start; p != finish; ++p)
|
||||
{
|
||||
if (p == l)
|
||||
found_l = true;
|
||||
|
||||
if (p == u)
|
||||
{
|
||||
assert(found_l);
|
||||
found_u = true;
|
||||
}
|
||||
|
||||
unsigned value = to_int(*p);
|
||||
assert(value >= last_value);
|
||||
last_value = value;
|
||||
|
||||
if (!found_l)
|
||||
{
|
||||
++index;
|
||||
assert(to_int(*p) < key);
|
||||
}
|
||||
else if (!found_u)
|
||||
{
|
||||
++count;
|
||||
assert(to_int(*p) == key);
|
||||
}
|
||||
else
|
||||
assert(to_int(*p) > key);
|
||||
}
|
||||
assert(found_l || l == finish);
|
||||
assert(found_u || u == finish);
|
||||
|
||||
std::pair<const_iterator, const_iterator>
|
||||
range = searches<Compare>::equal_range(start, finish, key, cmp);
|
||||
assert(range.first == l);
|
||||
assert(range.second == u);
|
||||
|
||||
bool found = searches<Compare>::binary_search(start, finish, key, cmp);
|
||||
assert(found == (u != l));
|
||||
std::cout << "found " << count << " copies of " << key << " at index " << index << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
string_vector x;
|
||||
std::cout << "=== testing random-access iterators with <: ===\n";
|
||||
test_loop(x, no_compare(), 25);
|
||||
std::cout << "=== testing random-access iterators with compare: ===\n";
|
||||
test_loop(x, cmp(), 25);
|
||||
|
||||
std::list<mystring> y;
|
||||
std::cout << "=== testing bidirectional iterators with <: ===\n";
|
||||
test_loop(y, no_compare(), 25);
|
||||
std::cout << "=== testing bidirectional iterators with compare: ===\n";
|
||||
test_loop(y, cmp(), 25);
|
||||
std::cerr << "******TEST PASSED******\n";
|
||||
return 0;
|
||||
}
|
@ -493,7 +493,7 @@ call_traits can not be used with reference or array types.</p>
|
||||
<h4>Example 1:</h4>
|
||||
|
||||
<p>The following class is a trivial class that stores some type T
|
||||
by value (see the <a href="call_traits_test.cpp">call_traits_test.cpp</a>
|
||||
by value (see the <a href="test/call_traits_test.cpp">call_traits_test.cpp</a>
|
||||
file), the aim is to illustrate how each of the available
|
||||
call_traits typedefs may be used:</p>
|
||||
|
||||
@ -740,26 +740,16 @@ specialisation).</p>
|
||||
|
||||
<p>Revised 01 September 2000</p>
|
||||
|
||||
<p><EFBFBD> Copyright boost.org 2000. 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.</p>
|
||||
|
||||
<p>Based on contributions by Steve Cleary, Beman Dawes, Howard
|
||||
Hinnant and John Maddock.</p>
|
||||
|
||||
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John
|
||||
Maddock</a>, the latest version of this file can be found at <a
|
||||
href="http://www.boost.org/">www.boost.org</a>, and the boost
|
||||
discussion list at <a
|
||||
href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p>
|
||||
|
||||
<p>.</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
<p>
|
||||
Copyright 2000 Steve Cleary, Beman Dawes, Howard
|
||||
Hinnant and John Maddock. <br/>
|
||||
Use, modification and distribution are subject to the
|
||||
Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt
|
||||
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
</a>).
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -1,122 +1,15 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: checked_delete.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"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
|
||||
</td>
|
||||
<td align="center">
|
||||
<h1>checked_delete.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
The header <STRONG><boost/checked_delete.hpp></STRONG> defines two
|
||||
function templates, <STRONG>checked_delete</STRONG> and <STRONG>checked_array_delete</STRONG>,
|
||||
and two class templates, <STRONG>checked_deleter</STRONG> and <STRONG>checked_array_deleter</STRONG>.
|
||||
</p>
|
||||
<P>The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to be
|
||||
deleted with a <EM>delete-expression</EM>. When the class has a non-trivial
|
||||
destructor, or a class-specific operator delete, the behavior is undefined.
|
||||
Some compilers issue a warning when an incomplete type is deleted, but
|
||||
unfortunately, not all do, and programmers sometimes ignore or disable
|
||||
warnings.</P>
|
||||
<P>A particularly troublesome case is when a smart pointer's destructor, such as <STRONG>
|
||||
boost::scoped_ptr<T>::~scoped_ptr</STRONG>, is instantiated with an
|
||||
incomplete type. This can often lead to silent, hard to track failures.</P>
|
||||
<P>The supplied function and class templates can be used to prevent these problems,
|
||||
as they require a complete type, and cause a compilation error otherwise.</P>
|
||||
<h3><a name="Synopsis">Synopsis</a></h3>
|
||||
<pre>
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> void checked_delete(T * p);
|
||||
template<class T> void checked_array_delete(T * p);
|
||||
template<class T> struct checked_deleter;
|
||||
template<class T> struct checked_array_deleter;
|
||||
|
||||
}
|
||||
</pre>
|
||||
<h3>checked_delete</h3>
|
||||
<h4><a name="checked_delete">template<class T> void checked_delete(T * p);</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Requires:</b> <b>T</b> must be a complete type. The expression <tt>delete p</tt>
|
||||
must be well-formed.
|
||||
</p>
|
||||
<p>
|
||||
<b>Effects:</b> <tt>delete p;</tt>
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3>checked_array_delete</h3>
|
||||
<h4><a name="checked_array_delete">template<class T> void checked_array_delete(T
|
||||
* p);</a></h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Requires:</b> <b>T</b> must be a complete type. The expression <tt>delete [] p</tt>
|
||||
must be well-formed.
|
||||
</p>
|
||||
<p>
|
||||
<b>Effects:</b> <tt>delete [] p;</tt>
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3>checked_deleter</h3>
|
||||
<pre>
|
||||
template<class T> struct checked_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
void operator()(T * p) const;
|
||||
};
|
||||
</pre>
|
||||
<h4>void checked_deleter<T>::operator()(T * p) const;</h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Requires:</b> <b>T</b> must be a complete type. The expression <tt>delete p</tt>
|
||||
must be well-formed.
|
||||
</p>
|
||||
<p>
|
||||
<b>Effects:</b> <tt>delete p;</tt>
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3>checked_array_deleter</h3>
|
||||
<pre>
|
||||
template<class T> struct checked_array_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
void operator()(T * p) const;
|
||||
};
|
||||
</pre>
|
||||
<h4>void checked_array_deleter<T>::operator()(T * p) const;</h4>
|
||||
<blockquote>
|
||||
<p>
|
||||
<b>Requires:</b> <b>T</b> must be a complete type. The expression <tt>delete [] p</tt>
|
||||
must be well-formed.
|
||||
</p>
|
||||
<p>
|
||||
<b>Effects:</b> <tt>delete [] p;</tt>
|
||||
</p>
|
||||
</blockquote>
|
||||
<h3><a name="Acknowledgements">Acknowledgements</a></h3>
|
||||
<p>
|
||||
The function templates <STRONG>checked_delete</STRONG> and <STRONG>checked_array_delete</STRONG>
|
||||
were originally part of <STRONG><boost/utility.hpp></STRONG>, and the
|
||||
documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, Rainer
|
||||
Deyke, John Maddock, and others as contributors.
|
||||
</p>
|
||||
<p>
|
||||
<br>
|
||||
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||
</body>
|
||||
<head>
|
||||
<meta http-equiv=refresh content="0; URL=../core/doc/html/core/checked_delete.html">
|
||||
<title>Automatic redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../core/doc/html/core/checked_delete.html">checked_delete.html</a>. <hr>
|
||||
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,28 +0,0 @@
|
||||
// Boost checked_delete test program ---------------------------------------//
|
||||
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org/libs/utility for documentation.
|
||||
|
||||
// Revision History
|
||||
// 21 May 01 Initial version (Beman Dawes)
|
||||
|
||||
#include <boost/checked_delete.hpp> // for checked_delete
|
||||
|
||||
// This program demonstrates compiler errors when trying to delete an
|
||||
// incomplete type.
|
||||
|
||||
namespace
|
||||
{
|
||||
class Incomplete;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Incomplete * p = 0;
|
||||
boost::checked_delete(p); // should cause compile time error
|
||||
boost::checked_array_delete(p); // should cause compile time error
|
||||
return 0;
|
||||
} // main
|
@ -1,75 +1,16 @@
|
||||
|
||||
<!--
|
||||
Copyright 2014 Daniel James.
|
||||
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)
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Header </title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
|
||||
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
||||
<boostcompressed_pair.hpp>
|
||||
</head>
|
||||
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">
|
||||
<h2><img src="../../boost.png" width="276" height="86">Header <<a href="../../boost/detail/compressed_pair.hpp">boost/compressed_pair.hpp</a>></h2>
|
||||
<p>All of the contents of <boost/compressed_pair.hpp> are defined inside
|
||||
namespace boost.</p>
|
||||
<p>The class compressed pair is very similar to std::pair, but if either of the
|
||||
template arguments are empty classes, then the "empty base-class optimisation"
|
||||
is applied to compress the size of the pair.</p>
|
||||
<pre>template <class T1, class T2>
|
||||
class compressed_pair
|
||||
{
|
||||
public:
|
||||
typedef T1 first_type;
|
||||
typedef T2 second_type;
|
||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
||||
typedef typename call_traits<first_type>::reference first_reference;
|
||||
typedef typename call_traits<second_type>::reference second_reference;
|
||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
||||
|
||||
compressed_pair() : base() {}
|
||||
compressed_pair(first_param_type x, second_param_type y);
|
||||
explicit compressed_pair(first_param_type x);
|
||||
explicit compressed_pair(second_param_type y);
|
||||
|
||||
compressed_pair& operator=(const compressed_pair&);
|
||||
|
||||
first_reference first();
|
||||
first_const_reference first() const;
|
||||
|
||||
second_reference second();
|
||||
second_const_reference second() const;
|
||||
|
||||
void swap(compressed_pair& y);
|
||||
};</pre>
|
||||
<p>The two members of the pair can be accessed using the member functions first()
|
||||
and second(). Note that not all member functions can be instantiated for all
|
||||
template parameter types. In particular compressed_pair can be instantiated for
|
||||
reference and array types, however in these cases the range of constructors
|
||||
that can be used are limited. If types T1 and T2 are the same type, then there
|
||||
is only one version of the single-argument constructor, and this constructor
|
||||
initialises both values in the pair to the passed value.</p>
|
||||
<P>Note that if either member is a POD type, then that member is not
|
||||
zero-initialized by the compressed_pair default constructor: it's up to you to
|
||||
supply an initial value for these types if you want them to have a default
|
||||
value.</P>
|
||||
<p>Note that compressed_pair can not be instantiated if either of the template
|
||||
arguments is a union type, unless there is compiler support for
|
||||
boost::is_union, or if boost::is_union is specialised for the union type.</p>
|
||||
<p>Finally, a word of caution for Visual C++ 6 users: if either argument is an
|
||||
empty type, then assigning to that member will produce memory corruption,
|
||||
unless the empty type has a "do nothing" assignment operator defined. This is
|
||||
due to a bug in the way VC6 generates implicit assignment operators.</p>
|
||||
<hr>
|
||||
<p>Revised 08 May 2001</p>
|
||||
<p><EFBFBD> Copyright boost.org 2000. 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.</p>
|
||||
<p>Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John
|
||||
Maddock.</p>
|
||||
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John Maddock</a>, the
|
||||
latest version of this file can be found at <a href="http://www.boost.org">www.boost.org</a>,
|
||||
and the boost discussion list at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p>
|
||||
<p> </p>
|
||||
</body>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=doc/html/compressed_pair.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="doc/html/compressed_pair.html">doc/html/compressed_pair.html</a>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,36 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: current_function.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"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
|
||||
</td>
|
||||
<td align="center">
|
||||
<h1>current_function.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
The header <STRONG><boost/current_function.hpp></STRONG> defines a single
|
||||
macro, <STRONG>BOOST_CURRENT_FUNCTION</STRONG>,<STRONG> </STRONG>similar to the
|
||||
C99 predefined identifier <STRONG>__func__</STRONG>.
|
||||
</p>
|
||||
<P><STRONG>BOOST_CURRENT_FUNCTION</STRONG> expands to a string literal containing
|
||||
the (fully qualified, if possible) name of the enclosing function. If there is
|
||||
no enclosing function, the behavior is undefined.</P>
|
||||
<p>Some compilers do not provide a way to obtain the name of the current enclosing
|
||||
function. On such compilers, the string literal has an unspecified value.</p>
|
||||
<p>
|
||||
<br>
|
||||
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||
</body>
|
||||
</html>
|
@ -1,40 +0,0 @@
|
||||
#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
|
||||
|
||||
//
|
||||
// current_function_test.cpp - a test for boost/current_function.hpp
|
||||
//
|
||||
// Copyright (c) 2002 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)
|
||||
//
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
void message(char const * file, long line, char const * func, char const * msg)
|
||||
{
|
||||
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using std::printf;
|
||||
#endif
|
||||
|
||||
printf("%s(%ld): %s in function '%s'\n", file, line, msg, func);
|
||||
}
|
||||
|
||||
#define MESSAGE(msg) message(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, msg)
|
||||
|
||||
int main()
|
||||
{
|
||||
MESSAGE("assertion failed");
|
||||
|
||||
return 0;
|
||||
}
|
127
doc/Jamfile.v2
Normal file
127
doc/Jamfile.v2
Normal file
@ -0,0 +1,127 @@
|
||||
|
||||
# Copyright John Maddock 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)
|
||||
|
||||
project : requirements
|
||||
# Path for links to Boost:
|
||||
<xsl:param>boost.root=../../../..
|
||||
|
||||
# Some general style settings:
|
||||
<xsl:param>table.footnote.number.format=1
|
||||
<xsl:param>footnote.number.format=1
|
||||
|
||||
# HTML options first:
|
||||
# Use graphics not text for navigation:
|
||||
<xsl:param>navig.graphics=1
|
||||
# PDF Options:
|
||||
# TOC Generation: this is needed for FOP-0.9 and later:
|
||||
<xsl:param>fop1.extensions=0
|
||||
<xsl:param>xep.extensions=1
|
||||
# TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
|
||||
<xsl:param>fop.extensions=0
|
||||
# No indent on body text:
|
||||
<xsl:param>body.start.indent=0pt
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.inner=0.5in
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.outer=0.5in
|
||||
# Paper type = A4
|
||||
<xsl:param>paper.type=A4
|
||||
# Yes, we want graphics for admonishments:
|
||||
<xsl:param>admon.graphics=1
|
||||
# Set this one for PDF generation *only*:
|
||||
# default pnd graphics are awful in PDF form,
|
||||
# better use SVG's instead:
|
||||
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
|
||||
<format>pdf:<xsl:param>admon.graphics.path=$(boost-images)/
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/utility/doc/html
|
||||
;
|
||||
|
||||
using quickbook ;
|
||||
|
||||
path-constant boost-images : ../../../doc/src/images ;
|
||||
|
||||
xml base_from_member : base_from_member.qbk ;
|
||||
boostbook standalone_base_from_member
|
||||
:
|
||||
base_from_member
|
||||
:
|
||||
# File name of HTML output:
|
||||
<xsl:param>root.filename=base_from_member
|
||||
# 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=1
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=1
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
;
|
||||
|
||||
xml compressed_pair : compressed_pair.qbk ;
|
||||
boostbook standalone_compressed_pair
|
||||
:
|
||||
compressed_pair
|
||||
:
|
||||
# File name of HTML output:
|
||||
<xsl:param>root.filename=compressed_pair
|
||||
# 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=1
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=1
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
;
|
||||
|
||||
xml declval : declval.qbk ;
|
||||
boostbook standalone_declval
|
||||
:
|
||||
declval
|
||||
:
|
||||
# File name of HTML output:
|
||||
<xsl:param>root.filename=declval
|
||||
# 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=1
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=1
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
;
|
||||
|
||||
xml string_ref : string_ref.qbk ;
|
||||
boostbook standalone_string_ref
|
||||
:
|
||||
string_ref
|
||||
:
|
||||
# File name of HTML output:
|
||||
<xsl:param>root.filename=string_ref
|
||||
# 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=1
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=1
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease :
|
||||
standalone_base_from_member standalone_compressed_pair
|
||||
standalone_declval standalone_string_ref ;
|
||||
explicit boostrelease ;
|
363
doc/base_from_member.qbk
Normal file
363
doc/base_from_member.qbk
Normal file
@ -0,0 +1,363 @@
|
||||
[/
|
||||
Copyright 2001, 2003, 2004, 2012 Daryle Walker.
|
||||
|
||||
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
|
||||
]
|
||||
|
||||
[article Base_From_Member
|
||||
[quickbook 1.5]
|
||||
[authors [Walker, Daryle]]
|
||||
[copyright 2001, 2003, 2004, 2012 Daryle Walker]
|
||||
[license
|
||||
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 Rationale]
|
||||
|
||||
When developing a class, sometimes a base class needs to be initialized
|
||||
with a member of the current class. As a na\u00EFve example:
|
||||
|
||||
#include <streambuf> /* for std::streambuf */
|
||||
#include <ostream> /* for std::ostream */
|
||||
|
||||
class fdoutbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit fdoutbuf( int fd );
|
||||
//...
|
||||
};
|
||||
|
||||
class fdostream
|
||||
: public std::ostream
|
||||
{
|
||||
protected:
|
||||
fdoutbuf buf;
|
||||
public:
|
||||
explicit fdostream( int fd )
|
||||
: buf( fd ), std::ostream( &buf ) {}
|
||||
//...
|
||||
};
|
||||
|
||||
This is undefined because C++'s initialization order mandates that the base
|
||||
class is initialized before the member it uses. [@http://www.moocat.org R.
|
||||
Samuel Klatchko] developed a way around this by using the initialization
|
||||
order in his favor. Base classes are intialized in order of declaration, so
|
||||
moving the desired member to another base class, that is initialized before
|
||||
the desired base class, can ensure proper initialization.
|
||||
|
||||
A custom base class can be made for this idiom:
|
||||
|
||||
#include <streambuf> /* for std::streambuf */
|
||||
#include <ostream> /* for std::ostream */
|
||||
|
||||
class fdoutbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit fdoutbuf( int fd );
|
||||
//...
|
||||
};
|
||||
|
||||
struct fdostream_pbase
|
||||
{
|
||||
fdoutbuf sbuffer;
|
||||
|
||||
explicit fdostream_pbase( int fd )
|
||||
: sbuffer( fd ) {}
|
||||
};
|
||||
|
||||
class fdostream
|
||||
: private fdostream_pbase
|
||||
, public std::ostream
|
||||
{
|
||||
typedef fdostream_pbase pbase_type;
|
||||
typedef std::ostream base_type;
|
||||
|
||||
public:
|
||||
explicit fdostream( int fd )
|
||||
: pbase_type( fd ), base_type( &sbuffer ) {}
|
||||
//...
|
||||
};
|
||||
|
||||
Other projects can use similar custom base classes. The technique is basic
|
||||
enough to make a template, with a sample template class in this library.
|
||||
The main template parameter is the type of the enclosed member. The
|
||||
template class has several (explicit) constructor member templates, which
|
||||
implicitly type the constructor arguments and pass them to the member. The
|
||||
template class uses implicit copy construction and assignment, cancelling
|
||||
them if the enclosed member is non-copyable.
|
||||
|
||||
Manually coding a base class may be better if the construction and/or
|
||||
copying needs are too complex for the supplied template class, or if the
|
||||
compiler is not advanced enough to use it.
|
||||
|
||||
Since base classes are unnamed, a class cannot have multiple (direct) base
|
||||
classes of the same type. The supplied template class has an extra template
|
||||
parameter, an integer, that exists solely to provide type differentiation.
|
||||
This parameter has a default value so a single use of a particular member
|
||||
type does not need to concern itself with the integer.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
#include <type_traits> /* exposition only */
|
||||
|
||||
#ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY
|
||||
#define BOOST_BASE_FROM_MEMBER_MAX_ARITY 10
|
||||
#endif
|
||||
|
||||
template < typename MemberType, int UniqueID = 0 >
|
||||
class boost::base_from_member
|
||||
{
|
||||
protected:
|
||||
MemberType member;
|
||||
|
||||
#if ``['C++11 is in use]``
|
||||
template< typename ...T >
|
||||
explicit constexpr base_from_member( T&& ...x )
|
||||
noexcept( std::is_nothrow_constructible<MemberType, T...>::value );
|
||||
#else
|
||||
base_from_member();
|
||||
|
||||
template< typename T1 >
|
||||
explicit base_from_member( T1 x1 );
|
||||
|
||||
template< typename T1, typename T2 >
|
||||
base_from_member( T1 x1, T2 x2 );
|
||||
|
||||
//...
|
||||
|
||||
template< typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8, typename T9,
|
||||
typename T10 >
|
||||
base_from_member( T1 x1, T2 x2, T3 x3, T4 x4, T5 x5, T6 x6, T7 x7,
|
||||
T8 x8, T9 x9, T10 x10 );
|
||||
#endif
|
||||
};
|
||||
|
||||
template < typename MemberType, int UniqueID >
|
||||
class base_from_member<MemberType&, UniqueID>
|
||||
{
|
||||
protected:
|
||||
MemberType& member;
|
||||
|
||||
explicit constexpr base_from_member( MemberType& x )
|
||||
noexcept;
|
||||
};
|
||||
|
||||
The class template has a first template parameter `MemberType` representing
|
||||
the type of the based-member. It has a last template parameter `UniqueID`,
|
||||
that is an `int`, to differentiate between multiple base classes that use
|
||||
the same based-member type. The last template parameter has a default value
|
||||
of zero if it is omitted. The class template has a protected data member
|
||||
called `member` that the derived class can use for later base classes (or
|
||||
itself).
|
||||
|
||||
If the appropriate features of C++11 are present, there will be a single
|
||||
constructor template. It implements ['perfect forwarding] to the best
|
||||
constructor call of `member` (if any). The constructor template is marked
|
||||
both `constexpr` and `explicit`. The former will be ignored if the
|
||||
corresponding inner constructor call (of `member`) does not have the marker.
|
||||
The latter binds the other way; always taking effect, even when the inner
|
||||
constructor call does not have the marker. The constructor template
|
||||
propagates the `noexcept` status of the inner constructor call. (The
|
||||
constructor template has a trailing parameter with a default value that
|
||||
disables the template when its signature is too close to the signatures of
|
||||
the automatically-defined non-template copy- and/or move-constructors of
|
||||
`base_from_member`.)
|
||||
|
||||
On earlier-standard compilers, there is a default constructor and several
|
||||
constructor member templates. These constructor templates can take as many
|
||||
arguments (currently up to ten) as possible and pass them to a constructor
|
||||
of the data member.
|
||||
|
||||
A specialization for member references offers a single constructor taking
|
||||
a `MemberType&`, which is the only way to initialize a reference.
|
||||
|
||||
Since C++ does not allow any way to explicitly state the template parameters
|
||||
of a templated constructor, make sure that the arguments are already close
|
||||
as possible to the actual type used in the data member's desired constructor.
|
||||
Explicit conversions may be necessary.
|
||||
|
||||
The `BOOST_BASE_FROM_MEMBER_MAX_ARITY` macro constant specifies the maximum
|
||||
argument length for the constructor templates. The constant may be overridden
|
||||
if more (or less) argument configurations are needed. The constant may be
|
||||
read for code that is expandable like the class template and needs to
|
||||
maintain the same maximum size. (Example code would be a class that uses
|
||||
this class template as a base class for a member with a flexible set of
|
||||
constructors.) This constant is ignored when C++11 features are present.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Usage]
|
||||
|
||||
With the starting example, the `fdoutbuf` sub-object needs to be
|
||||
encapsulated in a base class that is inheirited before `std::ostream`.
|
||||
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
|
||||
#include <streambuf> // for std::streambuf
|
||||
#include <ostream> // for std::ostream
|
||||
|
||||
class fdoutbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit fdoutbuf( int fd );
|
||||
//...
|
||||
};
|
||||
|
||||
class fdostream
|
||||
: private boost::base_from_member<fdoutbuf>
|
||||
, public std::ostream
|
||||
{
|
||||
// Helper typedef's
|
||||
typedef boost::base_from_member<fdoutbuf> pbase_type;
|
||||
typedef std::ostream base_type;
|
||||
|
||||
public:
|
||||
explicit fdostream( int fd )
|
||||
: pbase_type( fd ), base_type( &member ){}
|
||||
//...
|
||||
};
|
||||
|
||||
The base-from-member idiom is an implementation detail, so it should not
|
||||
be visible to the clients (or any derived classes) of `fdostream`. Due to
|
||||
the initialization order, the `fdoutbuf` sub-object will get initialized
|
||||
before the `std::ostream` sub-object does, making the former sub-object
|
||||
safe to use in the latter sub-object's construction. Since the `fdoutbuf`
|
||||
sub-object of the final type is the only sub-object with the name `member`
|
||||
that name can be used unqualified within the final class.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
The base-from-member class templates should commonly involve only one
|
||||
base-from-member sub-object, usually for attaching a stream-buffer to an
|
||||
I/O stream. The next example demonstrates how to use multiple
|
||||
base-from-member sub-objects and the resulting qualification issues.
|
||||
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
|
||||
#include <cstddef> /* for NULL */
|
||||
|
||||
struct an_int
|
||||
{
|
||||
int y;
|
||||
|
||||
an_int( float yf );
|
||||
};
|
||||
|
||||
class switcher
|
||||
{
|
||||
public:
|
||||
switcher();
|
||||
switcher( double, int * );
|
||||
//...
|
||||
};
|
||||
|
||||
class flow_regulator
|
||||
{
|
||||
public:
|
||||
flow_regulator( switcher &, switcher & );
|
||||
//...
|
||||
};
|
||||
|
||||
template < unsigned Size >
|
||||
class fan
|
||||
{
|
||||
public:
|
||||
explicit fan( switcher );
|
||||
//...
|
||||
};
|
||||
|
||||
class system
|
||||
: private boost::base_from_member<an_int>
|
||||
, private boost::base_from_member<switcher>
|
||||
, private boost::base_from_member<switcher, 1>
|
||||
, private boost::base_from_member<switcher, 2>
|
||||
, protected flow_regulator
|
||||
, public fan<6>
|
||||
{
|
||||
// Helper typedef's
|
||||
typedef boost::base_from_member<an_int> pbase0_type;
|
||||
typedef boost::base_from_member<switcher> pbase1_type;
|
||||
typedef boost::base_from_member<switcher, 1> pbase2_type;
|
||||
typedef boost::base_from_member<switcher, 2> pbase3_type;
|
||||
|
||||
typedef flow_regulator base1_type;
|
||||
typedef fan<6> base2_type;
|
||||
|
||||
public:
|
||||
system( double x );
|
||||
//...
|
||||
};
|
||||
|
||||
system::system( double x )
|
||||
: pbase0_type( 0.2 )
|
||||
, pbase1_type()
|
||||
, pbase2_type( -16, &this->pbase0_type::member.y )
|
||||
, pbase3_type( x, static_cast<int *>(NULL) )
|
||||
, base1_type( pbase3_type::member, pbase1_type::member )
|
||||
, base2_type( pbase2_type::member )
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
The final class has multiple sub-objects with the name `member`, so any
|
||||
use of that name needs qualification by a name of the appropriate base
|
||||
type. (Using `typedef`s ease mentioning the base types.) However, the fix
|
||||
introduces a new problem when a pointer is needed. Using the address
|
||||
operator with a sub-object qualified with its class's name results in a
|
||||
pointer-to-member (here, having a type of `an_int boost::base_from_member<
|
||||
an_int, 0> :: *`) instead of a pointer to the member (having a type of
|
||||
`an_int *`). The new problem is fixed by qualifying the sub-object with
|
||||
`this->` and is needed just for pointers, and not for references or values.
|
||||
|
||||
There are some argument conversions in the initialization. The constructor
|
||||
argument for `pbase0_type` is converted from `double` to `float`. The first
|
||||
constructor argument for `pbase2_type` is converted from `int` to `double`.
|
||||
The second constructor argument for `pbase3_type` is a special case of
|
||||
necessary conversion; all forms of the null-pointer literal in C++ (except
|
||||
`nullptr` from C++11) also look like compile-time integral expressions, so
|
||||
C++ always interprets such code as an integer when it has overloads that can
|
||||
take either an integer or a pointer. The last conversion is necessary for the
|
||||
compiler to call a constructor form with the exact pointer type used in
|
||||
`switcher`'s constructor. (If C++11's `nullptr` is used, it still needs a
|
||||
conversion if multiple pointer types can be accepted in a constructor call
|
||||
but `std::nullptr_t` cannot.)
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
* [@http://www.boost.org/people/ed_brey.htm Ed Brey] suggested some interface
|
||||
changes.
|
||||
|
||||
* [@http://www.moocat.org R. Samuel Klatchko] ([@mailto:rsk@moocat.org
|
||||
rsk@moocat.org], [@mailto:rsk@brightmail.com rsk@brightmail.com]) invented
|
||||
the idiom of how to use a class member for initializing a base class.
|
||||
|
||||
* [@http://www.boost.org/people/dietmar_kuehl.htm Dietmar Kuehl] popularized the
|
||||
base-from-member idiom in his [@http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/
|
||||
IOStream example classes].
|
||||
|
||||
* Jonathan Turkanis supplied an implementation of generating the constructor
|
||||
templates that can be controlled and automated with macros. The
|
||||
implementation uses the [@../../../preprocessor/index.html Preprocessor library].
|
||||
|
||||
* [@http://www.boost.org/people/daryle_walker.html">Daryle Walker] started the
|
||||
library. Contributed the test file [@../../test/base_from_member_test.cpp
|
||||
base_from_member_test.cpp].
|
||||
|
||||
[endsect]
|
||||
|
99
doc/compressed_pair.qbk
Normal file
99
doc/compressed_pair.qbk
Normal file
@ -0,0 +1,99 @@
|
||||
[/
|
||||
Copyright 2000 Beman Dawes & John Maddock.
|
||||
|
||||
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
|
||||
]
|
||||
|
||||
[article Compressed_Pair
|
||||
[quickbook 1.5]
|
||||
[authors [Cleary, Steve]]
|
||||
[authors [Dawes, Beman]]
|
||||
[authors [Hinnant, Howard]]
|
||||
[authors [Maddock, John]]
|
||||
[copyright 2000 Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock]
|
||||
[license
|
||||
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 Overview]
|
||||
|
||||
All of the contents of `<boost/compressed_pair.hpp>` are defined inside
|
||||
`namespace boost`.
|
||||
|
||||
The class `compressed_pair` is very similar to `std::pair`, but if either of
|
||||
the template arguments are empty classes, then the ['empty base-class
|
||||
optimisation] is applied to compress the size of the pair.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
template <class T1, class T2>
|
||||
class compressed_pair
|
||||
{
|
||||
public:
|
||||
typedef T1 first_type;
|
||||
typedef T2 second_type;
|
||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
||||
typedef typename call_traits<first_type>::reference first_reference;
|
||||
typedef typename call_traits<second_type>::reference second_reference;
|
||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
||||
|
||||
compressed_pair() : base() {}
|
||||
compressed_pair(first_param_type x, second_param_type y);
|
||||
explicit compressed_pair(first_param_type x);
|
||||
explicit compressed_pair(second_param_type y);
|
||||
|
||||
compressed_pair& operator=(const compressed_pair&);
|
||||
|
||||
first_reference first();
|
||||
first_const_reference first() const;
|
||||
|
||||
second_reference second();
|
||||
second_const_reference second() const;
|
||||
|
||||
void swap(compressed_pair& y);
|
||||
};
|
||||
|
||||
The two members of the pair can be accessed using the member functions
|
||||
`first()` and `second()`. Note that not all member functions can be
|
||||
instantiated for all template parameter types. In particular
|
||||
`compressed_pair` can be instantiated for reference and array types,
|
||||
however in these cases the range of constructors that can be used are
|
||||
limited. If types `T1` and `T2` are the same type, then there is only
|
||||
one version of the single-argument constructor, and this constructor
|
||||
initialises both values in the pair to the passed value.
|
||||
|
||||
Note that if either member is a POD type, then that member is not
|
||||
zero-initialized by the `compressed_pair` default constructor: it's up
|
||||
to you to supply an initial value for these types if you want them to have
|
||||
a default value.
|
||||
|
||||
Note that `compressed_pair` can not be instantiated if either of the
|
||||
template arguments is a union type, unless there is compiler support for
|
||||
`boost::is_union`, or if `boost::is_union` is specialised for the union
|
||||
type.
|
||||
|
||||
Finally, a word of caution for Visual C++ 6 users: if either argument is an
|
||||
empty type, then assigning to that member will produce memory corruption,
|
||||
unless the empty type has a "do nothing" assignment operator defined. This
|
||||
is due to a bug in the way VC6 generates implicit assignment operators.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and
|
||||
John Maddock.
|
||||
|
||||
Maintained by [@mailto:john@johnmaddock.co.uk John Maddock].
|
||||
|
||||
[endsect]
|
114
doc/declval.qbk
Normal file
114
doc/declval.qbk
Normal file
@ -0,0 +1,114 @@
|
||||
[/
|
||||
/ Copyright (c) 2008 Howard Hinnant
|
||||
/ Copyright (c) 2009-2012 Vicente J. Botet Escriba
|
||||
/
|
||||
/ 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)
|
||||
/]
|
||||
|
||||
[article Declval
|
||||
[quickbook 1.5]
|
||||
[authors [Hinnant, Howard]]
|
||||
[authors [Botet Escriba, Vicente J.]]
|
||||
[copyright 2008 Howard Hinnant]
|
||||
[copyright 2009-2012 Vicente J. Botet Escriba]
|
||||
[license
|
||||
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 Overview]
|
||||
[/===============]
|
||||
|
||||
The motivation for `declval` was introduced in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2958.html#Value N2958:
|
||||
Moving Swap Forward]. Here follows a rewording of this chapter.
|
||||
|
||||
With the provision of decltype, late-specified return types, and default template-arguments for function templates a
|
||||
new generation of SFINAE patterns will emerge to at least partially compensate the lack of concepts on the C++0x timescale.
|
||||
Using this technique, it is sometimes necessary to obtain an object of a known type in a non-using context, e.g. given the declaration
|
||||
|
||||
template<class T>
|
||||
T&& declval(); // not used
|
||||
|
||||
as part of the function template declaration
|
||||
|
||||
template<class To, class From>
|
||||
decltype(static_cast<To>(declval<From>())) convert(From&&);
|
||||
|
||||
or as part of a class template definition
|
||||
|
||||
template<class> class result_of;
|
||||
|
||||
template<class Fn, class... ArgTypes>
|
||||
struct result_of<Fn(ArgTypes...)>
|
||||
{
|
||||
typedef decltype(declval<Fn>()(declval<ArgTypes>()...)) type;
|
||||
};
|
||||
|
||||
The role of the function template declval() is a transformation of a type T into a value without using or evaluating this function.
|
||||
The name is supposed to direct the reader's attention to the fact that the expression `declval<T>()` is an lvalue if and only if
|
||||
T is an lvalue-reference, otherwise an rvalue. To extend the domain of this function we can do a bit better by changing its declaration to
|
||||
|
||||
template<class T>
|
||||
typename std::add_rvalue_reference<T>::type declval(); // not used
|
||||
|
||||
which ensures that we can also use cv void as template parameter. The careful reader might have noticed that `declval()`
|
||||
already exists under the name create() as part of the definition of the semantics of the type trait is_convertible in the C++0x standard.
|
||||
|
||||
The provision of a new library component that allows the production of values in unevaluated expressions is considered
|
||||
important to realize constrained templates in C++0x where concepts are not available.
|
||||
This extremely light-weight function is expected to be part of the daily tool-box of the C++0x programmer.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[/=================]
|
||||
[section:reference Reference ]
|
||||
[/=================]
|
||||
|
||||
`#include <boost/utility/declval.hpp>`
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename T>
|
||||
typename add_rvalue_reference<T>::type declval() noexcept; // as unevaluated operand
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
The library provides the function template declval to simplify the definition of expressions which occur as unevaluated operands.
|
||||
|
||||
template <typename T>
|
||||
typename add_rvalue_reference<T>::type declval();
|
||||
|
||||
[*Remarks:] If this function is used, the program is ill-formed.
|
||||
|
||||
[*Remarks:] The template parameter T of declval may be an incomplete type.
|
||||
|
||||
[*Example:]
|
||||
|
||||
template <class To, class From>
|
||||
decltype(static_cast<To>(declval<From>())) convert(From&&);
|
||||
|
||||
Declares a function template convert which only participates in overloading if the type From can be explicitly converted to type To.
|
||||
|
||||
[endsect]
|
||||
|
||||
[/===============]
|
||||
[section History]
|
||||
[/===============]
|
||||
|
||||
[heading boost 1.50]
|
||||
|
||||
Fixes:
|
||||
|
||||
* [@http://svn.boost.org/trac/boost/ticket/6570 #6570] Adding noexcept to boost::declval.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
BIN
doc/logo.png
Normal file
BIN
doc/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
539
doc/logo.svg
Normal file
539
doc/logo.svg
Normal file
@ -0,0 +1,539 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg6858"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="utility.svg">
|
||||
<defs
|
||||
id="defs6860">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4453-7-8-6-7-3-5"
|
||||
id="linearGradient10687-2-5"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="753.02301"
|
||||
y1="3132.0801"
|
||||
x2="1146.25"
|
||||
y2="3132.0801" />
|
||||
<linearGradient
|
||||
id="linearGradient4453-7-8-6-7-3-5">
|
||||
<stop
|
||||
style="stop-color:#aac4dd;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4455-61-8-7-1-2-8" />
|
||||
<stop
|
||||
style="stop-color:#c2dbe9;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop4457-4-1-9-1-12-1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4453-7-8-6-7-3-5"
|
||||
id="linearGradient10685-2-2"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="753.02301"
|
||||
y1="3132.0801"
|
||||
x2="1146.25"
|
||||
y2="3132.0801" />
|
||||
<linearGradient
|
||||
id="linearGradient6749">
|
||||
<stop
|
||||
style="stop-color:#aac4dd;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6751" />
|
||||
<stop
|
||||
style="stop-color:#c2dbe9;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop6753" />
|
||||
</linearGradient>
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath3387-3-6-4-2-8-4">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 862.109,3289.75 -109.086,-190.45 69.122,-124.42 164.511,-0.47 c 0,0 111.044,188.28 116.564,197.63 7.66,0 43.03,0 43.03,0 l -67.03,117.71 -217.111,0 z"
|
||||
id="path3389-2-0-7-7-8-9" />
|
||||
</clipPath>
|
||||
<linearGradient
|
||||
y2="3132.0801"
|
||||
x2="1146.25"
|
||||
y1="3132.0801"
|
||||
x1="753.02301"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient4492-8-8"
|
||||
xlink:href="#linearGradient4453-7-8-6-7-3-5"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
id="linearGradient6758">
|
||||
<stop
|
||||
style="stop-color:#aac4dd;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6760" />
|
||||
<stop
|
||||
style="stop-color:#c2dbe9;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop6762" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4453-7-8-6-7-3-5"
|
||||
id="linearGradient10691-7-8"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="1026.6899"
|
||||
y1="2937.73"
|
||||
x2="1463.14"
|
||||
y2="2937.73" />
|
||||
<linearGradient
|
||||
id="linearGradient6765">
|
||||
<stop
|
||||
style="stop-color:#aac4dd;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6767" />
|
||||
<stop
|
||||
style="stop-color:#c2dbe9;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop6769" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4453-7-8-6-7-3-5"
|
||||
id="linearGradient10689-4-2"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="1026.6899"
|
||||
y1="2937.73"
|
||||
x2="1463.14"
|
||||
y2="2937.73" />
|
||||
<linearGradient
|
||||
id="linearGradient6772">
|
||||
<stop
|
||||
style="stop-color:#aac4dd;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6774" />
|
||||
<stop
|
||||
style="stop-color:#c2dbe9;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop6776" />
|
||||
</linearGradient>
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath3369-1-5-6-1-0-7">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 1131.64,3128.5 -104.95,-181.12 116.38,-200.42 208.05,0.94 112.02,191.63 -112.08,188.97 -219.42,0 z"
|
||||
id="path3371-89-4-1-6-0-1" />
|
||||
</clipPath>
|
||||
<linearGradient
|
||||
y2="2937.73"
|
||||
x2="1463.14"
|
||||
y1="2937.73"
|
||||
x1="1026.6899"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient4498-5-7"
|
||||
xlink:href="#linearGradient4453-7-8-6-7-3-5"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
id="linearGradient6781">
|
||||
<stop
|
||||
style="stop-color:#aac4dd;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6783" />
|
||||
<stop
|
||||
style="stop-color:#c2dbe9;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop6785" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4459-1-2-8-9-9-5"
|
||||
id="linearGradient10695-9-9"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="646.55499"
|
||||
y1="2736.25"
|
||||
x2="1088.27"
|
||||
y2="2736.25" />
|
||||
<linearGradient
|
||||
id="linearGradient4459-1-2-8-9-9-5">
|
||||
<stop
|
||||
id="stop4461-2-1-5-2-5-0"
|
||||
offset="0"
|
||||
style="stop-color:#839bc2;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop4463-3-2-8-7-30-3"
|
||||
offset="1"
|
||||
style="stop-color:#9fb6d4;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4459-1-2-8-9-9-5"
|
||||
id="linearGradient10693-9-4"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="646.55499"
|
||||
y1="2736.25"
|
||||
x2="1088.27"
|
||||
y2="2736.25" />
|
||||
<linearGradient
|
||||
id="linearGradient6792">
|
||||
<stop
|
||||
id="stop6794"
|
||||
offset="0"
|
||||
style="stop-color:#839bc2;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop6796"
|
||||
offset="1"
|
||||
style="stop-color:#9fb6d4;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath3351-4-7-3-5-95-0">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 757.242,2926.25 -110.687,-189.11 110.656,-190.89 219.437,0 111.622,189.1 -111.59,190.9 -219.438,0 z"
|
||||
id="path3353-1-9-3-4-1-1" />
|
||||
</clipPath>
|
||||
<linearGradient
|
||||
y2="2736.25"
|
||||
x2="1088.27"
|
||||
y1="2736.25"
|
||||
x1="646.55499"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient4510-1-5"
|
||||
xlink:href="#linearGradient4459-1-2-8-9-9-5"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
id="linearGradient6801">
|
||||
<stop
|
||||
id="stop6803"
|
||||
offset="0"
|
||||
style="stop-color:#839bc2;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop6805"
|
||||
offset="1"
|
||||
style="stop-color:#9fb6d4;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#radialGradient3327-8-4-8-0-2-4"
|
||||
id="radialGradient10699-1-3"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cx="997.46997"
|
||||
cy="2896.25"
|
||||
fx="997.46997"
|
||||
fy="2896.25"
|
||||
r="583.73999" />
|
||||
<radialGradient
|
||||
fx="0"
|
||||
fy="0"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(58.375,0,0,-58.375,99.75,289.625)"
|
||||
spreadMethod="pad"
|
||||
id="radialGradient3327-8-4-8-0-2-4">
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#aeaeb3"
|
||||
offset="0"
|
||||
id="stop3329-7-0-1-0-33-2" />
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#ffffff"
|
||||
offset="0.949438"
|
||||
id="stop3331-4-3-0-0-97-3" />
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#ffffff"
|
||||
offset="1"
|
||||
id="stop3333-2-4-9-7-2-2" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
r="583.73999"
|
||||
fy="2896.25"
|
||||
fx="997.46997"
|
||||
cy="2896.25"
|
||||
cx="997.46997"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient13050"
|
||||
xlink:href="#radialGradient3327-8-4-8-0-2-4"
|
||||
inkscape:collect="always" />
|
||||
<radialGradient
|
||||
fx="0"
|
||||
fy="0"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(58.375,0,0,-58.375,99.75,289.625)"
|
||||
spreadMethod="pad"
|
||||
id="radialGradient6813">
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#aeaeb3"
|
||||
offset="0"
|
||||
id="stop6815" />
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#ffffff"
|
||||
offset="0.949438"
|
||||
id="stop6817" />
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#ffffff"
|
||||
offset="1"
|
||||
id="stop6819" />
|
||||
</radialGradient>
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath3323-7-2-4-5-3-4">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 997.469,2312.51 c -322.379,0 -583.739,261.36 -583.739,583.74 0,322.38 261.36,583.74 583.739,583.74 322.381,0 583.741,-261.36 583.741,-583.74 0,-322.38 -261.36,-583.74 -583.741,-583.74"
|
||||
id="path3325-9-2-9-5-04-9" />
|
||||
</clipPath>
|
||||
<radialGradient
|
||||
r="583.73999"
|
||||
fy="2896.25"
|
||||
fx="997.46997"
|
||||
cy="2896.25"
|
||||
cx="997.46997"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient4516-8-2"
|
||||
xlink:href="#radialGradient3327-8-4-8-0-2-4"
|
||||
inkscape:collect="always" />
|
||||
<radialGradient
|
||||
fx="0"
|
||||
fy="0"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(58.375,0,0,-58.375,99.75,289.625)"
|
||||
spreadMethod="pad"
|
||||
id="radialGradient6824">
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#aeaeb3"
|
||||
offset="0"
|
||||
id="stop6826" />
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#ffffff"
|
||||
offset="0.949438"
|
||||
id="stop6828" />
|
||||
<stop
|
||||
style="stop-opacity:1;stop-color:#ffffff"
|
||||
offset="1"
|
||||
id="stop6830" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
r="583.73999"
|
||||
fy="2896.25"
|
||||
fx="997.46997"
|
||||
cy="2896.25"
|
||||
cx="997.46997"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient6856"
|
||||
xlink:href="#radialGradient3327-8-4-8-0-2-4"
|
||||
inkscape:collect="always" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="234.05635"
|
||||
inkscape:cy="581.46313"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1680"
|
||||
inkscape:window-height="982"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3066" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata6863">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<g
|
||||
id="g3319-1-2-5-1-4-4"
|
||||
transform="matrix(0.10419818,0,0,-0.10419818,137.10955,897.00327)"
|
||||
style="fill:url(#radialGradient10699-1-3);fill-opacity:1"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523">
|
||||
<g
|
||||
clip-path="url(#clipPath3323-7-2-4-5-3-4)"
|
||||
id="g3321-9-2-7-4-3-9"
|
||||
style="fill:url(#radialGradient6856);fill-opacity:1">
|
||||
<path
|
||||
id="path3335-8-7-3-8-92-0"
|
||||
style="fill:url(#radialGradient4516-8-2);fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 997.469,2312.51 c -322.379,0 -583.739,261.36 -583.739,583.74 0,322.38 261.36,583.74 583.739,583.74 322.381,0 583.741,-261.36 583.741,-583.74 0,-322.38 -261.36,-583.74 -583.741,-583.74"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="g3347-6-8-3-7-4-4"
|
||||
transform="matrix(0.125,0,0,-0.125,112.08304,959.82207)"
|
||||
style="fill:url(#linearGradient10695-9-9);fill-opacity:1"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523">
|
||||
<g
|
||||
clip-path="url(#clipPath3351-4-7-3-5-95-0)"
|
||||
id="g3349-5-5-4-7-9-4"
|
||||
style="fill:url(#linearGradient10693-9-4);fill-opacity:1">
|
||||
<path
|
||||
id="path3361-0-8-2-9-0-9"
|
||||
style="fill:url(#linearGradient4510-1-5);fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 757.242,2926.25 -110.687,-189.11 110.656,-190.89 219.437,0 111.622,189.1 -111.59,190.9 -219.438,0"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<path
|
||||
id="path3363-6-9-0-1-5-8"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 194.34816,617.68335 13.106,-22.3925 25.99649,0 13.21487,22.60874 -13.21487,22.39125 -25.99649,0 -13.106,-22.60749 z m 40.53761,-24.8925 -28.86524,0 -0.72412,1.23749 -13.106,22.39251 -0.73575,1.25625 0.73087,1.26 13.106,22.60744 0.72263,1.24634 28.86374,0 0.72512,-1.22884 13.215,-22.39119 0.74625,-1.265 -0.74,-1.26751 -13.21537,-22.60875 -0.72313,-1.23874"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523" />
|
||||
<g
|
||||
id="g3365-0-4-1-9-7-5"
|
||||
transform="matrix(0.125,0,0,-0.125,112.08304,959.82207)"
|
||||
style="fill:url(#linearGradient10691-7-8);fill-opacity:1"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523">
|
||||
<g
|
||||
clip-path="url(#clipPath3369-1-5-6-1-0-7)"
|
||||
id="g3367-2-4-2-8-4-3"
|
||||
style="fill:url(#linearGradient10689-4-2);fill-opacity:1">
|
||||
<path
|
||||
id="path3379-4-6-7-6-7-2"
|
||||
style="fill:url(#linearGradient4498-5-7);fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 1131.64,3128.5 -104.95,-181.12 116.38,-200.42 208.05,0.94 112.02,191.63 -112.08,188.97 -219.42,0"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<path
|
||||
id="path3381-6-8-0-0-66-3"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 241.86427,591.39959 12.3925,-21.38999 25.99625,0 13.27125,22.37625 -13.27125,22.7025 -24.56875,0.11 -13.82,-23.79876 z m 39.8125,-23.88999 -28.86125,0 -0.7225,1.24625 -12.3925,21.39 -0.72625,1.255 0.7275,1.25374 13.82,23.79876 0.7275,1.25125 1.44625,-0.006 24.56875,-0.11 1.4275,-0.006 0.72,-1.2325 13.27125,-22.7025 0.7425,-1.27 -0.75125,-1.26625 -13.27125,-22.37625 -0.72625,-1.225"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523" />
|
||||
<g
|
||||
id="g3383-5-5-2-2-3-0"
|
||||
transform="matrix(0.125,0,0,-0.125,112.08304,959.82207)"
|
||||
style="fill:url(#linearGradient10687-2-5);fill-opacity:1"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523">
|
||||
<g
|
||||
clip-path="url(#clipPath3387-3-6-4-2-8-4)"
|
||||
id="g3385-0-6-4-8-0-1"
|
||||
style="fill:url(#linearGradient10685-2-2);fill-opacity:1">
|
||||
<path
|
||||
id="path3397-9-6-1-6-9-7"
|
||||
style="fill:url(#linearGradient4492-8-8);fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 862.109,3289.75 -109.086,-190.45 69.122,-124.42 164.511,-0.47 c 0,0 111.044,188.28 116.564,197.63 7.66,0 43.03,0 43.03,0 l -67.03,117.71 -217.111,0"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<path
|
||||
id="path3399-6-7-3-2-0-1"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 207.64603,572.41959 12.92424,-22.56624 25.68775,0 6.95625,12.21375 -3.94375,0 -14.56837,24.7025 -19.11525,-0.055 -7.94087,-14.295 z m 40.06574,-25.06624 -28.59012,0 -0.71975,1.2575 -12.92537,22.56625 -0.70112,1.22375 0.68512,1.23249 7.94137,14.295 0.71087,1.2825 1.46638,0.004 19.11525,0.055 1.43212,0.004 0.729,-1.23375 13.84375,-23.47249 6.81625,0 -2.12875,-3.7375 -6.95625,-12.21375 -0.71875,-1.2625"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523" />
|
||||
<g
|
||||
transform="matrix(1.25,0,0,-1.25,105.02062,972.84257)"
|
||||
id="g3465-0-8-9"
|
||||
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
|
||||
inkscape:export-xdpi="63.625523"
|
||||
inkscape:export-ydpi="63.625523">
|
||||
<text
|
||||
id="text3467-9-0-8"
|
||||
transform="matrix(1,0,-0.17627963,-1,0,0)"
|
||||
x="116.98372"
|
||||
y="-267.77499"
|
||||
style="font-size:11.81779194px">
|
||||
<tspan
|
||||
sodipodi:role="line"
|
||||
style="font-size:46.39999771px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#49608a;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:Denmark;-inkscape-font-specification:Denmark"
|
||||
x="116.98372"
|
||||
y="-267.77499"
|
||||
id="tspan13239">UTILITY</tspan>
|
||||
<tspan
|
||||
sodipodi:role="line"
|
||||
style="font-size:46.39999771px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#49608a;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:Denmark;-inkscape-font-specification:Denmark"
|
||||
x="116.98372"
|
||||
y="-209.77499"
|
||||
id="tspan11278-3" />
|
||||
</text>
|
||||
<text
|
||||
id="text3471-0-51-2"
|
||||
transform="matrix(0.99235617,0,-0.17763746,-1.0077027,0,0)"
|
||||
style="font-size:38.40000153px"
|
||||
x="112.74373"
|
||||
y="-306.75479">
|
||||
<tspan
|
||||
id="tspan3473-6-0-9"
|
||||
sodipodi:role="line"
|
||||
style="font-size:38.40000153px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#49608a;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:Denmark;-inkscape-font-specification:Denmark"
|
||||
x="112.74373"
|
||||
y="-306.75479">boost</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
d="m 201.43967,613.81579 4.64114,4.2175 3.3738,-3.71306 -0.92817,-0.84354 1.68708,-1.85636 20.53445,20.81026 4.2175,-4.64111 -22.22144,-18.95384 c 0,0 1.69594,-1.83698 2.53062,-2.78454 2.53905,-2.76559 5.98925,-4.72587 5.98925,-4.72587 0,0 -6.03647,0.58224 -8.76507,2.21476 -0.84428,0.92751 -6.75676,7.40649 -6.75676,7.40649 l -0.92819,-0.84355 -3.37382,3.71308"
|
||||
id="path13283"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccccccc" />
|
||||
<g
|
||||
id="g3086"
|
||||
transform="matrix(0.99872217,-0.05053738,0.05053738,0.99872217,-31.539183,11.181538)">
|
||||
<path
|
||||
sodipodi:nodetypes="ccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path13243"
|
||||
d="m 227.74101,611.16418 -15.09943,12.783 2.55659,3.01989 15.09944,-12.78302 c 3.56324,2.16769 7.58975,-1.2411 7.0464,-5.96538 l -4.02652,3.40879 -2.55659,-3.01989 4.02652,-3.40879 c -3.56324,-2.16769 -8.59639,2.0933 -7.04641,5.9654 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path13243-1"
|
||||
d="m 215.25729,626.9851 15.08951,-12.7947 -2.55893,-3.01791 -15.08952,12.79471 c -3.56492,-2.16491 -7.58878,1.24699 -7.04177,5.97085 l 4.02388,-3.41192 2.55892,3.01791 -4.02387,3.41192 c 3.56491,2.16492 8.59476,-2.09997 7.04178,-5.97086 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 20 KiB |
172
doc/string_ref.qbk
Normal file
172
doc/string_ref.qbk
Normal file
@ -0,0 +1,172 @@
|
||||
[/
|
||||
/ Copyright (c) 2012 Marshall Clow
|
||||
/
|
||||
/ 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)
|
||||
/]
|
||||
|
||||
[article String_Ref
|
||||
[quickbook 1.5]
|
||||
[authors [Clow, Marshall]]
|
||||
[copyright 2012 Marshall Clow]
|
||||
[license
|
||||
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 Overview]
|
||||
[/===============]
|
||||
|
||||
Boost.StringRef is an implementation of Jeffrey Yaskin's [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html N3442:
|
||||
string_ref: a non-owning reference to a string].
|
||||
|
||||
When you are parsing/processing strings from some external source, frequently you want to pass a piece of text to a procedure for specialized processing. The canonical way to do this is as a `std::string`, but that has certain drawbacks:
|
||||
|
||||
1) If you are processing a buffer of text (say a HTTP response or the contents of a file), then you have to create the string from the text you want to pass, which involves memory allocation and copying of data.
|
||||
|
||||
2) if a routine receives a constant `std::string` and wants to pass a portion of that string to another routine, then it must create a new string of that substring.
|
||||
|
||||
3) A routine receives a constant `std::string` and wants to return a portion of the string, then it must create a new string to return.
|
||||
|
||||
`string_ref` is designed to solve these efficiency problems. A `string_ref` is a read-only reference to a contiguous sequence of characters, and provides much of the functionality of `std::string`. A `string_ref` is cheap to create, copy and pass by value, because it does not actually own the storage that it points to.
|
||||
|
||||
A `string_ref` is implemented as a small struct that contains a pointer to the start of the character data and a count. A `string_ref` is cheap to create and cheap to copy.
|
||||
|
||||
`string_ref` acts as a container; it includes all the methods that you would expect in a container, including iteration support, `operator []`, `at` and `size`. It can be used with any of the iterator-based algorithms in the STL - as long as you don't need to change the underlying data (`sort` and `remove`, for example, will not work)
|
||||
|
||||
Besides generic container functionality, `string_ref` provides a subset of the interface of `std::string`. This makes it easy to replace parameters of type `const std::string &` with `boost::string_ref`. Like `std::string`, `string_ref` has a static member variable named `npos` to denote the result of failed searches, and to mean "the end".
|
||||
|
||||
Because a `string_ref` does not own the data that it "points to", it introduces lifetime issues into code that uses it. The programmer must ensure that the data that a `string_ref` refers to exists as long as the `string_ref` does.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[/===============]
|
||||
[section Examples]
|
||||
[/===============]
|
||||
|
||||
Integrating `string_ref` into your code is fairly simple. Wherever you pass a `const std::string &` or `std::string` as a parameter, that's a candidate for passing a `boost::string_ref`.
|
||||
|
||||
std::string extract_part ( const std::string &bar ) {
|
||||
return bar.substr ( 2, 3 );
|
||||
}
|
||||
|
||||
if ( extract_part ( "ABCDEFG" ).front() == 'C' ) { /* do something */ }
|
||||
|
||||
Let's figure out what happens in this (contrived) example.
|
||||
|
||||
First, a temporary string is created from the string literal `"ABCDEFG"`, and it is passed (by reference) to the routine `extract_part`. Then a second string is created in the call `std::string::substr` and returned to `extract_part` (this copy may be elided by RVO). Then `extract_part` returns that string back to the caller (again this copy may be elided). The first temporary string is deallocated, and `front` is called on the second string, and then it is deallocated as well.
|
||||
|
||||
Two `std::string`s are created, and two copy operations. That's (potentially) four memory allocations and deallocations, and the associated copying of data.
|
||||
|
||||
Now let's look at the same code with `string_ref`:
|
||||
|
||||
boost::string_ref extract_part ( boost::string_ref bar ) {
|
||||
return bar.substr ( 2, 3 );
|
||||
}
|
||||
|
||||
if ( extract_part ( "ABCDEFG" ).front() == "C" ) { /* do something */ }
|
||||
|
||||
No memory allocations. No copying of character data. No changes to the code other than the types. There are two `string_ref`s created, and two `string_ref`s copied, but those are cheap operations.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[/=================]
|
||||
[section:reference Reference ]
|
||||
[/=================]
|
||||
|
||||
The header file "string_ref.hpp" defines a template `boost::basic_string_ref`, and four specializations - for `char` / `wchar_t` / `char16_t` / `char32_t` .
|
||||
|
||||
`#include <boost/utility/string_ref.hpp>`
|
||||
|
||||
Construction and copying:
|
||||
|
||||
BOOST_CONSTEXPR basic_string_ref (); // Constructs an empty string_ref
|
||||
BOOST_CONSTEXPR basic_string_ref(const charT* str); // Constructs from a NULL-terminated string
|
||||
BOOST_CONSTEXPR basic_string_ref(const charT* str, size_type len); // Constructs from a pointer, length pair
|
||||
template<typename Allocator>
|
||||
basic_string_ref(const std::basic_string<charT, traits, Allocator>& str); // Constructs from a std::string
|
||||
basic_string_ref (const basic_string_ref &rhs);
|
||||
basic_string_ref& operator=(const basic_string_ref &rhs);
|
||||
|
||||
`string_ref` does not define a move constructor nor a move-assignment operator because copying a `string_ref` is just a cheap as moving one.
|
||||
|
||||
Basic container-like functions:
|
||||
|
||||
BOOST_CONSTEXPR size_type size() const ;
|
||||
BOOST_CONSTEXPR size_type length() const ;
|
||||
BOOST_CONSTEXPR size_type max_size() const ;
|
||||
BOOST_CONSTEXPR bool empty() const ;
|
||||
|
||||
// All iterators are const_iterators
|
||||
BOOST_CONSTEXPR const_iterator begin() const ;
|
||||
BOOST_CONSTEXPR const_iterator cbegin() const ;
|
||||
BOOST_CONSTEXPR const_iterator end() const ;
|
||||
BOOST_CONSTEXPR const_iterator cend() const ;
|
||||
const_reverse_iterator rbegin() const ;
|
||||
const_reverse_iterator crbegin() const ;
|
||||
const_reverse_iterator rend() const ;
|
||||
const_reverse_iterator crend() const ;
|
||||
|
||||
Access to the individual elements (all of which are const):
|
||||
|
||||
BOOST_CONSTEXPR const charT& operator[](size_type pos) const ;
|
||||
const charT& at(size_t pos) const ;
|
||||
BOOST_CONSTEXPR const charT& front() const ;
|
||||
BOOST_CONSTEXPR const charT& back() const ;
|
||||
BOOST_CONSTEXPR const charT* data() const ;
|
||||
|
||||
Modifying the `string_ref` (but not the underlying data):
|
||||
|
||||
void clear();
|
||||
void remove_prefix(size_type n);
|
||||
void remove_suffix(size_type n);
|
||||
|
||||
Searching:
|
||||
|
||||
size_type find(basic_string_ref s) const ;
|
||||
size_type find(charT c) const ;
|
||||
size_type rfind(basic_string_ref s) const ;
|
||||
size_type rfind(charT c) const ;
|
||||
size_type find_first_of(charT c) const ;
|
||||
size_type find_last_of (charT c) const ;
|
||||
|
||||
size_type find_first_of(basic_string_ref s) const ;
|
||||
size_type find_last_of(basic_string_ref s) const ;
|
||||
size_type find_first_not_of(basic_string_ref s) const ;
|
||||
size_type find_first_not_of(charT c) const ;
|
||||
size_type find_last_not_of(basic_string_ref s) const ;
|
||||
size_type find_last_not_of(charT c) const ;
|
||||
|
||||
String-like operations:
|
||||
|
||||
BOOST_CONSTEXPR basic_string_ref substr(size_type pos, size_type n=npos) const ; // Creates a new string_ref
|
||||
bool starts_with(charT c) const ;
|
||||
bool starts_with(basic_string_ref x) const ;
|
||||
bool ends_with(charT c) const ;
|
||||
bool ends_with(basic_string_ref x) const ;
|
||||
|
||||
[endsect]
|
||||
|
||||
[/===============]
|
||||
[section History]
|
||||
[/===============]
|
||||
|
||||
[heading boost 1.71]
|
||||
* Glen Fernandes updated the implementation of the stream insertion operator to
|
||||
write directly to the `basic_streambuf` and refactored that functionality into
|
||||
a common utility.
|
||||
|
||||
[heading boost 1.53]
|
||||
* Introduced
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
403
enable_if.html
403
enable_if.html
@ -1,388 +1,15 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<HTML>
|
||||
<HEAD><TITLE>enable_if</TITLE>
|
||||
|
||||
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<META name="GENERATOR" content="Microsoft FrontPage 5.0">
|
||||
</HEAD>
|
||||
<BODY >
|
||||
<!--HEVEA command line is: hevea -nosymb -noiso -pedantic -v enable_if_docs_for_boost.tex -->
|
||||
<!--HTMLHEAD-->
|
||||
<!--ENDHTML-->
|
||||
<!--PREFIX <ARG ></ARG>-->
|
||||
<!--CUT DEF section 1 -->
|
||||
<BR>
|
||||
<BR>
|
||||
|
||||
|
||||
<h1>
|
||||
<img border="0" src="../../boost.png" align="center" width="277" height="86">enable_if</h1>
|
||||
<BR>
|
||||
<BR>
|
||||
Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine.<BR>
|
||||
<BR>
|
||||
<!--TOC section Introduction-->
|
||||
|
||||
<H2><A NAME="htoc1">1</A> Introduction</H2><!--SEC END -->
|
||||
|
||||
<A NAME="introduction"></A>
|
||||
The <TT>enable_if</TT> family of templates is a set of tools to allow a function template or a class template specialization
|
||||
to include or exclude itself from a set of matching functions or specializations
|
||||
based on properties of its template arguments.
|
||||
For example, one can define function templates that
|
||||
are only enabled for, and thus only match, an arbitrary set of types
|
||||
defined by a traits class. The <TT>enable_if</TT> templates can also be
|
||||
applied to enable class template specializations. Applications of
|
||||
<TT>enable_if</TT> are discussed in length
|
||||
in [<A HREF="#jarvi:03:cuj_arbitrary_overloading"><CITE>1</CITE></A>] and [<A HREF="#jarvi:03:c++typeclasses"><CITE>2</CITE></A>].<BR>
|
||||
<BR>
|
||||
<!--TOC subsection Synopsis-->
|
||||
|
||||
<H3><A NAME="htoc2">1.1</A> Synopsis</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:synopsis"></A>
|
||||
<PRE>namespace boost {
|
||||
template <class Cond, class T = void> struct enable_if;
|
||||
template <class Cond, class T = void> struct disable_if;
|
||||
template <class Cond, class T> struct lazy_enable_if;
|
||||
template <class Cond, class T> struct lazy_disable_if;
|
||||
|
||||
template <bool B, class T = void> struct enable_if_c;
|
||||
template <bool B, class T = void> struct disable_if_c;
|
||||
template <bool B, class T> struct lazy_enable_if_c;
|
||||
template <bool B, class T> struct lazy_disable_if_c;
|
||||
}
|
||||
</PRE>
|
||||
<!--TOC subsection Background-->
|
||||
|
||||
<H3><A NAME="htoc3">1.2</A> Background</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:background"></A>
|
||||
Sensible operation of template function overloading in C++ relies
|
||||
on the <EM>SFINAE</EM> (substitution-failure-is-not-an-error)
|
||||
principle [<A HREF="#vandevoorde2002:templates"><CITE>3</CITE></A>]: if an invalid argument
|
||||
or return type is formed during the instantiation of a function
|
||||
template, the instantiation is removed from the overload resolution
|
||||
set instead of causing a compilation error. The following example,
|
||||
taken from [<A HREF="#jarvi:03:cuj_arbitrary_overloading"><CITE>1</CITE></A>],
|
||||
demonstrates why this is important:
|
||||
<PRE>int negate(int i) { return -i; }
|
||||
|
||||
template <class F>
|
||||
typename F::result_type negate(const F& f) { return -f(); }
|
||||
|
||||
</PRE>
|
||||
Suppose the compiler encounters the call <TT>negate(1)</TT>. The first
|
||||
definition is obviously a better match, but the compiler must
|
||||
nevertheless consider (and instantiate the prototypes) of both
|
||||
definitions to find this out. Instantiating the latter definition with
|
||||
<TT>F</TT> as <TT>int</TT> would result in:
|
||||
<PRE>int::result_type negate(const int&);
|
||||
|
||||
</PRE>
|
||||
where the return type is invalid. If this was an error, adding an unrelated function template
|
||||
(that was never called) could break otherwise valid code.
|
||||
Due to the SFINAE principle the above example is not, however, erroneous.
|
||||
The latter definition of <TT>negate</TT> is simply removed from the overload resolution set.<BR>
|
||||
<BR>
|
||||
The <TT>enable_if</TT> templates are tools for controlled creation of the SFINAE
|
||||
conditions.<BR>
|
||||
<BR>
|
||||
<!--TOC section The <TT>enable_if</TT> templates-->
|
||||
|
||||
<H2><A NAME="htoc4">2</A> The <TT>enable_if</TT> templates</H2><!--SEC END -->
|
||||
|
||||
<A NAME="enable_if"></A>
|
||||
The names of the <TT>enable_if</TT> templates have three parts: an optional <TT>lazy_</TT> tag,
|
||||
either <TT>enable_if</TT> or <TT>disable_if</TT>, and an optional <TT>_c</TT> tag.
|
||||
All eight combinations of these parts are supported.
|
||||
The meaning of the <TT>lazy_</TT> tag is described in Section <A HREF="#sec:enable_if_lazy">3.3</A>.
|
||||
The second part of the name indicates whether a true condition argument should
|
||||
enable or disable the current overload.
|
||||
The third part of the name indicates whether the condition argument is a <TT>bool</TT> value
|
||||
(<TT>_c</TT> suffix), or a type containing a static <TT>bool</TT> constant named <TT>value</TT> (no suffix).
|
||||
The latter version interoperates with Boost.MPL. <BR>
|
||||
<BR>
|
||||
The definitions of <TT>enable_if_c</TT> and <TT>enable_if</TT> are as follows (we use <TT>enable_if</TT> templates
|
||||
unqualified but they are in the <TT>boost</TT> namespace).
|
||||
<PRE>template <bool B, class T = void>
|
||||
struct enable_if_c {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct enable_if_c<false, T> {};
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct enable_if : public enable_if_c<Cond::value, T> {};
|
||||
|
||||
</PRE>
|
||||
An instantiation of the <TT>enable_if_c</TT> template with the parameter
|
||||
<TT>B</TT> as <TT>true</TT> contains a member type <TT>type</TT>, defined
|
||||
to be <TT>T</TT>. If <TT>B</TT> is
|
||||
<TT>false</TT>, no such member is defined. Thus
|
||||
<TT>enable_if_c<B, T>::type</TT> is either a valid or an invalid type
|
||||
expression, depending on the value of <TT>B</TT>.
|
||||
When valid, <TT>enable_if_c<B, T>::type</TT> equals <TT>T</TT>.
|
||||
The <TT>enable_if_c</TT> template can thus be used for controlling when functions are considered for
|
||||
overload resolution and when they are not.
|
||||
For example, the following function is defined for all arithmetic types (according to the
|
||||
classification of the <A HREF="../type_traits/index.html">Boost type_traits library</A>):
|
||||
<PRE>template <class T>
|
||||
typename enable_if_c<boost::is_arithmetic<T>::value, T>::type
|
||||
foo(T t) { return t; }
|
||||
|
||||
</PRE>
|
||||
The <TT>disable_if_c</TT> template is provided as well, and has the
|
||||
same functionality as <TT>enable_if_c</TT> except for the negated condition. The following
|
||||
function is enabled for all non-arithmetic types.
|
||||
<PRE>template <class T>
|
||||
typename disable_if_c<boost::is_arithmetic<T>::value, T>::type
|
||||
bar(T t) { return t; }
|
||||
|
||||
</PRE>
|
||||
For easier syntax in some cases and interoperation with Boost.MPL we provide versions of
|
||||
the <TT>enable_if</TT> templates taking any type with a <TT>bool</TT> member constant named
|
||||
<TT>value</TT> as the condition argument.
|
||||
The MPL <TT>bool_</TT>, <TT>and_</TT>, <TT>or_</TT>, and <TT>not_</TT> templates are likely to be
|
||||
useful for creating such types. Also, the traits classes in the Boost.Type_traits library
|
||||
follow this convention.
|
||||
For example, the above example function <TT>foo</TT> can be alternatively written as:
|
||||
<PRE>template <class T>
|
||||
typename enable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t) { return t; }
|
||||
|
||||
</PRE>
|
||||
<!--TOC section Using <TT>enable_if</TT>-->
|
||||
|
||||
<H2><A NAME="htoc5">3</A> Using <TT>enable_if</TT></H2><!--SEC END -->
|
||||
|
||||
<A NAME="sec:using_enable_if"></A>
|
||||
The <TT>enable_if</TT> templates are defined in
|
||||
<TT>boost/utility/enable_if.hpp</TT>, which is included by <TT>boost/utility.hpp</TT>.<BR>
|
||||
<BR>
|
||||
The <TT>enable_if</TT> template can be used either as the return type, or as an
|
||||
extra argument. For example, the <TT>foo</TT> function in the previous section could also be written
|
||||
as:
|
||||
<PRE>template <class T>
|
||||
T foo(T t, typename enable_if<boost::is_arithmetic<T> >::type* dummy = 0);
|
||||
|
||||
</PRE>Hence, an extra parameter of type <TT>void*</TT> is added, but it is given
|
||||
a default value to keep the parameter hidden from client code.
|
||||
Note that the second template argument was not given to <TT>enable_if</TT>, as the default
|
||||
<TT>void</TT> gives the desired behavior.<BR>
|
||||
<BR>
|
||||
Whether to write the enabler as an argument or within the return type is
|
||||
largely a matter of taste, but for certain functions, only one
|
||||
alternative is possible:
|
||||
<UL><LI>
|
||||
Operators have a fixed number of arguments, thus <TT>enable_if</TT> must be used in the return type.
|
||||
<LI>Constructors and destructors do not have a return type; an extra argument is the only option.
|
||||
<LI>There does not seem to be a way to specify an enabler for a conversion operator. Converting constructors,
|
||||
however, can have enablers as extra default arguments.
|
||||
</UL>
|
||||
<!--TOC subsection Enabling template class specializations-->
|
||||
|
||||
<H3><A NAME="htoc6">3.1</A> Enabling template class specializations</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:enable_if_classes"></A>
|
||||
Class template specializations can be enabled or disabled with <TT>enable_if</TT>.
|
||||
One extra template parameter needs to be added for the enabler expressions.
|
||||
This parameter has the default value <TT>void</TT>.
|
||||
For example:
|
||||
<PRE>template <class T, class Enable = void>
|
||||
class A { ... };
|
||||
|
||||
template <class T>
|
||||
class A<T, typename enable_if<is_integral<T> >::type> { ... };
|
||||
|
||||
template <class T>
|
||||
class A<T, typename enable_if<is_float<T> >::type> { ... };
|
||||
|
||||
</PRE>Instantiating <TT>A</TT> with any integral type matches the first specialization,
|
||||
whereas any floating point type matches the second one. All other types
|
||||
match the primary template.
|
||||
The condition can be any compile-time boolean expression that depends on the
|
||||
template arguments of the class.
|
||||
Note that again, the second argument to <TT>enable_if</TT> is not needed; the default (<TT>void</TT>)
|
||||
is the correct value.<BR>
|
||||
<BR>
|
||||
<!--TOC subsection Overlapping enabler conditions-->
|
||||
|
||||
<H3><A NAME="htoc7">3.2</A> Overlapping enabler conditions</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:overlapping_conditions"></A>
|
||||
Once the compiler has examined the enabling conditions and included the
|
||||
function into the overload resolution set, normal C++ overload resolution
|
||||
rules are used to select the best matching function.
|
||||
In particular, there is no ordering between enabling conditions.
|
||||
Function templates with enabling conditions that are not mutually exclusive can
|
||||
lead to ambiguities. For example:
|
||||
<PRE>template <class T>
|
||||
typename enable_if<boost::is_integral<T>, void>::type
|
||||
foo(T t) {}
|
||||
|
||||
template <class T>
|
||||
typename enable_if<boost::is_arithmetic<T>, void>::type
|
||||
foo(T t) {}
|
||||
|
||||
</PRE>
|
||||
All integral types are also arithmetic. Therefore, say, for the call <TT>foo(1)</TT>,
|
||||
both conditions are true and both functions are thus in the overload resolution set.
|
||||
They are both equally good matches and thus ambiguous.
|
||||
Of course, more than one enabling condition can be simultaneously true as long as
|
||||
other arguments disambiguate the functions.<BR>
|
||||
<BR>
|
||||
The above discussion applies to using <TT>enable_if</TT> in class template
|
||||
partial specializations as well.<BR>
|
||||
<BR>
|
||||
<!--TOC subsection Lazy <TT>enable_if</TT>-->
|
||||
|
||||
<H3><A NAME="htoc8">3.3</A> Lazy <TT>enable_if</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:enable_if_lazy"></A>
|
||||
In some cases it is necessary to avoid instantiating part of a
|
||||
function signature unless an enabling condition is true. For example:
|
||||
<PRE>template <class T, class U> class mult_traits;
|
||||
|
||||
template <class T, class U>
|
||||
typename enable_if<is_multipliable<T, U>, typename mult_traits<T, U>::type>::type
|
||||
operator*(const T& t, const U& u) { ... }
|
||||
|
||||
</PRE>Assume the class template <TT>mult_traits</TT> is a traits class defining
|
||||
the resulting type of a multiplication operator. The <TT>is_multipliable</TT> traits
|
||||
class specifies for which types to enable the operator. Whenever
|
||||
<TT>is_multipliable<A, B>::value</TT> is <TT>true</TT> for some types <TT>A</TT> and <TT>B</TT>,
|
||||
then <TT>mult_traits<A, B>::type</TT> is defined.<BR>
|
||||
<BR>
|
||||
Now, trying to invoke (some other overload) of <TT>operator*</TT> with, say, operand types <TT>C</TT> and <TT>D</TT>
|
||||
for which <TT>is_multipliable<C, D>::value</TT> is <TT>false</TT>
|
||||
and <TT>mult_traits<C, D>::type</TT> is not defined is an error on some compilers.
|
||||
The SFINAE principle is not applied because
|
||||
the invalid type occurs as an argument to another template. The <TT>lazy_enable_if</TT>
|
||||
and <TT>lazy_disable_if</TT> templates (and their <TT>_c</TT> versions) can be used in such
|
||||
situations:
|
||||
<PRE>template<class T, class U>
|
||||
typename lazy_enable_if<is_multipliable<T, U>, mult_traits<T, U> >::type
|
||||
operator*(const T& t, const U& u) { ... }
|
||||
|
||||
</PRE>The second argument of <TT>lazy_enable_if</TT> must be a class type
|
||||
that defines a nested type named <TT>type</TT> whenever the first
|
||||
parameter (the condition) is true.<BR>
|
||||
<BR>
|
||||
<!--TOC paragraph Note-->
|
||||
|
||||
<H5>Note</H5><!--SEC END -->
|
||||
|
||||
Referring to one member type or static constant in a traits class
|
||||
causes all of the members (type and static constant) of that
|
||||
specialization to be instantiated. Therefore, if your traits classes
|
||||
can sometimes contain invalid types, you should use two distinct
|
||||
templates for describing the conditions and the type mappings. In the
|
||||
above example, <TT>is_multipliable<T, U>::value</TT> defines when
|
||||
<TT>mult_traits<T, U>::type</TT> is valid.<BR>
|
||||
<BR>
|
||||
<!--TOC subsection Compiler workarounds-->
|
||||
|
||||
<H3><A NAME="htoc9">3.4</A> Compiler workarounds</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:workarounds"></A>
|
||||
Some compilers flag functions as ambiguous if the only distinguishing factor is a different
|
||||
condition in an enabler (even though the functions could never be ambiguous). For example,
|
||||
some compilers (e.g. GCC 3.2) diagnose the following two functions as ambiguous:
|
||||
<PRE>template <class T>
|
||||
typename enable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t);
|
||||
|
||||
template <class T>
|
||||
typename disable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t);
|
||||
|
||||
</PRE>Two workarounds can be applied:
|
||||
<UL><LI>
|
||||
Use an extra dummy parameter which disambiguates the functions. Use a default value for
|
||||
it to hide the parameter from the caller. For example:
|
||||
<PRE>template <int> struct dummy { dummy(int) {} };
|
||||
|
||||
template <class T>
|
||||
typename enable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t, dummy<0> = 0);
|
||||
|
||||
template <class T>
|
||||
typename disable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t, dummy<1> = 0);
|
||||
</PRE><BR>
|
||||
<BR>
|
||||
<LI>Define the functions in different namespaces and bring them into a common
|
||||
namespace with <TT>using</TT> declarations:
|
||||
<PRE>namespace A {
|
||||
template <class T>
|
||||
typename enable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t);
|
||||
}
|
||||
|
||||
namespace B {
|
||||
template <class T>
|
||||
typename disable_if<boost::is_arithmetic<T>, T>::type
|
||||
foo(T t);
|
||||
}
|
||||
|
||||
using A::foo;
|
||||
using B::foo;
|
||||
|
||||
</PRE>
|
||||
Note that the second workaround above cannot be used for member
|
||||
templates. On the other hand, operators do not accept extra arguments,
|
||||
which makes the first workaround unusable. As the net effect,
|
||||
neither of the workarounds are of assistance for templated operators that
|
||||
need to be defined as member functions (assignment and
|
||||
subscript operators).
|
||||
</UL>
|
||||
<!--TOC section Acknowledgements-->
|
||||
|
||||
<H2><A NAME="htoc10">4</A> Acknowledgements</H2><!--SEC END -->
|
||||
|
||||
We are grateful to Howard Hinnant, Jason Shirk, Paul Mensonides, and Richard
|
||||
Smith whose findings have influenced the library.<BR>
|
||||
<BR>
|
||||
<!--TOC section References-->
|
||||
|
||||
<H2>References</H2><!--SEC END -->
|
||||
<DL COMPACT=compact><DT><A NAME="jarvi:03:cuj_arbitrary_overloading"><FONT COLOR=purple>[1]</FONT></A><DD>
|
||||
Jaakko Järvi, Jeremiah Willcock, Howard Hinnant, and Andrew Lumsdaine.
|
||||
Function overloading based on arbitrary properties of types.
|
||||
<EM>C/C++ Users Journal</EM>, 21(6):25--32, June 2003.<BR>
|
||||
<BR>
|
||||
<DT><A NAME="jarvi:03:c++typeclasses"><FONT COLOR=purple>[2]</FONT></A><DD>
|
||||
Jaakko Järvi, Jeremiah Willcock, and Andrew Lumsdaine.
|
||||
Concept-controlled polymorphism.
|
||||
In Frank Pfennig and Yannis Smaragdakis, editors, <EM>Generative
|
||||
Programming and Component Engineering</EM>, volume 2830 of <EM>LNCS</EM>, pages
|
||||
228--244. Springer Verlag, September 2003.<BR>
|
||||
<BR>
|
||||
<DT><A NAME="vandevoorde2002:templates"><FONT COLOR=purple>[3]</FONT></A><DD>
|
||||
David Vandevoorde and Nicolai M. Josuttis.
|
||||
<EM>C++ Templates: The Complete Guide</EM>.
|
||||
Addison-Wesley, 2002.</DL>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<B>Contributed by:</B> <BR>
|
||||
Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine<BR>
|
||||
<EM>{jajarvi|jewillco|lums}@osl.iu.edu</EM><BR>
|
||||
Indiana University<BR>
|
||||
Open Systems Lab
|
||||
<!--HTMLFOOT-->
|
||||
<!--ENDHTML-->
|
||||
<!--FOOTER-->
|
||||
<HR SIZE=2>
|
||||
<BLOCKQUOTE><EM>This document was translated from L<sup>A</sup>T<sub>E</sub>X by
|
||||
</EM><A HREF="http://pauillac.inria.fr/~maranget/hevea/index.html"><EM>H<FONT SIZE=2><sup>E</sup></FONT>V<FONT SIZE=2><sup>E</sup></FONT>A</EM></A><EM>.
|
||||
</EM></BLOCKQUOTE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv=refresh content="0; URL=../core/doc/html/core/enable_if.html">
|
||||
<title>Automatic redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../core/doc/html/core/enable_if.html">enable_if.html</a>. <hr>
|
||||
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,23 +0,0 @@
|
||||
# Copyright David Abrahams 2003.
|
||||
# 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)
|
||||
|
||||
# For more information, see http://www.boost.org/
|
||||
|
||||
project
|
||||
: requirements <library>/boost/test//boost_test_exec_monitor
|
||||
;
|
||||
|
||||
test-suite utility/enable_if
|
||||
:
|
||||
[ run constructors.cpp ]
|
||||
[ run dummy_arg_disambiguation.cpp ]
|
||||
[ run lazy.cpp ]
|
||||
[ run lazy_test.cpp ]
|
||||
[ run member_templates.cpp ]
|
||||
[ run namespace_disambiguation.cpp ]
|
||||
[ run no_disambiguation.cpp ]
|
||||
[ run partial_specializations.cpp ]
|
||||
;
|
||||
|
@ -1,62 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
struct container {
|
||||
bool my_value;
|
||||
|
||||
template <class T>
|
||||
container(const T&, const typename enable_if<is_arithmetic<T>, T>::type * = 0):
|
||||
my_value(true) {}
|
||||
|
||||
template <class T>
|
||||
container(const T&, const typename disable_if<is_arithmetic<T>, T>::type * = 0):
|
||||
my_value(false) {}
|
||||
};
|
||||
|
||||
// example from Howard Hinnant (tests enable_if template members of a templated class)
|
||||
template <class charT>
|
||||
struct xstring
|
||||
{
|
||||
template <class It>
|
||||
xstring(It begin, It end, typename
|
||||
disable_if<is_arithmetic<It> >::type* = 0)
|
||||
: data(end-begin) {}
|
||||
|
||||
int data;
|
||||
};
|
||||
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
BOOST_CHECK(container(1).my_value);
|
||||
BOOST_CHECK(container(1.0).my_value);
|
||||
|
||||
BOOST_CHECK(!container("1").my_value);
|
||||
BOOST_CHECK(!container(static_cast<void*>(0)).my_value);
|
||||
|
||||
char sa[] = "123456";
|
||||
BOOST_CHECK(xstring<char>(sa, sa+6).data == 6);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
template <int N> struct dummy {
|
||||
dummy(int) {};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t, dummy<0> = 0) { return true; }
|
||||
|
||||
template<class T>
|
||||
typename disable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t, dummy<1> = 0) { return false; }
|
||||
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
BOOST_CHECK(arithmetic_object(1));
|
||||
BOOST_CHECK(arithmetic_object(1.0));
|
||||
|
||||
BOOST_CHECK(!arithmetic_object("1"));
|
||||
BOOST_CHECK(!arithmetic_object(static_cast<void*>(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,82 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
using boost::enable_if_c;
|
||||
using boost::lazy_enable_if_c;
|
||||
|
||||
// This class provides a reduced example of a traits class for
|
||||
// computing the result of multiplying two types. The member typedef
|
||||
// 'type' in this traits class defines the return type of this
|
||||
// operator. The return type member is invalid unless both arguments
|
||||
// for mult_traits are values that mult_traits expects (ints in this
|
||||
// case). This kind of situation may arise if a traits class only
|
||||
// makes sense for some set of types, not all C++ types.
|
||||
|
||||
template <class T> struct is_int {
|
||||
BOOST_STATIC_CONSTANT(bool, value = (boost::is_same<T, int>::value));
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
struct mult_traits {
|
||||
typedef typename T::does_not_exist type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct mult_traits<int, int> {
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
|
||||
// Next, a forwarding function mult() is defined. It is enabled only
|
||||
// when both arguments are of type int. The first version, using
|
||||
// non-lazy enable_if_c does not work.
|
||||
|
||||
#if 0
|
||||
template <class T, class U>
|
||||
typename enable_if_c<
|
||||
is_int<T>::value && is_int<U>::value,
|
||||
typename mult_traits<T, U>::type
|
||||
>::type
|
||||
mult(const T& x, const U& y) {return x * y;}
|
||||
#endif
|
||||
|
||||
// A correct version uses lazy_enable_if_c.
|
||||
// This template removes compiler errors from invalid code used as an
|
||||
// argument to enable_if_c.
|
||||
|
||||
#if 1
|
||||
template <class T, class U>
|
||||
typename lazy_enable_if_c<
|
||||
is_int<T>::value & is_int<U>::value,
|
||||
mult_traits<T, U>
|
||||
>::type
|
||||
mult(const T& x, const U& y) {return x * y;}
|
||||
#endif
|
||||
|
||||
double mult(int i, double d) { return (double)i * d; }
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
|
||||
BOOST_CHECK(mult(1, 2) == 2);
|
||||
|
||||
BOOST_CHECK(mult(1, 3.0) == 3.0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,100 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
// Testing all variations of lazy_enable_if.
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
using boost::lazy_enable_if;
|
||||
using boost::lazy_disable_if;
|
||||
|
||||
using boost::lazy_enable_if_c;
|
||||
using boost::lazy_disable_if_c;
|
||||
|
||||
|
||||
template <class T>
|
||||
struct is_int_or_double {
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
value = (boost::is_same<T, int>::value ||
|
||||
boost::is_same<T, double>::value));
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct some_traits {
|
||||
typedef typename T::does_not_exist type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct some_traits<int> {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct some_traits<double> {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct make_bool {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_bool<int> {};
|
||||
|
||||
template <>
|
||||
struct make_bool<double> {};
|
||||
|
||||
namespace A {
|
||||
|
||||
template<class T>
|
||||
typename lazy_enable_if<is_int_or_double<T>, some_traits<T> >::type
|
||||
foo(T t) { return true; }
|
||||
|
||||
template<class T>
|
||||
typename lazy_enable_if_c<is_int_or_double<T>::value, some_traits<T> >::type
|
||||
foo2(T t) { return true; }
|
||||
}
|
||||
|
||||
namespace B {
|
||||
template<class T>
|
||||
typename lazy_disable_if<is_int_or_double<T>, make_bool<T> >::type
|
||||
foo(T t) { return false; }
|
||||
|
||||
template<class T>
|
||||
typename lazy_disable_if_c<is_int_or_double<T>::value, make_bool<T> >::type
|
||||
foo2(T t) { return false; }
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
using namespace A;
|
||||
using namespace B;
|
||||
BOOST_CHECK(foo(1));
|
||||
BOOST_CHECK(foo(1.0));
|
||||
|
||||
BOOST_CHECK(!foo("1"));
|
||||
BOOST_CHECK(!foo(static_cast<void*>(0)));
|
||||
|
||||
BOOST_CHECK(foo2(1));
|
||||
BOOST_CHECK(foo2(1.0));
|
||||
|
||||
BOOST_CHECK(!foo2("1"));
|
||||
BOOST_CHECK(!foo2(static_cast<void*>(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
struct container {
|
||||
template <class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(const T&, const int* /* disambiguate */ = 0) {return true;}
|
||||
|
||||
template <class T>
|
||||
typename disable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(const T&) {return false;}
|
||||
};
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
BOOST_CHECK(container().arithmetic_object(1));
|
||||
BOOST_CHECK(container().arithmetic_object(1.0));
|
||||
|
||||
BOOST_CHECK(!container().arithmetic_object("1"));
|
||||
BOOST_CHECK(!container().arithmetic_object(static_cast<void*>(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::mpl::not_;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
namespace A {
|
||||
template<class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t) { return true; }
|
||||
}
|
||||
|
||||
namespace B {
|
||||
template<class T>
|
||||
typename enable_if<not_<is_arithmetic<T> >, bool>::type
|
||||
arithmetic_object(T t) { return false; }
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
using namespace A;
|
||||
using namespace B;
|
||||
BOOST_CHECK(arithmetic_object(1));
|
||||
BOOST_CHECK(arithmetic_object(1.0));
|
||||
|
||||
BOOST_CHECK(!arithmetic_object("1"));
|
||||
BOOST_CHECK(!arithmetic_object(static_cast<void*>(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
using boost::mpl::not_;
|
||||
using boost::enable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
template<class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t) { return true; }
|
||||
|
||||
template<class T>
|
||||
typename enable_if<not_<is_arithmetic<T> >, bool>::type
|
||||
arithmetic_object(T t) { return false; }
|
||||
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
BOOST_CHECK(arithmetic_object(1));
|
||||
BOOST_CHECK(arithmetic_object(1.0));
|
||||
|
||||
BOOST_CHECK(!arithmetic_object("1"));
|
||||
BOOST_CHECK(!arithmetic_object(static_cast<void*>(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
using boost::enable_if_c;
|
||||
using boost::disable_if_c;
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
template <class T, class Enable = void>
|
||||
struct tester;
|
||||
|
||||
template <class T>
|
||||
struct tester<T, typename enable_if_c<is_arithmetic<T>::value>::type> {
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct tester<T, typename disable_if_c<is_arithmetic<T>::value>::type> {
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
template <class T, class Enable = void>
|
||||
struct tester2;
|
||||
|
||||
template <class T>
|
||||
struct tester2<T, typename enable_if<is_arithmetic<T> >::type> {
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct tester2<T, typename disable_if<is_arithmetic<T> >::type> {
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
BOOST_CHECK(tester<int>::value);
|
||||
BOOST_CHECK(tester<double>::value);
|
||||
|
||||
BOOST_CHECK(!tester<char*>::value);
|
||||
BOOST_CHECK(!tester<void*>::value);
|
||||
|
||||
BOOST_CHECK(tester2<int>::value);
|
||||
BOOST_CHECK(tester2<double>::value);
|
||||
|
||||
BOOST_CHECK(!tester2<char*>::value);
|
||||
BOOST_CHECK(!tester2<void*>::value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,163 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||||
|
||||
<title>Generator Iterator Adaptor Documentation</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
<img src="../../boost.png" alt="boost.png (6897 bytes)" align="middle"
|
||||
width="277" height="86">
|
||||
|
||||
<h1>Generator Iterator Adaptor</h1>
|
||||
|
||||
<p>Defined in header <a href=
|
||||
"../../boost/generator_iterator.hpp">boost/generator_iterator.hpp</a></p>
|
||||
|
||||
<p>The generator iterator adaptor makes it easier to create custom input
|
||||
iterators from 0-ary functions and function objects. The adaptor takes a
|
||||
<a href="http://www.sgi.com/tech/stl/Generator.html">Generator</a> and
|
||||
creates a model of <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>. Each
|
||||
increment retrieves an item from the generator and makes it available to be
|
||||
retrieved by dereferencing. The motivation for this iterator is that some
|
||||
concepts can be more naturally expressed as a generator, while most STL
|
||||
algorithms expect an iterator. An example is the <a href=
|
||||
"../random/index.html">Random Number</a> library.</p>
|
||||
|
||||
<h2>Synopsis</h2>
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
namespace boost {
|
||||
template <class Generator>
|
||||
class generator_iterator_policies;
|
||||
|
||||
template <class Generator>
|
||||
class generator_iterator_generator;
|
||||
|
||||
template <class Generator>
|
||||
typename generator_iterator_generator<Generator>::type
|
||||
make_generator_iterator(Generator & gen);
|
||||
}
|
||||
</pre>
|
||||
</blockquote>
|
||||
<hr>
|
||||
|
||||
<h2>The Generator Iterator Generator Class</h2>
|
||||
|
||||
<p>The class generator_iterator_generator is a helper class whose purpose
|
||||
is to construct a generator iterator type. The template parameter for this
|
||||
class is the Generator function object type that is being wrapped. The
|
||||
generator iterator adaptor only holds a reference (or pointer) to the
|
||||
function object, therefore the function object must outlive the generator
|
||||
iterator adaptor constructed from it.</p>
|
||||
<pre>
|
||||
template <class Generator>
|
||||
class generator_iterator_generator
|
||||
{
|
||||
public:
|
||||
typedef <i>unspecified</i> type; // the resulting generator iterator type
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3>Template Parameters</h3>
|
||||
|
||||
<table border summary="">
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt><a href=
|
||||
"http://www.sgi.com/tech/stl/Generator.html">Generator</a></tt></td>
|
||||
|
||||
<td>The generator (0-ary function object) type being wrapped. The
|
||||
return type of the function must be defined as
|
||||
<tt>Generator::result_type</tt>. The function object must be a model of
|
||||
<a href=
|
||||
"http://www.sgi.com/tech/stl/Generator.html">Generator</a>.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Concept Model</h3>
|
||||
|
||||
<p>The generator iterator class is a model of <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.</p>
|
||||
|
||||
<h3>Members</h3>
|
||||
|
||||
<p>The generator iterator implements the member functions and operators
|
||||
required of the <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
|
||||
concept.<br></p>
|
||||
<hr>
|
||||
|
||||
<h2><a name="make_generator_iterator" id="make_generator_iterator">The
|
||||
Generator Iterator Object Generator</a></h2>
|
||||
|
||||
<p>The <tt>make_generator_iterator()</tt> function provides a convenient
|
||||
way to create generator iterator objects. The function saves the user the
|
||||
trouble of explicitly writing out the iterator types.</p>
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
template <class Generator>
|
||||
typename generator_iterator_generator<Generator>::type
|
||||
make_generator_iterator(Generator & gen);
|
||||
</pre>
|
||||
</blockquote>
|
||||
<hr>
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<p>The following program shows how <code>generator_iterator</code>
|
||||
transforms a generator into an input iterator.</p>
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
#include <iostream>
|
||||
#include <boost/generator_iterator.hpp>
|
||||
|
||||
class my_generator
|
||||
{
|
||||
public:
|
||||
typedef int result_type;
|
||||
my_generator() : state(0) { }
|
||||
int operator()() { return ++state; }
|
||||
private:
|
||||
int state;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
my_generator gen;
|
||||
boost::generator_iterator_generator<my_generator>::type it = boost::make_generator_iterator(gen);
|
||||
for(int i = 0; i < 10; ++i, ++it)
|
||||
std::cout << *it << std::endl;
|
||||
}
|
||||
</pre>
|
||||
</blockquote>
|
||||
<hr>
|
||||
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||
height="31" width="88"></a></p>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
|
||||
|
||||
<p><i>Copyright © 2001 <a href=
|
||||
"../../people/jens_maurer.htm">Jens Maurer</a></i></p>
|
||||
|
||||
<p><i>Distributed under the Boost Software License, Version 1.0. (See
|
||||
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||
copy at <a href=
|
||||
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
|
||||
</body>
|
||||
</html>
|
44
identity_type/doc/Jamfile.v2
Normal file
44
identity_type/doc/Jamfile.v2
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
# Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
# Distributed under the Boost Software License, Version 1.0
|
||||
# (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
# Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
import quickbook ;
|
||||
using boostbook ;
|
||||
|
||||
doxygen reference : ../../../../boost/utility/identity_type.hpp
|
||||
: <reftitle>"Reference"
|
||||
<doxygen:param>PREDEFINED="DOXYGEN"
|
||||
<doxygen:param>QUIET=YES
|
||||
<doxygen:param>WARN_IF_UNDOCUMENTED=NO
|
||||
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
|
||||
<doxygen:param>HIDE_UNDOC_CLASSES=YES
|
||||
<doxygen:param>ALIASES=" Params=\"<b>Parameters:</b> <table border="0">\" Param{2}=\"<tr><td><b><tt>\\1</tt></b></td><td>\\2</td></tr>\" EndParams=\"</table>\" Returns=\"<b>Returns:</b>\" Note=\"<b>Note:</b>\" Warning=\"<b>Warning:</b>\" See=\"<b>See:</b>\" RefSect{2}=\"\\xmlonly<link linkend='boost_utility_identitytype.\\1'>\\2</link>\\endxmlonly\" RefClass{1}=\"\\xmlonly<computeroutput><classname alt='\\1'>\\1</classname></computeroutput>\\endxmlonly\" RefFunc{1}=\"\\xmlonly<computeroutput><functionname alt='\\1'>\\1</functionname></computeroutput>\\endxmlonly\" RefMacro{1}=\"\\xmlonly<computeroutput><macroname alt='\\1'>\\1</macroname></computeroutput>\\endxmlonly\" "
|
||||
;
|
||||
|
||||
# This target must be called "index" so to generate "index.html" file.
|
||||
xml index : identity_type.qbk : <dependency>reference ;
|
||||
|
||||
boostbook doc : index
|
||||
: <location>html
|
||||
<format>onehtml
|
||||
<xsl:param>toc.section.depth=0
|
||||
<xsl:param>html.stylesheet=../../../../../doc/src/boostbook.css
|
||||
<xsl:param>boost.root=../../../../..
|
||||
;
|
||||
|
||||
#
|
||||
# This is very imperfect - it results in both html and pdf docs being built,
|
||||
# for some reason I can't get the "onehtml" format specified above to play nice
|
||||
# with the usual incantations for mixed pdf/html builds. JM 06/2012.
|
||||
#
|
||||
boostbook pdf_doc : index
|
||||
:
|
||||
<format>pdf
|
||||
<format>html:<build>no
|
||||
;
|
||||
|
||||
install pdf_doc_install : pdf_doc : <location>. <name>identity_type.pdf <install-type>PDF ;
|
||||
explicit pdf_doc_install ;
|
252
identity_type/doc/html/index.html
Normal file
252
identity_type/doc/html/index.html
Normal file
@ -0,0 +1,252 @@
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Boost.Utility/IdentityType 1.0.0</title><link rel="stylesheet" type="text/css" href="../../../../../doc/src/boostbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" title="Boost.Utility/IdentityType 1.0.0"><div class="titlepage"><div><div><h2 class="title"><a name="boost_utility_identitytype"></a>Boost.Utility/IdentityType 1.0.0</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Lorenzo</span> <span class="surname">Caminiti <code class="email"><<a class="email" href="mailto:lorcaminiti@gmail.com">lorcaminiti@gmail.com</a>></code></span></h3></div></div><div><p class="copyright">Copyright © 2009-2012 Lorenzo
|
||||
Caminiti</p></div><div><div class="legalnotice" title="Legal Notice"><a name="boost_utility_identitytype.legal"></a><p>
|
||||
Distributed under the Boost Software License, Version 1.0 (see accompanying
|
||||
file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p></div></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#boost_utility_identitytype.motivation">Motivation</a></span></dt><dt><span class="section"><a href="#boost_utility_identitytype.solution">Solution</a></span></dt><dt><span class="section"><a href="#boost_utility_identitytype.templates">Templates</a></span></dt><dt><span class="section"><a href="#boost_utility_identitytype.abstract_types">Abstract Types</a></span></dt><dt><span class="section"><a href="#boost_utility_identitytype.annex__usage">Annex: Usage</a></span></dt><dt><span class="section"><a href="#boost_utility_identitytype.annex__implementation">Annex:
|
||||
Implementation</a></span></dt><dt><span class="section"><a href="#reference">Reference</a></span></dt></dl></div><p>
|
||||
This library allows to wrap types within round parenthesis so they can always
|
||||
be passed as macro parameters.
|
||||
</p><div class="section boost_utility_identitytype_motivation" title="Motivation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="boost_utility_identitytype.motivation"></a><a class="link" href="#boost_utility_identitytype.motivation" title="Motivation">Motivation</a></h2></div></div></div><p>
|
||||
Consider the following macro which declares a variable named <code class="computeroutput"><span class="identifier">var</span></code><code class="literal"><span class="emphasis"><em>n</em></span></code>
|
||||
with the specified <code class="literal"><span class="emphasis"><em>type</em></span></code> (see also
|
||||
<a href="../../test/var_error.cpp" target="_top"><code class="literal">var_error.cpp</code></a>):
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">VAR</span><span class="special">(</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">n</span><span class="special">)</span> <span class="identifier">type</span> <span class="identifier">var</span> <span class="error">#</span><span class="preprocessor"># n</span>
|
||||
|
||||
<span class="identifier">VAR</span><span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span> <span class="comment">// OK.</span>
|
||||
<span class="identifier">VAR</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">>,</span> <span class="number">2</span><span class="special">);</span> <span class="comment">// Error.</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
The first macro invocation works correctly declaring a variable named <code class="computeroutput"><span class="identifier">var1</span></code> of type <code class="computeroutput"><span class="keyword">int</span></code>.
|
||||
However, the second macro invocation fails generating a preprocessor error
|
||||
similar to the following:
|
||||
</p><pre class="programlisting">error: macro "VAR" passed 3 arguments, but takes just 2
|
||||
</pre><p>
|
||||
That is because the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> type passed as the first macro parameter
|
||||
contains a comma <code class="computeroutput"><span class="special">,</span></code> not wrapped
|
||||
by round parenthesis <code class="computeroutput"><span class="special">()</span></code>. The preprocessor
|
||||
interprets that unwrapped comma as a separation between macro parameters concluding
|
||||
that a total of three (and not two) parameters are passed to the macro in the
|
||||
following order:
|
||||
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
||||
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span></code>
|
||||
</li><li class="listitem">
|
||||
<code class="computeroutput"><span class="keyword">char</span><span class="special">></span></code>
|
||||
</li><li class="listitem">
|
||||
<code class="computeroutput"><span class="number">2</span></code>
|
||||
</li></ol></div><p>
|
||||
Note that, differently from the compiler, the preprocessor only recognizes
|
||||
round parenthesis <code class="computeroutput"><span class="special">()</span></code>. Angular
|
||||
<code class="computeroutput"><span class="special"><></span></code> and squared <code class="computeroutput"><span class="special">[]</span></code> parenthesis are not recognized by the preprocessor
|
||||
when parsing macro parameters.
|
||||
</p></div><div class="section boost_utility_identitytype_solution" title="Solution"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="boost_utility_identitytype.solution"></a><a class="link" href="#boost_utility_identitytype.solution" title="Solution">Solution</a></h2></div></div></div><p>
|
||||
In some cases, it might be possible to workaround this issue by avoiding to
|
||||
pass the type expression to the macro all together. For example, in the case
|
||||
above a <code class="computeroutput"><span class="keyword">typedef</span></code> could have been
|
||||
used to specify the type expression with the commas outside the macro (see
|
||||
also <a href="../../test/var.cpp" target="_top"><code class="literal">var.cpp</code></a>):
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">></span> <span class="identifier">map_type</span><span class="special">;</span>
|
||||
<span class="identifier">VAR</span><span class="special">(</span><span class="identifier">map_type</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// OK.</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
When this is neither possible nor desired (e.g., see the function template
|
||||
<code class="computeroutput"><span class="identifier">f</span></code> in the section below), this
|
||||
library header <code class="computeroutput"><a class="link" href="#header.boost.utility.identity_type_hpp" title="Header <boost/utility/identity_type.hpp>">boost/utility/identity_type.hpp</a></code>
|
||||
defines a macro <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
|
||||
which can be used to workaround the issue while keeping the type expression
|
||||
as one of the macro parameters (see also <a href="../../test/var.cpp" target="_top"><code class="literal">var.cpp</code></a>).
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">/</span><span class="identifier">identity_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
|
||||
<span class="identifier">VAR</span><span class="special">(</span><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">>)),</span> <span class="number">4</span><span class="special">);</span> <span class="comment">// OK.</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
The <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code> macro
|
||||
expands to an expression that evaluates (at compile-time) to the specified
|
||||
type. The specified type is never split into multiple macro parameters because
|
||||
it is always wrapped by a set of extra round parenthesis <code class="computeroutput"><span class="special">()</span></code>.
|
||||
In fact, a total of two sets of round parenthesis must be used: The parenthesis
|
||||
to invoke the macro <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">(...)</span></code> plus the inner parenthesis to wrap the
|
||||
type passed to the macro <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((...))</span></code>.
|
||||
</p><p>
|
||||
This macro works on any <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
|
||||
compiler (and it does not use <a href="http://en.wikipedia.org/wiki/Variadic_macro" target="_top">variadic
|
||||
macros</a>). <sup>[<a name="boost_utility_identitytype.solution.f0" href="#ftn.boost_utility_identitytype.solution.f0" class="footnote">1</a>]</sup> The authors originally developed and tested this library using
|
||||
GNU Compiler Collection (GCC) C++ 4.5.3 (with and without C++11 features enabled
|
||||
<code class="computeroutput"><span class="special">-</span><span class="identifier">std</span><span class="special">=</span><span class="identifier">c</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span></code>) on Cygwin
|
||||
and Miscrosoft Visual C++ (MSVC) 8.0 on Windows 7. See the library <a href="http://www.boost.org/development/tests/release/developer/utility-identity_type.html" target="_top">regressions
|
||||
test results</a> for more information on supported compilers and platforms.
|
||||
</p></div><div class="section boost_utility_identitytype_templates" title="Templates"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="boost_utility_identitytype.templates"></a><a class="link" href="#boost_utility_identitytype.templates" title="Templates">Templates</a></h2></div></div></div><p>
|
||||
This macro must be prefixed by <code class="computeroutput"><span class="keyword">typename</span></code>
|
||||
when used within templates. For example, let's program a macro that declares
|
||||
a function parameter named <code class="computeroutput"><span class="identifier">arg</span></code><code class="literal"><span class="emphasis"><em>n</em></span></code>
|
||||
with the specified <code class="literal"><span class="emphasis"><em>type</em></span></code> (see also
|
||||
<a href="../../test/template.cpp" target="_top"><code class="literal">template.cpp</code></a>):
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">ARG</span><span class="special">(</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">n</span><span class="special">)</span> <span class="identifier">type</span> <span class="identifier">arg</span> <span class="error">#</span><span class="preprocessor"># n</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span> <span class="comment">// Prefix macro with `typename` in templates.</span>
|
||||
<span class="identifier">ARG</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">T</span><span class="special">>)),</span> <span class="number">1</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">cout</span> <span class="special"><<</span> <span class="identifier">arg1</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">></span> <span class="identifier">a</span><span class="special">;</span>
|
||||
<span class="identifier">a</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="char">'a'</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">f</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="identifier">a</span><span class="special">);</span> <span class="comment">// OK...</span>
|
||||
<span class="comment">// f(a); // ... but error.</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
However, note that the template parameter <code class="computeroutput"><span class="keyword">char</span></code>
|
||||
must be manually specified when invoking the function as in <code class="computeroutput"><span class="identifier">f</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="identifier">a</span><span class="special">)</span></code>. In fact,
|
||||
when the <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
|
||||
macro is used to wrap a function template parameter, the template parameter
|
||||
can no longer be automatically deduced by the compiler form the function call
|
||||
as <code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> would
|
||||
have done. <sup>[<a name="boost_utility_identitytype.templates.f0" href="#ftn.boost_utility_identitytype.templates.f0" class="footnote">2</a>]</sup> (This limitation does not apply to class templates because class
|
||||
template parameters must always be explicitly specified.) In other words, without
|
||||
using the <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
|
||||
macro, C++ would normally be able to automatically deduce the function template
|
||||
parameter as shown below:
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</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">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">T</span><span class="special">></span> <span class="identifier">arg1</span>
|
||||
<span class="special">)</span> <span class="special">{</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">arg1</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="identifier">g</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="identifier">a</span><span class="special">);</span> <span class="comment">// OK...</span>
|
||||
<span class="identifier">g</span><span class="special">(</span><span class="identifier">a</span><span class="special">);</span> <span class="comment">// ... and also OK.</span>
|
||||
</pre><p>
|
||||
</p></div><div class="section boost_utility_identitytype_abstract_types" title="Abstract Types"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="boost_utility_identitytype.abstract_types"></a><a class="link" href="#boost_utility_identitytype.abstract_types" title="Abstract Types">Abstract Types</a></h2></div></div></div><p>
|
||||
On some compilers (e.g., GCC), using this macro on abstract types (i.e., classes
|
||||
with one or more pure virtual functions) generates a compiler error. This can
|
||||
be avoided by manipulating the type adding and removing a reference to it.
|
||||
</p><p>
|
||||
Let's program a macro that performs a static assertion on a <a href="http://en.wikipedia.org/wiki/Template_metaprogramming" target="_top">Template
|
||||
Meta-Programming</a> (TMP) meta-function (similarly to Boost.MPL <a href="http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/assert.html" target="_top"><code class="computeroutput"><span class="identifier">BOOST_MPL_ASSERT</span></code></a>). The <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code> macro can be used
|
||||
to pass a meta-function with multiple template parameters to the assert macro
|
||||
(so to handle the commas separating the template parameters). In this case,
|
||||
if the meta-function is an abstract type, it needs to be manipulated adding
|
||||
and removing a reference to it (see also <a href="../../test/abstract.cpp" target="_top"><code class="literal">abstract.cpp</code></a>):
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">TMP_ASSERT</span><span class="special">(</span><span class="identifier">metafunction</span><span class="special">)</span> <span class="special">\</span>
|
||||
<span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">(</span><span class="identifier">metafunction</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">b</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">abstract</span> <span class="special">{</span>
|
||||
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">b</span><span class="special">;</span>
|
||||
<span class="keyword">virtual</span> <span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="comment">// Pure virtual function.</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="identifier">TMP_ASSERT</span><span class="special">(</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special"><</span> <span class="comment">// Add and remove</span>
|
||||
<span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span> <span class="comment">// reference for</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">add_reference</span><span class="special"><</span> <span class="comment">// abstract type.</span>
|
||||
<span class="identifier">abstract</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">true</span><span class="special">></span>
|
||||
<span class="special">>::</span><span class="identifier">type</span>
|
||||
<span class="special">))</span>
|
||||
<span class="special">>::</span><span class="identifier">type</span>
|
||||
<span class="special">);</span>
|
||||
</pre><p>
|
||||
</p></div><div class="section boost_utility_identitytype_annex__usage" title="Annex: Usage"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="boost_utility_identitytype.annex__usage"></a><a class="link" href="#boost_utility_identitytype.annex__usage" title="Annex: Usage">Annex: Usage</a></h2></div></div></div><p>
|
||||
The <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code> macro
|
||||
can be used either when calling a user-defined macro (as shown by the examples
|
||||
so far), or internally when implementing a user-defined macro (as shown below).
|
||||
When <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code> is
|
||||
used in the implementation of the user-defined macro, the caller of the user
|
||||
macro will have to specify the extra parenthesis (see also <a href="../../test/paren.cpp" target="_top"><code class="literal">paren.cpp</code></a>):
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">TMP_ASSERT_PAREN</span><span class="special">(</span><span class="identifier">parenthesized_metafunction</span><span class="special">)</span> <span class="special">\</span>
|
||||
<span class="comment">/* use `BOOST_IDENTITY_TYPE` in macro definition instead of invocation */</span> <span class="special">\</span>
|
||||
<span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">(</span><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">(</span><span class="identifier">parenthesized_metafunction</span><span class="special">)::</span><span class="identifier">value</span><span class="special">)</span>
|
||||
|
||||
<span class="preprocessor">#define</span> <span class="identifier">TMP_ASSERT</span><span class="special">(</span><span class="identifier">metafunction</span><span class="special">)</span> <span class="special">\</span>
|
||||
<span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">(</span><span class="identifier">metafunction</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span>
|
||||
|
||||
<span class="comment">// Specify only extra parenthesis `((...))`.</span>
|
||||
<span class="identifier">TMP_ASSERT_PAREN</span><span class="special">((</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_const</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">></span> <span class="keyword">const</span><span class="special">>));</span>
|
||||
|
||||
<span class="comment">// Specify both the extra parenthesis `((...))` and `BOOST_IDENTITY_TYPE` macro.</span>
|
||||
<span class="identifier">TMP_ASSERT</span><span class="special">(</span><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_const</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">></span> <span class="keyword">const</span><span class="special">>)));</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
However, note that the caller will <span class="emphasis"><em>always</em></span> have to specify
|
||||
the extra parenthesis even when the macro parameters contain no comma:
|
||||
</p><p>
|
||||
</p><pre class="programlisting"><span class="identifier">TMP_ASSERT_PAREN</span><span class="special">((</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_const</span><span class="special"><</span><span class="keyword">int</span> <span class="keyword">const</span><span class="special">>));</span> <span class="comment">// Always extra `((...))`.</span>
|
||||
|
||||
<span class="identifier">TMP_ASSERT</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_const</span><span class="special"><</span><span class="keyword">int</span> <span class="keyword">const</span><span class="special">>);</span> <span class="comment">// No extra `((...))` and no macro.</span>
|
||||
</pre><p>
|
||||
</p><p>
|
||||
In some cases, using <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
|
||||
in the implementation of the user-defined macro might provide the best syntax
|
||||
for the caller. For example, this is the case for <code class="computeroutput"><span class="identifier">BOOST_MPL_ASSERT</span></code>
|
||||
because the majority of template meta-programming expressions contain unwrapped
|
||||
commas so it is less confusing for the user to always specify the extra parenthesis
|
||||
<code class="computeroutput"><span class="special">((...))</span></code> instead of using <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>:
|
||||
</p><pre class="programlisting"><span class="identifier">BOOST_MPL_ASSERT</span><span class="special">((</span> <span class="comment">// Natural syntax.</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">and_</span><span class="special"><</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_const</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
|
||||
<span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_reference</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
|
||||
<span class="special">></span>
|
||||
<span class="special">));</span>
|
||||
</pre><p>
|
||||
However, in other situations it might be preferable to not require the extra
|
||||
parenthesis in the common cases and handle commas as special cases using <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>. For example, this
|
||||
is the case for <a href="http://www.boost.org/libs/local_function" target="_top"><code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION</span></code></a> for which always
|
||||
requiring the extra parenthesis <code class="computeroutput"><span class="special">((...))</span></code>
|
||||
around the types would lead to an unnatural syntax for the local function signature:
|
||||
</p><pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span> <span class="special">((</span><span class="keyword">int</span><span class="special">&))</span> <span class="identifier">x</span><span class="special">,</span> <span class="special">((</span><span class="keyword">int</span><span class="special">&))</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Unnatural syntax.</span>
|
||||
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
|
||||
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
|
||||
</pre><p>
|
||||
Instead requiring the user to specify <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
|
||||
only when needed allows for the more natural syntax <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span><span class="special">&</span>
|
||||
<span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">y</span><span class="special">)</span></code> in the common cases when the parameter types
|
||||
contain no comma (while still allowing to specify parameter types with commas
|
||||
as special cases using <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">>))&</span>
|
||||
<span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">y</span><span class="special">)</span></code>).
|
||||
</p></div><div class="section boost_utility_identitytype_annex__implementation" title="Annex: Implementation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="boost_utility_identitytype.annex__implementation"></a><a class="link" href="#boost_utility_identitytype.annex__implementation" title="Annex: Implementation">Annex:
|
||||
Implementation</a></h2></div></div></div><p>
|
||||
The implementation of this library macro is equivalent to the following: <sup>[<a name="boost_utility_identitytype.annex__implementation.f0" href="#ftn.boost_utility_identitytype.annex__implementation.f0" class="footnote">3</a>]</sup>
|
||||
</p><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">function_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
|
||||
<span class="preprocessor">#define</span> <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">(</span><span class="identifier">parenthesized_type</span><span class="special">)</span> <span class="special">\</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special"><</span><span class="keyword">void</span> <span class="identifier">parenthesized_type</span><span class="special">>::</span><span class="identifier">arg1_type</span>
|
||||
</pre><p>
|
||||
Essentially, the type is wrapped between round parenthesis <code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span>
|
||||
<span class="keyword">char</span><span class="special">>)</span></code>
|
||||
so it can be passed as a single macro parameter even if it contains commas.
|
||||
Then the parenthesized type is transformed into the type of a function returning
|
||||
<code class="computeroutput"><span class="keyword">void</span></code> and with the specified type
|
||||
as the type of the first and only argument <code class="computeroutput"><span class="keyword">void</span>
|
||||
<span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">>)</span></code>. Finally, the type of the first argument
|
||||
<code class="computeroutput"><span class="identifier">arg1_type</span></code> is extracted at compile-time
|
||||
using the <code class="computeroutput"><span class="identifier">function_traits</span></code> meta-function
|
||||
therefore obtaining the original type from the parenthesized type (effectively
|
||||
stripping the extra parenthesis from around the specified type).
|
||||
</p></div><div class="section reference" title="Reference"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="reference"></a>Reference</h2></div></div></div><div class="section header_boost_utility_identity_type_hpp" title="Header <boost/utility/identity_type.hpp>"><div class="titlepage"><div><div><h3 class="title"><a name="header.boost.utility.identity_type_hpp"></a>Header <<a href="../../../../../boost/utility/identity_type.hpp" target="_top">boost/utility/identity_type.hpp</a>></h3></div></div></div><p>Wrap type expressions with round parenthesis so they can be passed to macros even if they contain commas. </p><pre class="synopsis">
|
||||
|
||||
<a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a>(parenthesized_type)</pre><div class="refentry" title="Macro BOOST_IDENTITY_TYPE"><a name="BOOST_IDENTITY_TYPE"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">Macro BOOST_IDENTITY_TYPE</span></h2><p>BOOST_IDENTITY_TYPE — This macro allows to wrap the specified type expression within extra round parenthesis so the type can be passed as a single macro parameter even if it contains commas (not already wrapped within round parenthesis). </p></div><h2 class="refsynopsisdiv-title">Synopsis</h2><div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="#header.boost.utility.identity_type_hpp" title="Header <boost/utility/identity_type.hpp>">boost/utility/identity_type.hpp</a>>
|
||||
|
||||
</span>BOOST_IDENTITY_TYPE(parenthesized_type)</pre></div><div class="refsect1" title="Description"><a name="id554262"></a><h2>Description</h2><p><span class="bold"><strong>Parameters:</strong></span> </p><div class="informaltable"><table class="table"><colgroup><col><col></colgroup><tbody><tr><td><span class="bold"><strong><code class="computeroutput">parenthesized_type</code></strong></span></td><td>The type expression to be passed as macro parameter wrapped by a single set of round parenthesis <code class="computeroutput">(...)</code>. This type expression can contain an arbitrary number of commas. </td></tr></tbody></table></div><p>
|
||||
</p><p>This macro works on any C++03 compiler (it does not use variadic macros).</p><p>This macro must be prefixed by <code class="computeroutput">typename</code> when used within templates. Note that the compiler will not be able to automatically determine function template parameters when they are wrapped with this macro (these parameters need to be explicitly specified when calling the function template).</p><p>On some compilers (like GCC), using this macro on abstract types requires to add and remove a reference to the specified type. </p></div></div></div></div><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a id="ftn.boost_utility_identitytype.solution.f0" href="#boost_utility_identitytype.solution.f0" class="para">1</a>] </sup>
|
||||
Using variadic macros, it would be possible to require a single set of extra
|
||||
parenthesis <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">(</span></code><code class="literal"><span class="emphasis"><em>type</em></span></code><code class="computeroutput"><span class="special">)</span></code> instead of two <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span></code><code class="literal"><span class="emphasis"><em>type</em></span></code><code class="computeroutput"><span class="special">))</span></code> but variadic macros are not part of C++03
|
||||
(even if nowadays they are supported by most modern compilers and they are
|
||||
also part of C++11).
|
||||
</p></div><div class="footnote"><p><sup>[<a id="ftn.boost_utility_identitytype.templates.f0" href="#boost_utility_identitytype.templates.f0" class="para">2</a>] </sup>
|
||||
This is because the implementation of <code class="computeroutput"><a class="link" href="#BOOST_IDENTITY_TYPE" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
|
||||
wraps the specified type within a meta-function.
|
||||
</p></div><div class="footnote"><p><sup>[<a id="ftn.boost_utility_identitytype.annex__implementation.f0" href="#boost_utility_identitytype.annex__implementation.f0" class="para">3</a>] </sup>
|
||||
There is absolutely no guarantee that the macro is actually implemented using
|
||||
the code listed in this documentation. The listed code is for explanatory
|
||||
purposes only.
|
||||
</p></div></div></div></body></html>
|
165
identity_type/doc/identity_type.qbk
Normal file
165
identity_type/doc/identity_type.qbk
Normal file
@ -0,0 +1,165 @@
|
||||
|
||||
[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
|
||||
[/ Distributed under the Boost Software License, Version 1.0 ]
|
||||
[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
|
||||
[/ http://www.boost.org/LICENSE_1_0.txt) ]
|
||||
[/ Home at http://www.boost.org/libs/utility/identity_type ]
|
||||
|
||||
[library Boost.Utility/IdentityType
|
||||
[quickbook 1.5]
|
||||
[version 1.0.0]
|
||||
[copyright 2009-2012 Lorenzo Caminiti]
|
||||
[purpose wraps types with round parenthesis]
|
||||
[license
|
||||
Distributed under the Boost Software License, Version 1.0
|
||||
(see accompanying file LICENSE_1_0.txt or a copy at
|
||||
[@http://www.boost.org/LICENSE_1_0.txt])
|
||||
]
|
||||
[authors [Caminiti <email>lorcaminiti@gmail.com</email>, Lorenzo]]
|
||||
[category Utilities]
|
||||
]
|
||||
|
||||
This library allows to wrap types within round parenthesis so they can always be passed as macro parameters.
|
||||
|
||||
[import ../test/var_error.cpp]
|
||||
[import ../test/var.cpp]
|
||||
[import ../test/template.cpp]
|
||||
[import ../test/abstract.cpp]
|
||||
[import ../test/paren.cpp]
|
||||
|
||||
[section Motivation]
|
||||
|
||||
Consider the following macro which declares a variable named `var`[^['n]] with the specified [^['type]] (see also [@../../test/var_error.cpp =var_error.cpp=]):
|
||||
|
||||
[var_error]
|
||||
|
||||
The first macro invocation works correctly declaring a variable named `var1` of type `int`.
|
||||
However, the second macro invocation fails generating a preprocessor error similar to the following:
|
||||
|
||||
[pre
|
||||
error: macro "VAR" passed 3 arguments, but takes just 2
|
||||
]
|
||||
|
||||
That is because the `std::map` type passed as the first macro parameter contains a comma `,` not wrapped by round parenthesis `()`.
|
||||
The preprocessor interprets that unwrapped comma as a separation between macro parameters concluding that a total of three (and not two) parameters are passed to the macro in the following order:
|
||||
|
||||
# `std::map<int`
|
||||
# `char>`
|
||||
# `2`
|
||||
|
||||
Note that, differently from the compiler, the preprocessor only recognizes round parenthesis `()`.
|
||||
Angular `<>` and squared `[]` parenthesis are not recognized by the preprocessor when parsing macro parameters.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Solution]
|
||||
|
||||
In some cases, it might be possible to workaround this issue by avoiding to pass the type expression to the macro all together.
|
||||
For example, in the case above a `typedef` could have been used to specify the type expression with the commas outside the macro (see also [@../../test/var.cpp =var.cpp=]):
|
||||
|
||||
[var_typedef]
|
||||
|
||||
When this is neither possible nor desired (e.g., see the function template `f` in the section below), this library header [headerref boost/utility/identity_type.hpp] defines a macro [macroref BOOST_IDENTITY_TYPE] which can be used to workaround the issue while keeping the type expression as one of the macro parameters (see also [@../../test/var.cpp =var.cpp=]).
|
||||
|
||||
[var_ok]
|
||||
|
||||
The [macroref BOOST_IDENTITY_TYPE] macro expands to an expression that evaluates (at compile-time) to the specified type.
|
||||
The specified type is never split into multiple macro parameters because it is always wrapped by a set of extra round parenthesis `()`.
|
||||
In fact, a total of two sets of round parenthesis must be used: The parenthesis to invoke the macro `BOOST_IDENTITY_TYPE(...)` plus the inner parenthesis to wrap the type passed to the macro `BOOST_IDENTITY_TYPE((...))`.
|
||||
|
||||
This macro works on any [@http://www.open-std.org/JTC1/SC22/WG21/docs/standards C++03] compiler (and it does not use [@http://en.wikipedia.org/wiki/Variadic_macro variadic macros]).
|
||||
[footnote
|
||||
Using variadic macros, it would be possible to require a single set of extra parenthesis `BOOST_IDENTITY_TYPE(`[^['type]]`)` instead of two `BOOST_IDENTITY_TYPE((`[^['type]]`))` but variadic macros are not part of C++03 (even if nowadays they are supported by most modern compilers and they are also part of C++11).
|
||||
]
|
||||
The authors originally developed and tested this library using GNU Compiler Collection (GCC) C++ 4.5.3 (with and without C++11 features enabled `-std=c++0x`) on Cygwin and Miscrosoft Visual C++ (MSVC) 8.0 on Windows 7.
|
||||
See the library [@http://www.boost.org/development/tests/release/developer/utility-identity_type.html regressions test results] for more information on supported compilers and platforms.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Templates]
|
||||
|
||||
This macro must be prefixed by `typename` when used within templates.
|
||||
For example, let's program a macro that declares a function parameter named `arg`[^['n]] with the specified [^['type]] (see also [@../../test/template.cpp =template.cpp=]):
|
||||
|
||||
[template_f_decl]
|
||||
[template_f_call]
|
||||
|
||||
However, note that the template parameter `char` must be manually specified when invoking the function as in `f<char>(a)`.
|
||||
In fact, when the [macroref BOOST_IDENTITY_TYPE] macro is used to wrap a function template parameter, the template parameter can no longer be automatically deduced by the compiler form the function call as `f(a)` would have done.
|
||||
[footnote
|
||||
This is because the implementation of [macroref BOOST_IDENTITY_TYPE] wraps the specified type within a meta-function.
|
||||
]
|
||||
(This limitation does not apply to class templates because class template parameters must always be explicitly specified.)
|
||||
In other words, without using the [macroref BOOST_IDENTITY_TYPE] macro, C++ would normally be able to automatically deduce the function template parameter as shown below:
|
||||
|
||||
[template_g_decl]
|
||||
[template_g_call]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Abstract Types]
|
||||
|
||||
On some compilers (e.g., GCC), using this macro on abstract types (i.e., classes with one or more pure virtual functions) generates a compiler error.
|
||||
This can be avoided by manipulating the type adding and removing a reference to it.
|
||||
|
||||
Let's program a macro that performs a static assertion on a [@http://en.wikipedia.org/wiki/Template_metaprogramming Template Meta-Programming] (TMP) meta-function (similarly to Boost.MPL [@http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/assert.html `BOOST_MPL_ASSERT`]).
|
||||
The [macroref BOOST_IDENTITY_TYPE] macro can be used to pass a meta-function with multiple template parameters to the assert macro (so to handle the commas separating the template parameters).
|
||||
In this case, if the meta-function is an abstract type, it needs to be manipulated adding and removing a reference to it (see also [@../../test/abstract.cpp =abstract.cpp=]):
|
||||
|
||||
[abstract]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Annex: Usage]
|
||||
|
||||
The [macroref BOOST_IDENTITY_TYPE] macro can be used either when calling a user-defined macro (as shown by the examples so far), or internally when implementing a user-defined macro (as shown below).
|
||||
When [macroref BOOST_IDENTITY_TYPE] is used in the implementation of the user-defined macro, the caller of the user macro will have to specify the extra parenthesis (see also [@../../test/paren.cpp =paren.cpp=]):
|
||||
|
||||
[paren]
|
||||
|
||||
However, note that the caller will /always/ have to specify the extra parenthesis even when the macro parameters contain no comma:
|
||||
|
||||
[paren_always]
|
||||
|
||||
In some cases, using [macroref BOOST_IDENTITY_TYPE] in the implementation of the user-defined macro might provide the best syntax for the caller.
|
||||
For example, this is the case for `BOOST_MPL_ASSERT` because the majority of template meta-programming expressions contain unwrapped commas so it is less confusing for the user to always specify the extra parenthesis `((...))` instead of using [macroref BOOST_IDENTITY_TYPE]:
|
||||
|
||||
BOOST_MPL_ASSERT(( // Natural syntax.
|
||||
boost::mpl::and_<
|
||||
boost::is_const<T>
|
||||
, boost::is_reference<T>
|
||||
>
|
||||
));
|
||||
|
||||
However, in other situations it might be preferable to not require the extra parenthesis in the common cases and handle commas as special cases using [macroref BOOST_IDENTITY_TYPE].
|
||||
For example, this is the case for [@http://www.boost.org/libs/local_function `BOOST_LOCAL_FUNCTION`] for which always requiring the extra parenthesis `((...))` around the types would lead to an unnatural syntax for the local function signature:
|
||||
|
||||
int BOOST_LOCAL_FUNCTION( ((int&)) x, ((int&)) y ) { // Unnatural syntax.
|
||||
return x + y;
|
||||
} BOOST_LOCAL_FUNCTION_NAME(add)
|
||||
|
||||
Instead requiring the user to specify [macroref BOOST_IDENTITY_TYPE] only when needed allows for the more natural syntax `BOOST_LOCAL_FUNCTION(int& x, int& y)` in the common cases when the parameter types contain no comma (while still allowing to specify parameter types with commas as special cases using `BOOST_LOCAL_FUNCTION(BOOST_IDENTITY_TYPE((std::map<int, char>))& x, int& y)`).
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Annex: Implementation]
|
||||
|
||||
The implementation of this library macro is equivalent to the following:
|
||||
[footnote
|
||||
There is absolutely no guarantee that the macro is actually implemented using the code listed in this documentation.
|
||||
The listed code is for explanatory purposes only.
|
||||
]
|
||||
|
||||
#include <boost/type_traits/function_traits.hpp>
|
||||
|
||||
#define BOOST_IDENTITY_TYPE(parenthesized_type) \
|
||||
boost::function_traits<void parenthesized_type>::arg1_type
|
||||
|
||||
Essentially, the type is wrapped between round parenthesis `(std::map<int, char>)` so it can be passed as a single macro parameter even if it contains commas.
|
||||
Then the parenthesized type is transformed into the type of a function returning `void` and with the specified type as the type of the first and only argument `void (std::map<int, char>)`.
|
||||
Finally, the type of the first argument `arg1_type` is extracted at compile-time using the `function_traits` meta-function therefore obtaining the original type from the parenthesized type (effectively stripping the extra parenthesis from around the specified type).
|
||||
|
||||
[endsect]
|
||||
|
||||
[xinclude reference.xml]
|
||||
|
15
identity_type/index.html
Normal file
15
identity_type/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, click this
|
||||
<a href="doc/html/index.html">link</a> <hr>
|
||||
<p><EFBFBD> Copyright Lorenzo Caminiti, 2009-2012</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0 (see
|
||||
accompanying file <a href="../../../LICENSE_1_0.txt">
|
||||
LICENSE_1_0.txt</a> or a copy at
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
16
identity_type/test/Jamfile.v2
Normal file
16
identity_type/test/Jamfile.v2
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
# Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
# Distributed under the Boost Software License, Version 1.0
|
||||
# (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
# Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
import testing ;
|
||||
|
||||
compile-fail var_error.cpp ;
|
||||
run var.cpp ;
|
||||
run template.cpp ;
|
||||
run abstract.cpp ;
|
||||
run noncopyable.cpp ;
|
||||
run paren.cpp ;
|
||||
|
35
identity_type/test/abstract.cpp
Normal file
35
identity_type/test/abstract.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
#include <boost/utility/identity_type.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
//[abstract
|
||||
#define TMP_ASSERT(metafunction) \
|
||||
BOOST_STATIC_ASSERT(metafunction::value)
|
||||
|
||||
template<typename T, bool b>
|
||||
struct abstract {
|
||||
static const bool value = b;
|
||||
virtual void f(T const& x) = 0; // Pure virtual function.
|
||||
};
|
||||
|
||||
TMP_ASSERT(
|
||||
boost::remove_reference< // Add and remove
|
||||
BOOST_IDENTITY_TYPE(( // reference for
|
||||
boost::add_reference< // abstract type.
|
||||
abstract<int, true>
|
||||
>::type
|
||||
))
|
||||
>::type
|
||||
);
|
||||
//]
|
||||
|
||||
int main() { return 0; }
|
||||
|
25
identity_type/test/noncopyable.cpp
Normal file
25
identity_type/test/noncopyable.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
#include <boost/utility/identity_type.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
//[noncopyable
|
||||
#define TMP_ASSERT(metafunction) \
|
||||
BOOST_STATIC_ASSERT(metafunction::value)
|
||||
|
||||
template<typename T, T init>
|
||||
struct noncopyable : boost::noncopyable {
|
||||
static const T value = init;
|
||||
};
|
||||
|
||||
TMP_ASSERT(BOOST_IDENTITY_TYPE((noncopyable<bool, true>)));
|
||||
//]
|
||||
|
||||
int main() { return 0; }
|
||||
|
35
identity_type/test/paren.cpp
Normal file
35
identity_type/test/paren.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
#include <boost/utility/identity_type.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <map>
|
||||
|
||||
//[paren
|
||||
#define TMP_ASSERT_PAREN(parenthesized_metafunction) \
|
||||
/* use `BOOST_IDENTITY_TYPE` in macro definition instead of invocation */ \
|
||||
BOOST_STATIC_ASSERT(BOOST_IDENTITY_TYPE(parenthesized_metafunction)::value)
|
||||
|
||||
#define TMP_ASSERT(metafunction) \
|
||||
BOOST_STATIC_ASSERT(metafunction::value)
|
||||
|
||||
// Specify only extra parenthesis `((...))`.
|
||||
TMP_ASSERT_PAREN((boost::is_const<std::map<int, char> const>));
|
||||
|
||||
// Specify both the extra parenthesis `((...))` and `BOOST_IDENTITY_TYPE` macro.
|
||||
TMP_ASSERT(BOOST_IDENTITY_TYPE((boost::is_const<std::map<int, char> const>)));
|
||||
//]
|
||||
|
||||
//[paren_always
|
||||
TMP_ASSERT_PAREN((boost::is_const<int const>)); // Always extra `((...))`.
|
||||
|
||||
TMP_ASSERT(boost::is_const<int const>); // No extra `((...))` and no macro.
|
||||
//]
|
||||
|
||||
int main() { return 0; }
|
||||
|
48
identity_type/test/template.cpp
Normal file
48
identity_type/test/template.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
#include <boost/utility/identity_type.hpp>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
//[template_f_decl
|
||||
#define ARG(type, n) type arg ## n
|
||||
|
||||
template<typename T>
|
||||
void f( // Prefix macro with `typename` in templates.
|
||||
ARG(typename BOOST_IDENTITY_TYPE((std::map<int, T>)), 1)
|
||||
) {
|
||||
std::cout << arg1[0] << std::endl;
|
||||
}
|
||||
//]
|
||||
|
||||
//[template_g_decl
|
||||
template<typename T>
|
||||
void g(
|
||||
std::map<int, T> arg1
|
||||
) {
|
||||
std::cout << arg1[0] << std::endl;
|
||||
}
|
||||
//]
|
||||
|
||||
int main() {
|
||||
//[template_f_call
|
||||
std::map<int, char> a;
|
||||
a[0] = 'a';
|
||||
|
||||
f<char>(a); // OK...
|
||||
// f(a); // ... but error.
|
||||
//]
|
||||
|
||||
//[template_g_call
|
||||
g<char>(a); // OK...
|
||||
g(a); // ... and also OK.
|
||||
//]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
26
identity_type/test/var.cpp
Normal file
26
identity_type/test/var.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
#include <map>
|
||||
|
||||
#define VAR(type, n) type var ## n
|
||||
|
||||
VAR(int, 1); // OK.
|
||||
|
||||
//[var_typedef
|
||||
typedef std::map<int, char> map_type;
|
||||
VAR(map_type, 3); // OK.
|
||||
//]
|
||||
|
||||
//[var_ok
|
||||
#include <boost/utility/identity_type.hpp>
|
||||
|
||||
VAR(BOOST_IDENTITY_TYPE((std::map<int, char>)), 4); // OK.
|
||||
//]
|
||||
|
||||
int main() { return 0; }
|
||||
|
18
identity_type/test/var_error.cpp
Normal file
18
identity_type/test/var_error.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
#include <map>
|
||||
|
||||
//[var_error
|
||||
#define VAR(type, n) type var ## n
|
||||
|
||||
VAR(int, 1); // OK.
|
||||
VAR(std::map<int, char>, 2); // Error.
|
||||
//]
|
||||
|
||||
int main() { return 0; }
|
||||
|
@ -46,7 +46,7 @@ HREF="../../boost/utility/typed_in_place_factory.hpp">boost/utility/typed_in_pla
|
||||
<p>Suppose we have a class</p>
|
||||
<pre>struct X
|
||||
{
|
||||
X ( int, std:::string ) ;
|
||||
X ( int, std::string ) ;
|
||||
} ;</pre>
|
||||
<p>And a container for it which supports an empty state (that is, which can contain zero objects):</p>
|
||||
<pre>struct C
|
||||
@ -99,7 +99,7 @@ directly to the container:</p>
|
||||
<H2><A NAME="framework"></A>Framework</H2>
|
||||
<p>
|
||||
This library proposes a framework to allow some containers to directly contruct contained objects in-place without requiring
|
||||
the entire set of constructor overloads ftom the contained type. It also allows the container to remove the CopyConstuctible
|
||||
the entire set of constructor overloads from the contained type. It also allows the container to remove the CopyConstuctible
|
||||
requirement from the contained type since objects can be directly constructed in-place without need of a copy.<br>
|
||||
The only requirement on the container is that it must provide proper storage (that is, correctly aligned and sized).
|
||||
Naturally, the container will typically support uninitialized storage to avoid the in-place construction to override
|
||||
@ -117,7 +117,7 @@ The following simplified example shows the basic idea. A complete example follow
|
||||
<pre>struct C
|
||||
{
|
||||
template<class InPlaceFactory>
|
||||
C ( InPlaceFactory const& aFactoty )
|
||||
C ( InPlaceFactory const& aFactory )
|
||||
:
|
||||
contained_ ( uninitialized_storage() )
|
||||
{
|
||||
@ -293,4 +293,4 @@ the latest version of this file can be found at <A
|
||||
HREF="http://www.boost.org">www.boost.org</A>, and the boost
|
||||
<A HREF="http://www.boost.org/more/mailing_lists.htm#main">discussion lists</A></P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
@ -1,37 +0,0 @@
|
||||
//
|
||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
||||
//
|
||||
// Copyright (c) 2001, 2002 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)
|
||||
//
|
||||
// Note: There are no include guards. This is intentional.
|
||||
//
|
||||
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
||||
//
|
||||
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS)
|
||||
|
||||
# define BOOST_ASSERT(expr) ((void)0)
|
||||
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
|
||||
# define BOOST_ASSERT(expr) assert(expr)
|
||||
#endif
|
@ -5,7 +5,7 @@
|
||||
//
|
||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
||||
|
||||
// See boost/detail/call_traits.hpp and boost/detail/ob_call_traits.hpp
|
||||
// See boost/detail/call_traits.hpp
|
||||
// for full copyright notices.
|
||||
|
||||
#ifndef BOOST_CALL_TRAITS_HPP
|
||||
@ -15,10 +15,6 @@
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/detail/ob_call_traits.hpp>
|
||||
#else
|
||||
#include <boost/detail/call_traits.hpp>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_CALL_TRAITS_HPP
|
||||
|
@ -1,69 +0,0 @@
|
||||
#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
|
||||
#define BOOST_CHECKED_DELETE_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/checked_delete.hpp
|
||||
//
|
||||
// Copyright (c) 2002, 2003 Peter Dimov
|
||||
// Copyright (c) 2003 Daniel Frey
|
||||
// Copyright (c) 2003 Howard Hinnant
|
||||
//
|
||||
// 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/utility/checked_delete.html for documentation.
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// verify that types are complete for increased safety
|
||||
|
||||
template<class T> inline void checked_delete(T * x)
|
||||
{
|
||||
// intentionally complex - simplification causes regressions
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
delete x;
|
||||
}
|
||||
|
||||
template<class T> inline void checked_array_delete(T * x)
|
||||
{
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
delete [] x;
|
||||
}
|
||||
|
||||
template<class T> struct checked_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
void operator()(T * x) const
|
||||
{
|
||||
// boost:: disables ADL
|
||||
boost::checked_delete(x);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T> struct checked_array_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
void operator()(T * x) const
|
||||
{
|
||||
boost::checked_array_delete(x);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
|
@ -5,7 +5,7 @@
|
||||
//
|
||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
||||
|
||||
// See boost/detail/compressed_pair.hpp and boost/detail/ob_compressed_pair.hpp
|
||||
// See boost/detail/compressed_pair.hpp
|
||||
// for full copyright notices.
|
||||
|
||||
#ifndef BOOST_COMPRESSED_PAIR_HPP
|
||||
@ -15,10 +15,6 @@
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/detail/ob_compressed_pair.hpp>
|
||||
#else
|
||||
#include <boost/detail/compressed_pair.hpp>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COMPRESSED_PAIR_HPP
|
||||
|
@ -1,67 +0,0 @@
|
||||
#ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
||||
#define BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/current_function.hpp - BOOST_CURRENT_FUNCTION
|
||||
//
|
||||
// Copyright (c) 2002 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)
|
||||
//
|
||||
// http://www.boost.org/libs/utility/current_function.html
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void current_function_helper()
|
||||
{
|
||||
|
||||
#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600))
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#elif defined(__DMC__) && (__DMC__ >= 0x810)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#elif defined(__FUNCSIG__)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
|
||||
|
||||
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNCTION__
|
||||
|
||||
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNC__
|
||||
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __func__
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION "(unknown)"
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
@ -24,6 +24,7 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@ -43,20 +44,26 @@ struct ct_imp2<T, true>
|
||||
typedef const T param_type;
|
||||
};
|
||||
|
||||
template <typename T, bool isp, bool b1>
|
||||
template <typename T, bool isp, bool b1, bool b2>
|
||||
struct ct_imp
|
||||
{
|
||||
typedef const T& param_type;
|
||||
};
|
||||
|
||||
template <typename T, bool isp>
|
||||
struct ct_imp<T, isp, true>
|
||||
template <typename T, bool isp, bool b2>
|
||||
struct ct_imp<T, isp, true, b2>
|
||||
{
|
||||
typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
|
||||
};
|
||||
|
||||
template <typename T, bool b1>
|
||||
struct ct_imp<T, true, b1>
|
||||
template <typename T, bool isp, bool b1>
|
||||
struct ct_imp<T, isp, b1, true>
|
||||
{
|
||||
typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
|
||||
};
|
||||
|
||||
template <typename T, bool b1, bool b2>
|
||||
struct ct_imp<T, true, b1, b2>
|
||||
{
|
||||
typedef const T param_type;
|
||||
};
|
||||
@ -79,7 +86,8 @@ public:
|
||||
typedef typename boost::detail::ct_imp<
|
||||
T,
|
||||
::boost::is_pointer<T>::value,
|
||||
::boost::is_arithmetic<T>::value
|
||||
::boost::is_arithmetic<T>::value,
|
||||
::boost::is_enum<T>::value
|
||||
>::param_type param_type;
|
||||
};
|
||||
|
||||
@ -92,7 +100,7 @@ struct call_traits<T&>
|
||||
typedef T& param_type; // hh removed const
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 ) )
|
||||
#if BOOST_WORKAROUND( BOOST_BORLANDC, < 0x5A0 )
|
||||
// these are illegal specialisations; cv-qualifies applied to
|
||||
// references have no effect according to [8.3.2p1],
|
||||
// C++ Builder requires them though as it treats cv-qualified
|
||||
|
@ -6,7 +6,7 @@
|
||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
||||
|
||||
// compressed_pair: pair that "compresses" empty members
|
||||
// (see libs/utility/compressed_pair.htm)
|
||||
// (see libs/utility/doc/html/compressed_pair.html)
|
||||
//
|
||||
// JM changes 25 Jan 2004:
|
||||
// For the case where T1 == T2 and both are empty, then first() and second()
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/is_empty.hpp>
|
||||
#include <boost/type_traits/is_final.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
|
||||
@ -42,6 +43,14 @@ class compressed_pair;
|
||||
|
||||
namespace details
|
||||
{
|
||||
template<class T, bool E = boost::is_final<T>::value>
|
||||
struct compressed_pair_empty
|
||||
: ::boost::false_type { };
|
||||
|
||||
template<class T>
|
||||
struct compressed_pair_empty<T, false>
|
||||
: ::boost::is_empty<T> { };
|
||||
|
||||
// JM altered 26 Jan 2000:
|
||||
template <class T1, class T2, bool IsSame, bool FirstEmpty, bool SecondEmpty>
|
||||
struct compressed_pair_switch;
|
||||
@ -343,8 +352,8 @@ class compressed_pair
|
||||
T1,
|
||||
T2,
|
||||
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
|
||||
::boost::is_empty<T1>::value,
|
||||
::boost::is_empty<T2>::value>::value>
|
||||
::boost::details::compressed_pair_empty<T1>::value,
|
||||
::boost::details::compressed_pair_empty<T2>::value>::value>
|
||||
{
|
||||
private:
|
||||
typedef details::compressed_pair_imp<T1, T2,
|
||||
@ -352,8 +361,8 @@ private:
|
||||
T1,
|
||||
T2,
|
||||
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
|
||||
::boost::is_empty<T1>::value,
|
||||
::boost::is_empty<T2>::value>::value> base;
|
||||
::boost::details::compressed_pair_empty<T1>::value,
|
||||
::boost::details::compressed_pair_empty<T2>::value>::value> base;
|
||||
public:
|
||||
typedef T1 first_type;
|
||||
typedef T2 second_type;
|
||||
@ -388,8 +397,8 @@ class compressed_pair<T, T>
|
||||
T,
|
||||
T,
|
||||
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
|
||||
::boost::is_empty<T>::value,
|
||||
::boost::is_empty<T>::value>::value>
|
||||
::boost::details::compressed_pair_empty<T>::value,
|
||||
::boost::details::compressed_pair_empty<T>::value>::value>
|
||||
{
|
||||
private:
|
||||
typedef details::compressed_pair_imp<T, T,
|
||||
@ -397,8 +406,8 @@ private:
|
||||
T,
|
||||
T,
|
||||
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
|
||||
::boost::is_empty<T>::value,
|
||||
::boost::is_empty<T>::value>::value> base;
|
||||
::boost::details::compressed_pair_empty<T>::value,
|
||||
::boost::details::compressed_pair_empty<T>::value>::value> base;
|
||||
public:
|
||||
typedef T first_type;
|
||||
typedef T second_type;
|
||||
|
@ -1,168 +0,0 @@
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
||||
// 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).
|
||||
//
|
||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
||||
//
|
||||
// Crippled version for crippled compilers:
|
||||
// see libs/utility/call_traits.htm
|
||||
//
|
||||
|
||||
/* Release notes:
|
||||
01st October 2000:
|
||||
Fixed call_traits on VC6, using "poor man's partial specialisation",
|
||||
using ideas taken from "Generative programming" by Krzysztof Czarnecki
|
||||
& Ulrich Eisenecker.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_OB_CALL_TRAITS_HPP
|
||||
#define BOOST_OB_CALL_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/arithmetic_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/composite_traits.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef BOOST_MSVC6_MEMBER_TEMPLATES
|
||||
//
|
||||
// use member templates to emulate
|
||||
// partial specialisation:
|
||||
//
|
||||
namespace detail{
|
||||
|
||||
template <class T>
|
||||
struct standard_call_traits
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef const T& param_type;
|
||||
};
|
||||
template <class T>
|
||||
struct simple_call_traits
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef const T param_type;
|
||||
};
|
||||
template <class T>
|
||||
struct reference_call_traits
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T reference;
|
||||
typedef T const_reference;
|
||||
typedef T param_type;
|
||||
};
|
||||
|
||||
template <bool pointer, bool arithmetic, bool reference>
|
||||
struct call_traits_chooser
|
||||
{
|
||||
template <class T>
|
||||
struct rebind
|
||||
{
|
||||
typedef standard_call_traits<T> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct call_traits_chooser<true, false, false>
|
||||
{
|
||||
template <class T>
|
||||
struct rebind
|
||||
{
|
||||
typedef simple_call_traits<T> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct call_traits_chooser<false, false, true>
|
||||
{
|
||||
template <class T>
|
||||
struct rebind
|
||||
{
|
||||
typedef reference_call_traits<T> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <bool size_is_small>
|
||||
struct call_traits_sizeof_chooser2
|
||||
{
|
||||
template <class T>
|
||||
struct small_rebind
|
||||
{
|
||||
typedef simple_call_traits<T> small_type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct call_traits_sizeof_chooser2<false>
|
||||
{
|
||||
template <class T>
|
||||
struct small_rebind
|
||||
{
|
||||
typedef standard_call_traits<T> small_type;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct call_traits_chooser<false, true, false>
|
||||
{
|
||||
template <class T>
|
||||
struct rebind
|
||||
{
|
||||
enum { sizeof_choice = (sizeof(T) <= sizeof(void*)) };
|
||||
typedef call_traits_sizeof_chooser2<(sizeof(T) <= sizeof(void*))> chooser;
|
||||
typedef typename chooser::template small_rebind<T> bound_type;
|
||||
typedef typename bound_type::small_type type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
template <typename T>
|
||||
struct call_traits
|
||||
{
|
||||
private:
|
||||
typedef detail::call_traits_chooser<
|
||||
::boost::is_pointer<T>::value,
|
||||
::boost::is_arithmetic<T>::value,
|
||||
::boost::is_reference<T>::value
|
||||
> chooser;
|
||||
typedef typename chooser::template rebind<T> bound_type;
|
||||
typedef typename bound_type::type call_traits_type;
|
||||
public:
|
||||
typedef typename call_traits_type::value_type value_type;
|
||||
typedef typename call_traits_type::reference reference;
|
||||
typedef typename call_traits_type::const_reference const_reference;
|
||||
typedef typename call_traits_type::param_type param_type;
|
||||
};
|
||||
|
||||
#else
|
||||
//
|
||||
// sorry call_traits is completely non-functional
|
||||
// blame your broken compiler:
|
||||
//
|
||||
|
||||
template <typename T>
|
||||
struct call_traits
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef const T& param_type;
|
||||
};
|
||||
|
||||
#endif // member templates
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_OB_CALL_TRAITS_HPP
|
@ -167,17 +167,6 @@ public:
|
||||
compressed_pair_1(const ::boost::compressed_pair<T1,T2>& x)
|
||||
: T2(x.second()), _first(x.first()) {}
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
|
||||
// Total weirdness. If the assignment to _first is moved after
|
||||
// the call to the inherited operator=, then this breaks graph/test/graph.cpp
|
||||
// by way of iterator_adaptor.
|
||||
compressed_pair_1& operator=(const compressed_pair_1& x) {
|
||||
_first = x._first;
|
||||
T2::operator=(x);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
first_reference first() { return _first; }
|
||||
first_const_reference first() const { return _first; }
|
||||
|
||||
|
@ -1,80 +0,0 @@
|
||||
// (C) Copyright Jens Maurer 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)
|
||||
//
|
||||
// Revision History:
|
||||
|
||||
// 15 Nov 2001 Jens Maurer
|
||||
// created.
|
||||
|
||||
// See http://www.boost.org/libs/utility/iterator_adaptors.htm for documentation.
|
||||
|
||||
#ifndef BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
|
||||
#define BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
|
||||
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class Generator>
|
||||
class generator_iterator
|
||||
: public iterator_facade<
|
||||
generator_iterator<Generator>
|
||||
, typename Generator::result_type
|
||||
, single_pass_traversal_tag
|
||||
, typename Generator::result_type const&
|
||||
>
|
||||
{
|
||||
typedef iterator_facade<
|
||||
generator_iterator<Generator>
|
||||
, typename Generator::result_type
|
||||
, single_pass_traversal_tag
|
||||
, typename Generator::result_type const&
|
||||
> super_t;
|
||||
|
||||
public:
|
||||
generator_iterator() {}
|
||||
generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {}
|
||||
|
||||
void increment()
|
||||
{
|
||||
m_value = (*m_g)();
|
||||
}
|
||||
|
||||
const typename Generator::result_type&
|
||||
dereference() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
bool equal(generator_iterator const& y) const
|
||||
{
|
||||
return this->m_g == y.m_g && this->m_value == y.m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
Generator* m_g;
|
||||
typename Generator::result_type m_value;
|
||||
};
|
||||
|
||||
template<class Generator>
|
||||
struct generator_iterator_generator
|
||||
{
|
||||
typedef generator_iterator<Generator> type;
|
||||
};
|
||||
|
||||
template <class Generator>
|
||||
inline generator_iterator<Generator>
|
||||
make_generator_iterator(Generator & gen)
|
||||
{
|
||||
typedef generator_iterator<Generator> result_t;
|
||||
return result_t(&gen);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
|
||||
|
@ -1,51 +0,0 @@
|
||||
// Boost next_prior.hpp header file ---------------------------------------//
|
||||
|
||||
// (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. 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/utility for documentation.
|
||||
|
||||
// Revision History
|
||||
// 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker)
|
||||
|
||||
#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
|
||||
#define BOOST_NEXT_PRIOR_HPP_INCLUDED
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Helper functions for classes like bidirectional iterators not supporting
|
||||
// operator+ and operator-
|
||||
//
|
||||
// Usage:
|
||||
// const std::list<T>::iterator p = get_some_iterator();
|
||||
// const std::list<T>::iterator prev = boost::prior(p);
|
||||
// const std::list<T>::iterator next = boost::next(prev, 2);
|
||||
|
||||
// Contributed by Dave Abrahams
|
||||
|
||||
template <class T>
|
||||
inline T next(T x) { return ++x; }
|
||||
|
||||
template <class T, class Distance>
|
||||
inline T next(T x, Distance n)
|
||||
{
|
||||
std::advance(x, n);
|
||||
return x;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T prior(T x) { return --x; }
|
||||
|
||||
template <class T, class Distance>
|
||||
inline T prior(T x, Distance n)
|
||||
{
|
||||
std::advance(x, -n);
|
||||
return x;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NEXT_PRIOR_HPP_INCLUDED
|
@ -1,36 +0,0 @@
|
||||
// Boost noncopyable.hpp header file --------------------------------------//
|
||||
|
||||
// (C) Copyright Beman Dawes 1999-2003. 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/utility for documentation.
|
||||
|
||||
#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED
|
||||
#define BOOST_NONCOPYABLE_HPP_INCLUDED
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Private copy constructor and copy assignment ensure classes derived from
|
||||
// class noncopyable cannot be copied.
|
||||
|
||||
// Contributed by Dave Abrahams
|
||||
|
||||
namespace noncopyable_ // protection from unintended ADL
|
||||
{
|
||||
class noncopyable
|
||||
{
|
||||
protected:
|
||||
noncopyable() {}
|
||||
~noncopyable() {}
|
||||
private: // emphasize the following members are private
|
||||
noncopyable( const noncopyable& );
|
||||
const noncopyable& operator=( const noncopyable& );
|
||||
};
|
||||
}
|
||||
|
||||
typedef noncopyable_::noncopyable noncopyable;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NONCOPYABLE_HPP_INCLUDED
|
File diff suppressed because it is too large
Load Diff
951
include/boost/operators_v1.hpp
Normal file
951
include/boost/operators_v1.hpp
Normal file
@ -0,0 +1,951 @@
|
||||
// Boost operators.hpp header file ----------------------------------------//
|
||||
|
||||
// (C) Copyright David Abrahams, Jeremy Siek, Daryle Walker 1999-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)
|
||||
|
||||
// See http://www.boost.org/libs/utility/operators.htm for documentation.
|
||||
|
||||
// Revision History
|
||||
// 22 Feb 16 Preserve old work-arounds. (Daniel Frey)
|
||||
// 16 Dec 10 Limit warning suppression for 4284 to older versions of VC++
|
||||
// (Matthew Bradbury, fixes #4432)
|
||||
// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey)
|
||||
// 03 Apr 08 Make sure "convertible to bool" is sufficient
|
||||
// for T::operator<, etc. (Daniel Frey)
|
||||
// 24 May 07 Changed empty_base to depend on T, see
|
||||
// http://svn.boost.org/trac/boost/ticket/979
|
||||
// 21 Oct 02 Modified implementation of operators to allow compilers with a
|
||||
// correct named return value optimization (NRVO) to produce optimal
|
||||
// code. (Daniel Frey)
|
||||
// 02 Dec 01 Bug fixed in random_access_iteratable. (Helmut Zeisel)
|
||||
// 28 Sep 01 Factored out iterator operator groups. (Daryle Walker)
|
||||
// 27 Aug 01 'left' form for non commutative operators added;
|
||||
// additional classes for groups of related operators added;
|
||||
// workaround for empty base class optimization
|
||||
// bug of GCC 3.0 (Helmut Zeisel)
|
||||
// 25 Jun 01 output_iterator_helper changes: removed default template
|
||||
// parameters, added support for self-proxying, additional
|
||||
// documentation and tests (Aleksey Gurtovoy)
|
||||
// 29 May 01 Added operator classes for << and >>. Added input and output
|
||||
// iterator helper classes. Added classes to connect equality and
|
||||
// relational operators. Added classes for groups of related
|
||||
// operators. Reimplemented example operator and iterator helper
|
||||
// classes in terms of the new groups. (Daryle Walker, with help
|
||||
// from Alexy Gurtovoy)
|
||||
// 11 Feb 01 Fixed bugs in the iterator helpers which prevented explicitly
|
||||
// supplied arguments from actually being used (Dave Abrahams)
|
||||
// 04 Jul 00 Fixed NO_OPERATORS_IN_NAMESPACE bugs, major cleanup and
|
||||
// refactoring of compiler workarounds, additional documentation
|
||||
// (Alexy Gurtovoy and Mark Rodgers with some help and prompting from
|
||||
// Dave Abrahams)
|
||||
// 28 Jun 00 General cleanup and integration of bugfixes from Mark Rodgers and
|
||||
// Jeremy Siek (Dave Abrahams)
|
||||
// 20 Jun 00 Changes to accommodate Borland C++Builder 4 and Borland C++ 5.5
|
||||
// (Mark Rodgers)
|
||||
// 20 Jun 00 Minor fixes to the prior revision (Aleksey Gurtovoy)
|
||||
// 10 Jun 00 Support for the base class chaining technique was added
|
||||
// (Aleksey Gurtovoy). See documentation and the comments below
|
||||
// for the details.
|
||||
// 12 Dec 99 Initial version with iterator operators (Jeremy Siek)
|
||||
// 18 Nov 99 Change name "divideable" to "dividable", remove unnecessary
|
||||
// specializations of dividable, subtractable, modable (Ed Brey)
|
||||
// 17 Nov 99 Add comments (Beman Dawes)
|
||||
// Remove unnecessary specialization of operators<> (Ed Brey)
|
||||
// 15 Nov 99 Fix less_than_comparable<T,U> second operand type for first two
|
||||
// operators.(Beman Dawes)
|
||||
// 12 Nov 99 Add operators templates (Ed Brey)
|
||||
// 11 Nov 99 Add single template parameter version for compilers without
|
||||
// partial specialization (Beman Dawes)
|
||||
// 10 Nov 99 Initial version
|
||||
|
||||
// 10 Jun 00:
|
||||
// An additional optional template parameter was added to most of
|
||||
// operator templates to support the base class chaining technique (see
|
||||
// documentation for the details). Unfortunately, a straightforward
|
||||
// implementation of this change would have broken compatibility with the
|
||||
// previous version of the library by making it impossible to use the same
|
||||
// template name (e.g. 'addable') for both the 1- and 2-argument versions of
|
||||
// an operator template. This implementation solves the backward-compatibility
|
||||
// issue at the cost of some simplicity.
|
||||
//
|
||||
// One of the complications is an existence of special auxiliary class template
|
||||
// 'is_chained_base<>' (see 'detail' namespace below), which is used
|
||||
// to determine whether its template parameter is a library's operator template
|
||||
// or not. You have to specialize 'is_chained_base<>' for each new
|
||||
// operator template you add to the library.
|
||||
//
|
||||
// However, most of the non-trivial implementation details are hidden behind
|
||||
// several local macros defined below, and as soon as you understand them,
|
||||
// you understand the whole library implementation.
|
||||
|
||||
#ifndef BOOST_OPERATORS_V1_HPP
|
||||
#define BOOST_OPERATORS_V1_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__)
|
||||
# pragma set woff 1234
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1600)
|
||||
# pragma warning( disable : 4284 ) // complaint about return type of
|
||||
#endif // operator-> not begin a UDT
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template <typename T> class empty_base {};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
// In this section we supply the xxxx1 and xxxx2 forms of the operator
|
||||
// templates, which are explicitly targeted at the 1-type-argument and
|
||||
// 2-type-argument operator forms, respectively. Some compilers get confused
|
||||
// when inline friend functions are overloaded in namespaces other than the
|
||||
// global namespace. When BOOST_NO_OPERATORS_IN_NAMESPACE is defined, all of
|
||||
// these templates must go in the global namespace.
|
||||
|
||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
namespace boost
|
||||
{
|
||||
#endif
|
||||
|
||||
// Basic operator classes (contributed by Dave Abrahams) ------------------//
|
||||
|
||||
// Note that friend functions defined in a class are implicitly inline.
|
||||
// See the C++ std, 11.4 [class.friend] paragraph 5
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct less_than_comparable2 : B
|
||||
{
|
||||
friend bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
|
||||
friend bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
|
||||
friend bool operator>(const U& x, const T& y) { return y < x; }
|
||||
friend bool operator<(const U& x, const T& y) { return y > x; }
|
||||
friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
|
||||
};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct less_than_comparable1 : B
|
||||
{
|
||||
friend bool operator>(const T& x, const T& y) { return y < x; }
|
||||
friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
|
||||
};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct equality_comparable2 : B
|
||||
{
|
||||
friend bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct equality_comparable1 : B
|
||||
{
|
||||
friend bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
// A macro which produces "name_2left" from "name".
|
||||
#define BOOST_OPERATOR2_LEFT(name) name##2##_##left
|
||||
|
||||
// NRVO-friendly implementation (contributed by Daniel Frey) ---------------//
|
||||
|
||||
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
|
||||
// This is the optimal implementation for ISO/ANSI C++,
|
||||
// but it requires the compiler to implement the NRVO.
|
||||
// If the compiler has no NRVO, this is the best symmetric
|
||||
// implementation available.
|
||||
|
||||
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||
{ T nrv( rhs ); nrv OP##= lhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
};
|
||||
|
||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
||||
{ \
|
||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
};
|
||||
|
||||
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
|
||||
// For compilers without NRVO the following code is optimal, but not
|
||||
// symmetric! Note that the implementation of
|
||||
// BOOST_OPERATOR2_LEFT(NAME) only looks cool, but doesn't provide
|
||||
// optimization opportunities to the compiler :)
|
||||
|
||||
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
};
|
||||
|
||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
||||
{ \
|
||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||
{ return T( lhs ) OP##= rhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
|
||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( multipliable, * )
|
||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( addable, + )
|
||||
BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( subtractable, - )
|
||||
BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( dividable, / )
|
||||
BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( modable, % )
|
||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( xorable, ^ )
|
||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( andable, & )
|
||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | )
|
||||
|
||||
#undef BOOST_BINARY_OPERATOR_COMMUTATIVE
|
||||
#undef BOOST_BINARY_OPERATOR_NON_COMMUTATIVE
|
||||
#undef BOOST_OPERATOR2_LEFT
|
||||
|
||||
// incrementable and decrementable contributed by Jeremy Siek
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct incrementable : B
|
||||
{
|
||||
friend T operator++(T& x, int)
|
||||
{
|
||||
incrementable_type nrv(x);
|
||||
++x;
|
||||
return nrv;
|
||||
}
|
||||
private: // The use of this typedef works around a Borland bug
|
||||
typedef T incrementable_type;
|
||||
};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct decrementable : B
|
||||
{
|
||||
friend T operator--(T& x, int)
|
||||
{
|
||||
decrementable_type nrv(x);
|
||||
--x;
|
||||
return nrv;
|
||||
}
|
||||
private: // The use of this typedef works around a Borland bug
|
||||
typedef T decrementable_type;
|
||||
};
|
||||
|
||||
// Iterator operator classes (contributed by Jeremy Siek) ------------------//
|
||||
|
||||
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||
struct dereferenceable : B
|
||||
{
|
||||
P operator->() const
|
||||
{
|
||||
return &*static_cast<const T&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class I, class R, class B = ::boost::detail::empty_base<T> >
|
||||
struct indexable : B
|
||||
{
|
||||
R operator[](I n) const
|
||||
{
|
||||
return *(static_cast<const T&>(*this) + n);
|
||||
}
|
||||
};
|
||||
|
||||
// More operator classes (contributed by Daryle Walker) --------------------//
|
||||
// (NRVO-friendly implementation contributed by Daniel Frey) ---------------//
|
||||
|
||||
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
|
||||
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
};
|
||||
|
||||
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
|
||||
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
|
||||
BOOST_BINARY_OPERATOR( left_shiftable, << )
|
||||
BOOST_BINARY_OPERATOR( right_shiftable, >> )
|
||||
|
||||
#undef BOOST_BINARY_OPERATOR
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct equivalent2 : B
|
||||
{
|
||||
friend bool operator==(const T& x, const U& y)
|
||||
{
|
||||
return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct equivalent1 : B
|
||||
{
|
||||
friend bool operator==(const T&x, const T&y)
|
||||
{
|
||||
return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct partially_ordered2 : B
|
||||
{
|
||||
friend bool operator<=(const T& x, const U& y)
|
||||
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>=(const T& x, const U& y)
|
||||
{ return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>(const U& x, const T& y)
|
||||
{ return y < x; }
|
||||
friend bool operator<(const U& x, const T& y)
|
||||
{ return y > x; }
|
||||
friend bool operator<=(const U& x, const T& y)
|
||||
{ return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
|
||||
friend bool operator>=(const U& x, const T& y)
|
||||
{ return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
|
||||
};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct partially_ordered1 : B
|
||||
{
|
||||
friend bool operator>(const T& x, const T& y)
|
||||
{ return y < x; }
|
||||
friend bool operator<=(const T& x, const T& y)
|
||||
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>=(const T& x, const T& y)
|
||||
{ return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
// Combined operator classes (contributed by Daryle Walker) ----------------//
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct totally_ordered2
|
||||
: less_than_comparable2<T, U
|
||||
, equality_comparable2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct totally_ordered1
|
||||
: less_than_comparable1<T
|
||||
, equality_comparable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct additive2
|
||||
: addable2<T, U
|
||||
, subtractable2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct additive1
|
||||
: addable1<T
|
||||
, subtractable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct multiplicative2
|
||||
: multipliable2<T, U
|
||||
, dividable2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct multiplicative1
|
||||
: multipliable1<T
|
||||
, dividable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct integer_multiplicative2
|
||||
: multiplicative2<T, U
|
||||
, modable2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct integer_multiplicative1
|
||||
: multiplicative1<T
|
||||
, modable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct arithmetic2
|
||||
: additive2<T, U
|
||||
, multiplicative2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct arithmetic1
|
||||
: additive1<T
|
||||
, multiplicative1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct integer_arithmetic2
|
||||
: additive2<T, U
|
||||
, integer_multiplicative2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct integer_arithmetic1
|
||||
: additive1<T
|
||||
, integer_multiplicative1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct bitwise2
|
||||
: xorable2<T, U
|
||||
, andable2<T, U
|
||||
, orable2<T, U, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct bitwise1
|
||||
: xorable1<T
|
||||
, andable1<T
|
||||
, orable1<T, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct unit_steppable
|
||||
: incrementable<T
|
||||
, decrementable<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct shiftable2
|
||||
: left_shiftable2<T, U
|
||||
, right_shiftable2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct shiftable1
|
||||
: left_shiftable1<T
|
||||
, right_shiftable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct ring_operators2
|
||||
: additive2<T, U
|
||||
, subtractable2_left<T, U
|
||||
, multipliable2<T, U, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct ring_operators1
|
||||
: additive1<T
|
||||
, multipliable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_ring_operators2
|
||||
: ring_operators2<T, U
|
||||
, totally_ordered2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_ring_operators1
|
||||
: ring_operators1<T
|
||||
, totally_ordered1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct field_operators2
|
||||
: ring_operators2<T, U
|
||||
, dividable2<T, U
|
||||
, dividable2_left<T, U, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct field_operators1
|
||||
: ring_operators1<T
|
||||
, dividable1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_field_operators2
|
||||
: field_operators2<T, U
|
||||
, totally_ordered2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_field_operators1
|
||||
: field_operators1<T
|
||||
, totally_ordered1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct euclidian_ring_operators2
|
||||
: ring_operators2<T, U
|
||||
, dividable2<T, U
|
||||
, dividable2_left<T, U
|
||||
, modable2<T, U
|
||||
, modable2_left<T, U, B
|
||||
> > > > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct euclidian_ring_operators1
|
||||
: ring_operators1<T
|
||||
, dividable1<T
|
||||
, modable1<T, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_euclidian_ring_operators2
|
||||
: totally_ordered2<T, U
|
||||
, euclidian_ring_operators2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_euclidian_ring_operators1
|
||||
: totally_ordered1<T
|
||||
, euclidian_ring_operators1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct euclidean_ring_operators2
|
||||
: ring_operators2<T, U
|
||||
, dividable2<T, U
|
||||
, dividable2_left<T, U
|
||||
, modable2<T, U
|
||||
, modable2_left<T, U, B
|
||||
> > > > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct euclidean_ring_operators1
|
||||
: ring_operators1<T
|
||||
, dividable1<T
|
||||
, modable1<T, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_euclidean_ring_operators2
|
||||
: totally_ordered2<T, U
|
||||
, euclidean_ring_operators2<T, U, B
|
||||
> > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct ordered_euclidean_ring_operators1
|
||||
: totally_ordered1<T
|
||||
, euclidean_ring_operators1<T, B
|
||||
> > {};
|
||||
|
||||
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||
struct input_iteratable
|
||||
: equality_comparable1<T
|
||||
, incrementable<T
|
||||
, dereferenceable<T, P, B
|
||||
> > > {};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
struct output_iteratable
|
||||
: incrementable<T, B
|
||||
> {};
|
||||
|
||||
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||
struct forward_iteratable
|
||||
: input_iteratable<T, P, B
|
||||
> {};
|
||||
|
||||
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||
struct bidirectional_iteratable
|
||||
: forward_iteratable<T, P
|
||||
, decrementable<T, B
|
||||
> > {};
|
||||
|
||||
// To avoid repeated derivation from equality_comparable,
|
||||
// which is an indirect base class of bidirectional_iterable,
|
||||
// random_access_iteratable must not be derived from totally_ordered1
|
||||
// but from less_than_comparable1 only. (Helmut Zeisel, 02-Dec-2001)
|
||||
template <class T, class P, class D, class R, class B = ::boost::detail::empty_base<T> >
|
||||
struct random_access_iteratable
|
||||
: bidirectional_iteratable<T, P
|
||||
, less_than_comparable1<T
|
||||
, additive2<T, D
|
||||
, indexable<T, D, R, B
|
||||
> > > > {};
|
||||
|
||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
} // namespace boost
|
||||
#endif // BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
|
||||
|
||||
// BOOST_IMPORT_TEMPLATE1 .. BOOST_IMPORT_TEMPLATE4 -
|
||||
//
|
||||
// When BOOST_NO_OPERATORS_IN_NAMESPACE is defined we need a way to import an
|
||||
// operator template into the boost namespace. BOOST_IMPORT_TEMPLATE1 is used
|
||||
// for one-argument forms of operator templates; BOOST_IMPORT_TEMPLATE2 for
|
||||
// two-argument forms. Note that these macros expect to be invoked from within
|
||||
// boost.
|
||||
|
||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
|
||||
// The template is already in boost so we have nothing to do.
|
||||
# define BOOST_IMPORT_TEMPLATE4(template_name)
|
||||
# define BOOST_IMPORT_TEMPLATE3(template_name)
|
||||
# define BOOST_IMPORT_TEMPLATE2(template_name)
|
||||
# define BOOST_IMPORT_TEMPLATE1(template_name)
|
||||
|
||||
#else // BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
|
||||
# ifndef BOOST_NO_USING_TEMPLATE
|
||||
|
||||
// Bring the names in with a using-declaration
|
||||
// to avoid stressing the compiler.
|
||||
# define BOOST_IMPORT_TEMPLATE4(template_name) using ::template_name;
|
||||
# define BOOST_IMPORT_TEMPLATE3(template_name) using ::template_name;
|
||||
# define BOOST_IMPORT_TEMPLATE2(template_name) using ::template_name;
|
||||
# define BOOST_IMPORT_TEMPLATE1(template_name) using ::template_name;
|
||||
|
||||
# else
|
||||
|
||||
// Otherwise, because a Borland C++ 5.5 bug prevents a using declaration
|
||||
// from working, we are forced to use inheritance for that compiler.
|
||||
# define BOOST_IMPORT_TEMPLATE4(template_name) \
|
||||
template <class T, class U, class V, class W, class B = ::boost::detail::empty_base<T> > \
|
||||
struct template_name : ::template_name<T, U, V, W, B> {};
|
||||
|
||||
# define BOOST_IMPORT_TEMPLATE3(template_name) \
|
||||
template <class T, class U, class V, class B = ::boost::detail::empty_base<T> > \
|
||||
struct template_name : ::template_name<T, U, V, B> {};
|
||||
|
||||
# define BOOST_IMPORT_TEMPLATE2(template_name) \
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||
struct template_name : ::template_name<T, U, B> {};
|
||||
|
||||
# define BOOST_IMPORT_TEMPLATE1(template_name) \
|
||||
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||
struct template_name : ::template_name<T, B> {};
|
||||
|
||||
# endif // BOOST_NO_USING_TEMPLATE
|
||||
|
||||
#endif // BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
|
||||
//
|
||||
// Here's where we put it all together, defining the xxxx forms of the templates
|
||||
// in namespace boost. We also define specializations of is_chained_base<> for
|
||||
// the xxxx, xxxx1, and xxxx2 templates, importing them into boost:: as
|
||||
// necessary.
|
||||
//
|
||||
|
||||
// is_chained_base<> - a traits class used to distinguish whether an operator
|
||||
// template argument is being used for base class chaining, or is specifying a
|
||||
// 2nd argument type.
|
||||
|
||||
namespace boost {
|
||||
// A type parameter is used instead of a plain bool because Borland's compiler
|
||||
// didn't cope well with the more obvious non-type template parameter.
|
||||
namespace detail {
|
||||
struct true_t {};
|
||||
struct false_t {};
|
||||
} // namespace detail
|
||||
|
||||
// Unspecialized version assumes that most types are not being used for base
|
||||
// class chaining. We specialize for the operator templates defined in this
|
||||
// library.
|
||||
template<class T> struct is_chained_base {
|
||||
typedef ::boost::detail::false_t value;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// Import a 4-type-argument operator template into boost (if necessary) and
|
||||
// provide a specialization of 'is_chained_base<>' for it.
|
||||
# define BOOST_OPERATOR_TEMPLATE4(template_name4) \
|
||||
BOOST_IMPORT_TEMPLATE4(template_name4) \
|
||||
template<class T, class U, class V, class W, class B> \
|
||||
struct is_chained_base< ::boost::template_name4<T, U, V, W, B> > { \
|
||||
typedef ::boost::detail::true_t value; \
|
||||
};
|
||||
|
||||
// Import a 3-type-argument operator template into boost (if necessary) and
|
||||
// provide a specialization of 'is_chained_base<>' for it.
|
||||
# define BOOST_OPERATOR_TEMPLATE3(template_name3) \
|
||||
BOOST_IMPORT_TEMPLATE3(template_name3) \
|
||||
template<class T, class U, class V, class B> \
|
||||
struct is_chained_base< ::boost::template_name3<T, U, V, B> > { \
|
||||
typedef ::boost::detail::true_t value; \
|
||||
};
|
||||
|
||||
// Import a 2-type-argument operator template into boost (if necessary) and
|
||||
// provide a specialization of 'is_chained_base<>' for it.
|
||||
# define BOOST_OPERATOR_TEMPLATE2(template_name2) \
|
||||
BOOST_IMPORT_TEMPLATE2(template_name2) \
|
||||
template<class T, class U, class B> \
|
||||
struct is_chained_base< ::boost::template_name2<T, U, B> > { \
|
||||
typedef ::boost::detail::true_t value; \
|
||||
};
|
||||
|
||||
// Import a 1-type-argument operator template into boost (if necessary) and
|
||||
// provide a specialization of 'is_chained_base<>' for it.
|
||||
# define BOOST_OPERATOR_TEMPLATE1(template_name1) \
|
||||
BOOST_IMPORT_TEMPLATE1(template_name1) \
|
||||
template<class T, class B> \
|
||||
struct is_chained_base< ::boost::template_name1<T, B> > { \
|
||||
typedef ::boost::detail::true_t value; \
|
||||
};
|
||||
|
||||
// BOOST_OPERATOR_TEMPLATE(template_name) defines template_name<> such that it
|
||||
// can be used for specifying both 1-argument and 2-argument forms. Requires the
|
||||
// existence of two previously defined class templates named '<template_name>1'
|
||||
// and '<template_name>2' which must implement the corresponding 1- and 2-
|
||||
// argument forms.
|
||||
//
|
||||
// The template type parameter O == is_chained_base<U>::value is used to
|
||||
// distinguish whether the 2nd argument to <template_name> is being used for
|
||||
// base class chaining from another boost operator template or is describing a
|
||||
// 2nd operand type. O == true_t only when U is actually an another operator
|
||||
// template from the library. Partial specialization is used to select an
|
||||
// implementation in terms of either '<template_name>1' or '<template_name>2'.
|
||||
//
|
||||
|
||||
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
||||
template <class T \
|
||||
,class U = T \
|
||||
,class B = ::boost::detail::empty_base<T> \
|
||||
,class O = typename is_chained_base<U>::value \
|
||||
> \
|
||||
struct template_name : template_name##2<T, U, B> {}; \
|
||||
\
|
||||
template<class T, class U, class B> \
|
||||
struct template_name<T, U, B, ::boost::detail::true_t> \
|
||||
: template_name##1<T, U> {}; \
|
||||
\
|
||||
template <class T, class B> \
|
||||
struct template_name<T, T, B, ::boost::detail::false_t> \
|
||||
: template_name##1<T, B> {}; \
|
||||
\
|
||||
template<class T, class U, class B, class O> \
|
||||
struct is_chained_base< ::boost::template_name<T, U, B, O> > { \
|
||||
typedef ::boost::detail::true_t value; \
|
||||
}; \
|
||||
\
|
||||
BOOST_OPERATOR_TEMPLATE2(template_name##2) \
|
||||
BOOST_OPERATOR_TEMPLATE1(template_name##1)
|
||||
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
BOOST_OPERATOR_TEMPLATE(less_than_comparable)
|
||||
BOOST_OPERATOR_TEMPLATE(equality_comparable)
|
||||
BOOST_OPERATOR_TEMPLATE(multipliable)
|
||||
BOOST_OPERATOR_TEMPLATE(addable)
|
||||
BOOST_OPERATOR_TEMPLATE(subtractable)
|
||||
BOOST_OPERATOR_TEMPLATE2(subtractable2_left)
|
||||
BOOST_OPERATOR_TEMPLATE(dividable)
|
||||
BOOST_OPERATOR_TEMPLATE2(dividable2_left)
|
||||
BOOST_OPERATOR_TEMPLATE(modable)
|
||||
BOOST_OPERATOR_TEMPLATE2(modable2_left)
|
||||
BOOST_OPERATOR_TEMPLATE(xorable)
|
||||
BOOST_OPERATOR_TEMPLATE(andable)
|
||||
BOOST_OPERATOR_TEMPLATE(orable)
|
||||
|
||||
BOOST_OPERATOR_TEMPLATE1(incrementable)
|
||||
BOOST_OPERATOR_TEMPLATE1(decrementable)
|
||||
|
||||
BOOST_OPERATOR_TEMPLATE2(dereferenceable)
|
||||
BOOST_OPERATOR_TEMPLATE3(indexable)
|
||||
|
||||
BOOST_OPERATOR_TEMPLATE(left_shiftable)
|
||||
BOOST_OPERATOR_TEMPLATE(right_shiftable)
|
||||
BOOST_OPERATOR_TEMPLATE(equivalent)
|
||||
BOOST_OPERATOR_TEMPLATE(partially_ordered)
|
||||
|
||||
BOOST_OPERATOR_TEMPLATE(totally_ordered)
|
||||
BOOST_OPERATOR_TEMPLATE(additive)
|
||||
BOOST_OPERATOR_TEMPLATE(multiplicative)
|
||||
BOOST_OPERATOR_TEMPLATE(integer_multiplicative)
|
||||
BOOST_OPERATOR_TEMPLATE(arithmetic)
|
||||
BOOST_OPERATOR_TEMPLATE(integer_arithmetic)
|
||||
BOOST_OPERATOR_TEMPLATE(bitwise)
|
||||
BOOST_OPERATOR_TEMPLATE1(unit_steppable)
|
||||
BOOST_OPERATOR_TEMPLATE(shiftable)
|
||||
BOOST_OPERATOR_TEMPLATE(ring_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(ordered_ring_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(field_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(ordered_field_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(euclidean_ring_operators)
|
||||
BOOST_OPERATOR_TEMPLATE(ordered_euclidean_ring_operators)
|
||||
BOOST_OPERATOR_TEMPLATE2(input_iteratable)
|
||||
BOOST_OPERATOR_TEMPLATE1(output_iteratable)
|
||||
BOOST_OPERATOR_TEMPLATE2(forward_iteratable)
|
||||
BOOST_OPERATOR_TEMPLATE2(bidirectional_iteratable)
|
||||
BOOST_OPERATOR_TEMPLATE4(random_access_iteratable)
|
||||
|
||||
#undef BOOST_OPERATOR_TEMPLATE
|
||||
#undef BOOST_OPERATOR_TEMPLATE4
|
||||
#undef BOOST_OPERATOR_TEMPLATE3
|
||||
#undef BOOST_OPERATOR_TEMPLATE2
|
||||
#undef BOOST_OPERATOR_TEMPLATE1
|
||||
#undef BOOST_IMPORT_TEMPLATE1
|
||||
#undef BOOST_IMPORT_TEMPLATE2
|
||||
#undef BOOST_IMPORT_TEMPLATE3
|
||||
#undef BOOST_IMPORT_TEMPLATE4
|
||||
|
||||
// The following 'operators' classes can only be used portably if the derived class
|
||||
// declares ALL of the required member operators.
|
||||
template <class T, class U>
|
||||
struct operators2
|
||||
: totally_ordered2<T,U
|
||||
, integer_arithmetic2<T,U
|
||||
, bitwise2<T,U
|
||||
> > > {};
|
||||
|
||||
template <class T, class U = T>
|
||||
struct operators : operators2<T, U> {};
|
||||
|
||||
template <class T> struct operators<T, T>
|
||||
: totally_ordered<T
|
||||
, integer_arithmetic<T
|
||||
, bitwise<T
|
||||
, unit_steppable<T
|
||||
> > > > {};
|
||||
|
||||
// Iterator helper classes (contributed by Jeremy Siek) -------------------//
|
||||
// (Input and output iterator helpers contributed by Daryle Walker) -------//
|
||||
// (Changed to use combined operator classes by Daryle Walker) ------------//
|
||||
template <class T,
|
||||
class V,
|
||||
class D = std::ptrdiff_t,
|
||||
class P = V const *,
|
||||
class R = V const &>
|
||||
struct input_iterator_helper
|
||||
: input_iteratable<T, P
|
||||
, std::iterator<std::input_iterator_tag, V, D, P, R
|
||||
> > {};
|
||||
|
||||
template<class T>
|
||||
struct output_iterator_helper
|
||||
: output_iteratable<T
|
||||
, std::iterator<std::output_iterator_tag, void, void, void, void
|
||||
> >
|
||||
{
|
||||
T& operator*() { return static_cast<T&>(*this); }
|
||||
T& operator++() { return static_cast<T&>(*this); }
|
||||
};
|
||||
|
||||
template <class T,
|
||||
class V,
|
||||
class D = std::ptrdiff_t,
|
||||
class P = V*,
|
||||
class R = V&>
|
||||
struct forward_iterator_helper
|
||||
: forward_iteratable<T, P
|
||||
, std::iterator<std::forward_iterator_tag, V, D, P, R
|
||||
> > {};
|
||||
|
||||
template <class T,
|
||||
class V,
|
||||
class D = std::ptrdiff_t,
|
||||
class P = V*,
|
||||
class R = V&>
|
||||
struct bidirectional_iterator_helper
|
||||
: bidirectional_iteratable<T, P
|
||||
, std::iterator<std::bidirectional_iterator_tag, V, D, P, R
|
||||
> > {};
|
||||
|
||||
template <class T,
|
||||
class V,
|
||||
class D = std::ptrdiff_t,
|
||||
class P = V*,
|
||||
class R = V&>
|
||||
struct random_access_iterator_helper
|
||||
: random_access_iteratable<T, P, D, R
|
||||
, std::iterator<std::random_access_iterator_tag, V, D, P, R
|
||||
> >
|
||||
{
|
||||
friend D requires_difference_operator(const T& x, const T& y) {
|
||||
return x - y;
|
||||
}
|
||||
}; // random_access_iterator_helper
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__)
|
||||
#pragma reset woff 1234
|
||||
#endif
|
||||
|
||||
#endif // BOOST_OPERATORS_V1_HPP
|
@ -1,178 +0,0 @@
|
||||
#ifndef BOOST_REF_HPP_INCLUDED
|
||||
#define BOOST_REF_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
//
|
||||
// ref.hpp - ref/cref, useful helper functions
|
||||
//
|
||||
// Copyright (C) 1999, 2000 Jaakko J<>rvi (jaakko.jarvi@cs.utu.fi)
|
||||
// Copyright (C) 2001, 2002 Peter Dimov
|
||||
// Copyright (C) 2002 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/ref.html for documentation.
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> class reference_wrapper
|
||||
{
|
||||
public:
|
||||
typedef T type;
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
|
||||
|
||||
explicit reference_wrapper(T& t): t_(&t) {}
|
||||
|
||||
#else
|
||||
|
||||
explicit reference_wrapper(T& t): t_(boost::addressof(t)) {}
|
||||
|
||||
#endif
|
||||
|
||||
operator T& () const { return *t_; }
|
||||
|
||||
T& get() const { return *t_; }
|
||||
|
||||
T* get_pointer() const { return t_; }
|
||||
|
||||
private:
|
||||
|
||||
T* t_;
|
||||
};
|
||||
|
||||
# if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
|
||||
# define BOOST_REF_CONST
|
||||
# else
|
||||
# define BOOST_REF_CONST const
|
||||
# endif
|
||||
|
||||
template<class T> inline reference_wrapper<T> BOOST_REF_CONST ref(T & t)
|
||||
{
|
||||
return reference_wrapper<T>(t);
|
||||
}
|
||||
|
||||
template<class T> inline reference_wrapper<T const> BOOST_REF_CONST cref(T const & t)
|
||||
{
|
||||
return reference_wrapper<T const>(t);
|
||||
}
|
||||
|
||||
# undef BOOST_REF_CONST
|
||||
|
||||
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template<typename T>
|
||||
class is_reference_wrapper
|
||||
: public mpl::false_
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class unwrap_reference
|
||||
{
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
# define AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(X) \
|
||||
template<typename T> \
|
||||
class is_reference_wrapper< X > \
|
||||
: public mpl::true_ \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
template<typename T> \
|
||||
class unwrap_reference< X > \
|
||||
{ \
|
||||
public: \
|
||||
typedef T type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T>)
|
||||
#if !defined(BOOST_NO_CV_SPECIALIZATIONS)
|
||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> const)
|
||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> volatile)
|
||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> const volatile)
|
||||
#endif
|
||||
|
||||
# undef AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF
|
||||
|
||||
# else // no partial specialization
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/type.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
typedef char (&yes_reference_wrapper_t)[1];
|
||||
typedef char (&no_reference_wrapper_t)[2];
|
||||
|
||||
no_reference_wrapper_t is_reference_wrapper_test(...);
|
||||
|
||||
template<typename T>
|
||||
yes_reference_wrapper_t is_reference_wrapper_test(type< reference_wrapper<T> >);
|
||||
|
||||
template<bool wrapped>
|
||||
struct reference_unwrapper
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct reference_unwrapper<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename T::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class is_reference_wrapper
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = (
|
||||
sizeof(detail::is_reference_wrapper_test(type<T>()))
|
||||
== sizeof(detail::yes_reference_wrapper_t)));
|
||||
|
||||
typedef ::boost::mpl::bool_<value> type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class unwrap_reference
|
||||
: public detail::reference_unwrapper<
|
||||
is_reference_wrapper<T>::value
|
||||
>::template apply<T>
|
||||
{};
|
||||
|
||||
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_REF_HPP_INCLUDED
|
@ -9,11 +9,16 @@
|
||||
#ifndef BOOST_UTILITY_HPP
|
||||
#define BOOST_UTILITY_HPP
|
||||
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
// Use of this header is discouraged and it will be deprecated.
|
||||
// Please include one or more of the headers below instead.
|
||||
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/utility/binary.hpp>
|
||||
#include <boost/utility/identity_type.hpp>
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
|
||||
#endif // BOOST_UTILITY_HPP
|
||||
|
@ -1,58 +0,0 @@
|
||||
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
|
||||
// Douglas Gregor (gregod@cs.rpi.edu)
|
||||
// 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)
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
#ifndef BOOST_UTILITY_ADDRESSOF_HPP
|
||||
# define BOOST_UTILITY_ADDRESSOF_HPP
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
|
||||
|
||||
// VC7 strips const from nested classes unless we add indirection here
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
|
||||
template<class T> struct _addp
|
||||
{
|
||||
typedef T * type;
|
||||
};
|
||||
|
||||
template <typename T> typename _addp<T>::type
|
||||
|
||||
# else
|
||||
template <typename T> T*
|
||||
# endif
|
||||
addressof(T& v)
|
||||
{
|
||||
return reinterpret_cast<T*>(
|
||||
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
|
||||
}
|
||||
|
||||
// Borland doesn't like casting an array reference to a char reference
|
||||
// but these overloads work around the problem.
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template<typename T,std::size_t N>
|
||||
T (*addressof(T (&t)[N]))[N]
|
||||
{
|
||||
return reinterpret_cast<T(*)[N]>(&t);
|
||||
}
|
||||
|
||||
template<typename T,std::size_t N>
|
||||
const T (*addressof(const T (&t)[N]))[N]
|
||||
{
|
||||
return reinterpret_cast<const T(*)[N]>(&t);
|
||||
}
|
||||
# endif
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_UTILITY_ADDRESSOF_HPP
|
@ -1,6 +1,6 @@
|
||||
// boost utility/base_from_member.hpp header file --------------------------//
|
||||
|
||||
// Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and
|
||||
// Copyright 2001, 2003, 2004, 2012 Daryle Walker. Use, modification, and
|
||||
// distribution are subject to the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or a copy at
|
||||
// <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
@ -10,10 +10,15 @@
|
||||
#ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP
|
||||
#define BOOST_UTILITY_BASE_FROM_MEMBER_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
|
||||
// Base-from-member arity configuration macro ------------------------------//
|
||||
@ -42,17 +47,70 @@
|
||||
// {}
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_PRIVATE_CTR_DEF( z, n, data ) \
|
||||
template < BOOST_PP_ENUM_PARAMS(n, typename T) > \
|
||||
explicit base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) ) \
|
||||
: member( BOOST_PP_ENUM_PARAMS(n, x) ) \
|
||||
{} \
|
||||
#define BOOST_PRIVATE_CTR_DEF( z, n, data ) \
|
||||
template < BOOST_PP_ENUM_PARAMS(n, typename T) > \
|
||||
base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) ) \
|
||||
: member( BOOST_PP_ENUM_PARAMS(n, x) ) \
|
||||
{} \
|
||||
/**/
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Type-unmarking class template -------------------------------------------//
|
||||
|
||||
// Type-trait to get the raw type, i.e. the type without top-level reference nor
|
||||
// cv-qualification, from a type expression. Mainly for function arguments, any
|
||||
// reference part is stripped first.
|
||||
|
||||
// Contributed by Daryle Walker
|
||||
|
||||
template < typename T >
|
||||
struct remove_cv_ref
|
||||
{
|
||||
typedef typename ::boost::remove_cv<typename
|
||||
::boost::remove_reference<T>::type>::type type;
|
||||
|
||||
}; // boost::detail::remove_cv_ref
|
||||
|
||||
// Unmarked-type comparison class template ---------------------------------//
|
||||
|
||||
// Type-trait to check if two type expressions have the same raw type.
|
||||
|
||||
// Contributed by Daryle Walker, based on a work-around by Luc Danton
|
||||
|
||||
template < typename T, typename U >
|
||||
struct is_related
|
||||
: public ::boost::is_same<
|
||||
typename ::boost::detail::remove_cv_ref<T>::type,
|
||||
typename ::boost::detail::remove_cv_ref<U>::type >
|
||||
{};
|
||||
|
||||
// Enable-if-on-unidentical-unmarked-type class template -------------------//
|
||||
|
||||
// Enable-if on the first two type expressions NOT having the same raw type.
|
||||
|
||||
// Contributed by Daryle Walker, based on a work-around by Luc Danton
|
||||
|
||||
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
|
||||
template<typename ...T>
|
||||
struct enable_if_unrelated
|
||||
: public ::boost::enable_if_c<true>
|
||||
{};
|
||||
|
||||
template<typename T, typename U, typename ...U2>
|
||||
struct enable_if_unrelated<T, U, U2...>
|
||||
: public ::boost::disable_if< ::boost::detail::is_related<T, U> >
|
||||
{};
|
||||
#endif
|
||||
|
||||
} // namespace boost::detail
|
||||
|
||||
|
||||
// Base-from-member class template -----------------------------------------//
|
||||
|
||||
// Helper to initialize a base object so a derived class can use this
|
||||
@ -68,12 +126,39 @@ class base_from_member
|
||||
protected:
|
||||
MemberType member;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) && \
|
||||
!(defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4))
|
||||
template <typename ...T, typename EnableIf = typename
|
||||
::boost::detail::enable_if_unrelated<base_from_member, T...>::type>
|
||||
explicit BOOST_CONSTEXPR base_from_member( T&& ...x )
|
||||
BOOST_NOEXCEPT_IF( BOOST_NOEXCEPT_EXPR(::new ((void*) 0) MemberType(
|
||||
static_cast<T&&>(x)... )) ) // no std::is_nothrow_constructible...
|
||||
: member( static_cast<T&&>(x)... ) // ...nor std::forward needed
|
||||
{}
|
||||
#else
|
||||
base_from_member()
|
||||
: member()
|
||||
{}
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
|
||||
template < typename T0 > explicit base_from_member( T0 x0 ) : member( x0 ) {}
|
||||
BOOST_PP_REPEAT_FROM_TO( 2, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
|
||||
BOOST_PRIVATE_CTR_DEF, _ )
|
||||
#endif
|
||||
|
||||
}; // boost::base_from_member
|
||||
|
||||
template < typename MemberType, int UniqueID >
|
||||
class base_from_member<MemberType&, UniqueID>
|
||||
{
|
||||
protected:
|
||||
MemberType& member;
|
||||
|
||||
explicit BOOST_CONSTEXPR base_from_member( MemberType& x )
|
||||
BOOST_NOEXCEPT
|
||||
: member( x )
|
||||
{}
|
||||
|
||||
}; // boost::base_from_member
|
||||
|
||||
|
708
include/boost/utility/binary.hpp
Normal file
708
include/boost/utility/binary.hpp
Normal file
@ -0,0 +1,708 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005 Matthew Calabrese
|
||||
|
||||
Use, modification and distribution is 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)
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef BOOST_UTILITY_BINARY_HPP
|
||||
#define BOOST_UTILITY_BINARY_HPP
|
||||
|
||||
/*=============================================================================
|
||||
|
||||
Binary Literal Utility
|
||||
______________________
|
||||
|
||||
|
||||
The following code works by converting the input bit pattern into a
|
||||
Boost.Preprocessor sequence, then converting groupings of 3 bits each into
|
||||
the corresponding octal digit, and finally concatenating all of the digits
|
||||
together along with a leading zero. This yields a standard octal literal
|
||||
with the desired value as specified in bits.
|
||||
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/preprocessor/control/deduce_d.hpp>
|
||||
#include <boost/preprocessor/facilities/identity.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/seq/cat.hpp>
|
||||
#include <boost/preprocessor/seq/transform.hpp>
|
||||
#include <boost/preprocessor/arithmetic/mod.hpp>
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
#include <boost/preprocessor/facilities/empty.hpp>
|
||||
#include <boost/preprocessor/control/while.hpp>
|
||||
|
||||
#define BOOST_BINARY( bit_groupings ) \
|
||||
BOOST_BINARY_LITERAL_D( BOOST_PP_DEDUCE_D(), bit_groupings )
|
||||
|
||||
#define BOOST_BINARY_U( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, U )
|
||||
|
||||
#define BOOST_BINARY_L( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, L )
|
||||
|
||||
#define BOOST_BINARY_UL( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, UL )
|
||||
|
||||
#define BOOST_BINARY_LU( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LU )
|
||||
|
||||
#define BOOST_BINARY_LL( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LL )
|
||||
|
||||
#define BOOST_BINARY_ULL( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, ULL )
|
||||
|
||||
#define BOOST_BINARY_LLU( bit_groupings ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LLU )
|
||||
|
||||
#define BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, suffix ) \
|
||||
BOOST_SUFFIXED_BINARY_LITERAL_D( BOOST_PP_DEDUCE_D(), bit_groupings, suffix )
|
||||
|
||||
#define BOOST_SUFFIXED_BINARY_LITERAL_D( d, bit_groupings, suffix ) \
|
||||
BOOST_PP_CAT( BOOST_BINARY_LITERAL_D( d, bit_groupings ), suffix )
|
||||
|
||||
#define BOOST_BINARY_LITERAL_D( d, bit_groupings ) \
|
||||
BOOST_PP_SEQ_CAT \
|
||||
( (0) BOOST_DETAIL_CREATE_BINARY_LITERAL_OCTAL_SEQUENCE( d, bit_groupings ) \
|
||||
)
|
||||
|
||||
#define BOOST_DETAIL_CREATE_BINARY_LITERAL_OCTAL_SEQUENCE( d, bit_groupings ) \
|
||||
BOOST_PP_SEQ_TRANSFORM \
|
||||
( BOOST_DETAIL_TRIPLE_TO_OCTAL_OPERATION \
|
||||
, BOOST_PP_NIL \
|
||||
, BOOST_PP_IDENTITY( BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_TRIPLE_SEQUENCE )()\
|
||||
( BOOST_DETAIL_COMPLETE_TRIPLE_SEQUENCE \
|
||||
( \
|
||||
d \
|
||||
, BOOST_DETAIL_CREATE_BINARY_LITERAL_BIT_SEQUENCE( d, bit_groupings ) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_TRIPLE_SEQUENCE( bit_sequence ) \
|
||||
BOOST_PP_CAT \
|
||||
( BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1 bit_sequence \
|
||||
, END_BIT \
|
||||
)
|
||||
|
||||
#define BOOST_DETAIL_BITS_PER_OCTIT 3
|
||||
|
||||
#define BOOST_DETAIL_COMPLETE_TRIPLE_SEQUENCE( d, incomplete_nibble_sequence ) \
|
||||
BOOST_PP_CAT \
|
||||
( BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_ \
|
||||
, BOOST_PP_MOD_D( d \
|
||||
, BOOST_PP_SEQ_SIZE( incomplete_nibble_sequence ) \
|
||||
, BOOST_DETAIL_BITS_PER_OCTIT \
|
||||
) \
|
||||
) \
|
||||
incomplete_nibble_sequence
|
||||
|
||||
#define BOOST_DETAIL_FIXED_COMPL( bit ) \
|
||||
BOOST_PP_CAT( BOOST_DETAIL_FIXED_COMPL_, bit )
|
||||
|
||||
#define BOOST_DETAIL_FIXED_COMPL_0 1
|
||||
|
||||
#define BOOST_DETAIL_FIXED_COMPL_1 0
|
||||
|
||||
#define BOOST_DETAIL_CREATE_BINARY_LITERAL_BIT_SEQUENCE( d, bit_groupings ) \
|
||||
BOOST_PP_EMPTY \
|
||||
BOOST_PP_CAT( BOOST_PP_WHILE_, d ) \
|
||||
( BOOST_DETAIL_BINARY_LITERAL_PREDICATE \
|
||||
, BOOST_DETAIL_BINARY_LITERAL_OPERATION \
|
||||
, bit_groupings () \
|
||||
)
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_PREDICATE( d, state ) \
|
||||
BOOST_DETAIL_FIXED_COMPL( BOOST_DETAIL_IS_NULLARY_ARGS( state ) )
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_OPERATION( d, state ) \
|
||||
BOOST_DETAIL_SPLIT_AND_SWAP \
|
||||
( BOOST_PP_CAT( BOOST_DETAIL_BINARY_LITERAL_ELEMENT_, state ) )
|
||||
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_OPERATION( s, dummy_param, tuple ) \
|
||||
BOOST_DETAIL_TERNARY_TRIPLE_TO_OCTAL tuple
|
||||
|
||||
#define BOOST_DETAIL_TERNARY_TRIPLE_TO_OCTAL( bit2, bit1, bit0 ) \
|
||||
BOOST_DETAIL_TRIPLE_TO_OCTAL_ ## bit2 ## bit1 ## bit0
|
||||
|
||||
#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_1 (0)(0)
|
||||
#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_2 (0)
|
||||
#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_0
|
||||
|
||||
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1END_BIT
|
||||
|
||||
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1( bit ) \
|
||||
( ( bit, BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_2
|
||||
|
||||
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_2( bit ) \
|
||||
bit, BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_3
|
||||
|
||||
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_3( bit ) \
|
||||
bit ) ) BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1
|
||||
|
||||
#define BOOST_DETAIL_SPLIT_AND_SWAP( params ) \
|
||||
BOOST_PP_IDENTITY( BOOST_DETAIL_SPLIT_AND_SWAP_PARAMS )()( params )
|
||||
|
||||
#define BOOST_DETAIL_SPLIT_AND_SWAP_PARAMS( first_param, second_param ) \
|
||||
second_param first_param
|
||||
|
||||
#define BOOST_DETAIL_LEFT_OF_COMMA( params ) \
|
||||
BOOST_PP_IDENTITY( BOOST_DETAIL_FIRST_MACRO_PARAM )()( params )
|
||||
|
||||
#define BOOST_DETAIL_FIRST_MACRO_PARAM( first_param, second_param ) \
|
||||
first_param
|
||||
|
||||
/* Begin derived concepts from Chaos by Paul Mensonides */
|
||||
|
||||
#define BOOST_DETAIL_IS_NULLARY_ARGS( param ) \
|
||||
BOOST_DETAIL_LEFT_OF_COMMA \
|
||||
( BOOST_PP_CAT( BOOST_DETAIL_IS_NULLARY_ARGS_R_ \
|
||||
, BOOST_DETAIL_IS_NULLARY_ARGS_C param \
|
||||
) \
|
||||
)
|
||||
|
||||
#define BOOST_DETAIL_IS_NULLARY_ARGS_C() \
|
||||
1
|
||||
|
||||
#define BOOST_DETAIL_IS_NULLARY_ARGS_R_1 \
|
||||
1, BOOST_PP_NIL
|
||||
|
||||
#define BOOST_DETAIL_IS_NULLARY_ARGS_R_BOOST_DETAIL_IS_NULLARY_ARGS_C \
|
||||
0, BOOST_PP_NIL
|
||||
|
||||
/* End derived concepts from Chaos by Paul Mensonides */
|
||||
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_000 0
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_001 1
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_010 2
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_011 3
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_100 4
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_101 5
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_110 6
|
||||
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_111 7
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0 (0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1 (1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00 (0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01 (0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10 (1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11 (1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00 (0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01 (0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10 (1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11 (1)(1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000 (0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001 (0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010 (0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011 (0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100 (1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101 (1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110 (1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111 (1)(1)(1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000 (0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001 (0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010 (0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011 (0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100 (0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101 (0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110 (0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111 (0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000 (1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001 (1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010 (1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011 (1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100 (1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101 (1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110 (1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111 (1)(1)(1)(1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000 (0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001 (0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010 (0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011 (0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100 (0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101 (0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110 (0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111 (0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000 (0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001 (0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010 (0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011 (0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100 (0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101 (0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110 (0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111 (0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000 (1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001 (1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010 (1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011 (1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100 (1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101 (1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110 (1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111 (1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000 (1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001 (1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010 (1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011 (1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100 (1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101 (1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110 (1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111 (1)(1)(1)(1)(1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000000 (0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000001 (0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000010 (0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000011 (0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000100 (0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000101 (0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000110 (0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000111 (0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001000 (0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001001 (0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001010 (0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001011 (0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001100 (0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001101 (0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001110 (0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001111 (0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010000 (0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010001 (0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010010 (0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010011 (0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010100 (0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010101 (0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010110 (0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010111 (0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011000 (0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011001 (0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011010 (0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011011 (0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011100 (0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011101 (0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011110 (0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011111 (0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100000 (1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100001 (1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100010 (1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100011 (1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100100 (1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100101 (1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100110 (1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100111 (1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101000 (1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101001 (1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101010 (1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101011 (1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101100 (1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101101 (1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101110 (1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101111 (1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110000 (1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110001 (1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110010 (1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110011 (1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110100 (1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110101 (1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110110 (1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110111 (1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111000 (1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111001 (1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111010 (1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111011 (1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111100 (1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111101 (1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111110 (1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111111 (1)(1)(1)(1)(1)(1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000000 (0)(0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000001 (0)(0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000010 (0)(0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000011 (0)(0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000100 (0)(0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000101 (0)(0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000110 (0)(0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000111 (0)(0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001000 (0)(0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001001 (0)(0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001010 (0)(0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001011 (0)(0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001100 (0)(0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001101 (0)(0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001110 (0)(0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001111 (0)(0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010000 (0)(0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010001 (0)(0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010010 (0)(0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010011 (0)(0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010100 (0)(0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010101 (0)(0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010110 (0)(0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010111 (0)(0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011000 (0)(0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011001 (0)(0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011010 (0)(0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011011 (0)(0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011100 (0)(0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011101 (0)(0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011110 (0)(0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011111 (0)(0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100000 (0)(1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100001 (0)(1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100010 (0)(1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100011 (0)(1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100100 (0)(1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100101 (0)(1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100110 (0)(1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100111 (0)(1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101000 (0)(1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101001 (0)(1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101010 (0)(1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101011 (0)(1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101100 (0)(1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101101 (0)(1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101110 (0)(1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101111 (0)(1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110000 (0)(1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110001 (0)(1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110010 (0)(1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110011 (0)(1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110100 (0)(1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110101 (0)(1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110110 (0)(1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110111 (0)(1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111000 (0)(1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111001 (0)(1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111010 (0)(1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111011 (0)(1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111100 (0)(1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111101 (0)(1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111110 (0)(1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111111 (0)(1)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000000 (1)(0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000001 (1)(0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000010 (1)(0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000011 (1)(0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000100 (1)(0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000101 (1)(0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000110 (1)(0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000111 (1)(0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001000 (1)(0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001001 (1)(0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001010 (1)(0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001011 (1)(0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001100 (1)(0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001101 (1)(0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001110 (1)(0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001111 (1)(0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010000 (1)(0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010001 (1)(0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010010 (1)(0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010011 (1)(0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010100 (1)(0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010101 (1)(0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010110 (1)(0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010111 (1)(0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011000 (1)(0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011001 (1)(0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011010 (1)(0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011011 (1)(0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011100 (1)(0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011101 (1)(0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011110 (1)(0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011111 (1)(0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100000 (1)(1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100001 (1)(1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100010 (1)(1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100011 (1)(1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100100 (1)(1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100101 (1)(1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100110 (1)(1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100111 (1)(1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101000 (1)(1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101001 (1)(1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101010 (1)(1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101011 (1)(1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101100 (1)(1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101101 (1)(1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101110 (1)(1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101111 (1)(1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110000 (1)(1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110001 (1)(1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110010 (1)(1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110011 (1)(1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110100 (1)(1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110101 (1)(1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110110 (1)(1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110111 (1)(1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111000 (1)(1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111001 (1)(1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111010 (1)(1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111011 (1)(1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111100 (1)(1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111101 (1)(1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111110 (1)(1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111111 (1)(1)(1)(1)(1)(1)(1),
|
||||
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000000 (0)(0)(0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000001 (0)(0)(0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000010 (0)(0)(0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000011 (0)(0)(0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000100 (0)(0)(0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000101 (0)(0)(0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000110 (0)(0)(0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000111 (0)(0)(0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001000 (0)(0)(0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001001 (0)(0)(0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001010 (0)(0)(0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001011 (0)(0)(0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001100 (0)(0)(0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001101 (0)(0)(0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001110 (0)(0)(0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001111 (0)(0)(0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010000 (0)(0)(0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010001 (0)(0)(0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010010 (0)(0)(0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010011 (0)(0)(0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010100 (0)(0)(0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010101 (0)(0)(0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010110 (0)(0)(0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010111 (0)(0)(0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011000 (0)(0)(0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011001 (0)(0)(0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011010 (0)(0)(0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011011 (0)(0)(0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011100 (0)(0)(0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011101 (0)(0)(0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011110 (0)(0)(0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011111 (0)(0)(0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100000 (0)(0)(1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100001 (0)(0)(1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100010 (0)(0)(1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100011 (0)(0)(1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100100 (0)(0)(1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100101 (0)(0)(1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100110 (0)(0)(1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100111 (0)(0)(1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101000 (0)(0)(1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101001 (0)(0)(1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101010 (0)(0)(1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101011 (0)(0)(1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101100 (0)(0)(1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101101 (0)(0)(1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101110 (0)(0)(1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101111 (0)(0)(1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110000 (0)(0)(1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110001 (0)(0)(1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110010 (0)(0)(1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110011 (0)(0)(1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110100 (0)(0)(1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110101 (0)(0)(1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110110 (0)(0)(1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110111 (0)(0)(1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111000 (0)(0)(1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111001 (0)(0)(1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111010 (0)(0)(1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111011 (0)(0)(1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111100 (0)(0)(1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111101 (0)(0)(1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111110 (0)(0)(1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111111 (0)(0)(1)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000000 (0)(1)(0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000001 (0)(1)(0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000010 (0)(1)(0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000011 (0)(1)(0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000100 (0)(1)(0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000101 (0)(1)(0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000110 (0)(1)(0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000111 (0)(1)(0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001000 (0)(1)(0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001001 (0)(1)(0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001010 (0)(1)(0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001011 (0)(1)(0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001100 (0)(1)(0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001101 (0)(1)(0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001110 (0)(1)(0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001111 (0)(1)(0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010000 (0)(1)(0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010001 (0)(1)(0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010010 (0)(1)(0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010011 (0)(1)(0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010100 (0)(1)(0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010101 (0)(1)(0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010110 (0)(1)(0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010111 (0)(1)(0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011000 (0)(1)(0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011001 (0)(1)(0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011010 (0)(1)(0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011011 (0)(1)(0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011100 (0)(1)(0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011101 (0)(1)(0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011110 (0)(1)(0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011111 (0)(1)(0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100000 (0)(1)(1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100001 (0)(1)(1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100010 (0)(1)(1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100011 (0)(1)(1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100100 (0)(1)(1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100101 (0)(1)(1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100110 (0)(1)(1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100111 (0)(1)(1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101000 (0)(1)(1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101001 (0)(1)(1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101010 (0)(1)(1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101011 (0)(1)(1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101100 (0)(1)(1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101101 (0)(1)(1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101110 (0)(1)(1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101111 (0)(1)(1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110000 (0)(1)(1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110001 (0)(1)(1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110010 (0)(1)(1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110011 (0)(1)(1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110100 (0)(1)(1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110101 (0)(1)(1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110110 (0)(1)(1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110111 (0)(1)(1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111000 (0)(1)(1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111001 (0)(1)(1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111010 (0)(1)(1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111011 (0)(1)(1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111100 (0)(1)(1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111101 (0)(1)(1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111110 (0)(1)(1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111111 (0)(1)(1)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000000 (1)(0)(0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000001 (1)(0)(0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000010 (1)(0)(0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000011 (1)(0)(0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000100 (1)(0)(0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000101 (1)(0)(0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000110 (1)(0)(0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000111 (1)(0)(0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001000 (1)(0)(0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001001 (1)(0)(0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001010 (1)(0)(0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001011 (1)(0)(0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001100 (1)(0)(0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001101 (1)(0)(0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001110 (1)(0)(0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001111 (1)(0)(0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010000 (1)(0)(0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010001 (1)(0)(0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010010 (1)(0)(0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010011 (1)(0)(0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010100 (1)(0)(0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010101 (1)(0)(0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010110 (1)(0)(0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010111 (1)(0)(0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011000 (1)(0)(0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011001 (1)(0)(0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011010 (1)(0)(0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011011 (1)(0)(0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011100 (1)(0)(0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011101 (1)(0)(0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011110 (1)(0)(0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011111 (1)(0)(0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100000 (1)(0)(1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100001 (1)(0)(1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100010 (1)(0)(1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100011 (1)(0)(1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100100 (1)(0)(1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100101 (1)(0)(1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100110 (1)(0)(1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100111 (1)(0)(1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101000 (1)(0)(1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101001 (1)(0)(1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101010 (1)(0)(1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101011 (1)(0)(1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101100 (1)(0)(1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101101 (1)(0)(1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101110 (1)(0)(1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101111 (1)(0)(1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110000 (1)(0)(1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110001 (1)(0)(1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110010 (1)(0)(1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110011 (1)(0)(1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110100 (1)(0)(1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110101 (1)(0)(1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110110 (1)(0)(1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110111 (1)(0)(1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111000 (1)(0)(1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111001 (1)(0)(1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111010 (1)(0)(1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111011 (1)(0)(1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111100 (1)(0)(1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111101 (1)(0)(1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111110 (1)(0)(1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111111 (1)(0)(1)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000000 (1)(1)(0)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000001 (1)(1)(0)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000010 (1)(1)(0)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000011 (1)(1)(0)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000100 (1)(1)(0)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000101 (1)(1)(0)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000110 (1)(1)(0)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000111 (1)(1)(0)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001000 (1)(1)(0)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001001 (1)(1)(0)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001010 (1)(1)(0)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001011 (1)(1)(0)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001100 (1)(1)(0)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001101 (1)(1)(0)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001110 (1)(1)(0)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001111 (1)(1)(0)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010000 (1)(1)(0)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010001 (1)(1)(0)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010010 (1)(1)(0)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010011 (1)(1)(0)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010100 (1)(1)(0)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010101 (1)(1)(0)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010110 (1)(1)(0)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010111 (1)(1)(0)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011000 (1)(1)(0)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011001 (1)(1)(0)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011010 (1)(1)(0)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011011 (1)(1)(0)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011100 (1)(1)(0)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011101 (1)(1)(0)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011110 (1)(1)(0)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011111 (1)(1)(0)(1)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100000 (1)(1)(1)(0)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100001 (1)(1)(1)(0)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100010 (1)(1)(1)(0)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100011 (1)(1)(1)(0)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100100 (1)(1)(1)(0)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100101 (1)(1)(1)(0)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100110 (1)(1)(1)(0)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100111 (1)(1)(1)(0)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101000 (1)(1)(1)(0)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101001 (1)(1)(1)(0)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101010 (1)(1)(1)(0)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101011 (1)(1)(1)(0)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101100 (1)(1)(1)(0)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101101 (1)(1)(1)(0)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101110 (1)(1)(1)(0)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101111 (1)(1)(1)(0)(1)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110000 (1)(1)(1)(1)(0)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110001 (1)(1)(1)(1)(0)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110010 (1)(1)(1)(1)(0)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110011 (1)(1)(1)(1)(0)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110100 (1)(1)(1)(1)(0)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110101 (1)(1)(1)(1)(0)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110110 (1)(1)(1)(1)(0)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110111 (1)(1)(1)(1)(0)(1)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111000 (1)(1)(1)(1)(1)(0)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111001 (1)(1)(1)(1)(1)(0)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111010 (1)(1)(1)(1)(1)(0)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111011 (1)(1)(1)(1)(1)(0)(1)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111100 (1)(1)(1)(1)(1)(1)(0)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111101 (1)(1)(1)(1)(1)(1)(0)(1),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111110 (1)(1)(1)(1)(1)(1)(1)(0),
|
||||
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111111 (1)(1)(1)(1)(1)(1)(1)(1),
|
||||
|
||||
#endif
|
@ -4,7 +4,7 @@
|
||||
// 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/lib/optional for documentation.
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
@ -33,8 +33,12 @@ bool equal_pointees ( OptionalPointee const& x, OptionalPointee const& y )
|
||||
}
|
||||
|
||||
template<class OptionalPointee>
|
||||
struct equal_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>
|
||||
struct equal_pointees_t
|
||||
{
|
||||
typedef bool result_type;
|
||||
typedef OptionalPointee first_argument_type;
|
||||
typedef OptionalPointee second_argument_type;
|
||||
|
||||
bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
|
||||
{ return equal_pointees(x,y) ; }
|
||||
} ;
|
||||
@ -56,8 +60,12 @@ bool less_pointees ( OptionalPointee const& x, OptionalPointee const& y )
|
||||
}
|
||||
|
||||
template<class OptionalPointee>
|
||||
struct less_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>
|
||||
struct less_pointees_t
|
||||
{
|
||||
typedef bool result_type;
|
||||
typedef OptionalPointee first_argument_type;
|
||||
typedef OptionalPointee second_argument_type;
|
||||
|
||||
bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
|
||||
{ return less_pointees(x,y) ; }
|
||||
} ;
|
||||
|
@ -5,7 +5,7 @@
|
||||
// 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/lib/optional for documentation.
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
|
@ -5,7 +5,7 @@
|
||||
// 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/lib/optional for documentation.
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
|
58
include/boost/utility/detail/minstd_rand.hpp
Normal file
58
include/boost/utility/detail/minstd_rand.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
|
||||
#define BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
|
||||
|
||||
// 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
|
||||
//
|
||||
// An implementation of minstd_rand that does not require
|
||||
// the Random library
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class minstd_rand
|
||||
{
|
||||
private:
|
||||
|
||||
boost::uint_least32_t x_;
|
||||
|
||||
enum { a = 48271, m = 2147483647 };
|
||||
|
||||
public:
|
||||
|
||||
minstd_rand(): x_( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
explicit minstd_rand( boost::uint_least32_t x ): x_( x % m )
|
||||
{
|
||||
if( x_ == 0 )
|
||||
{
|
||||
x_ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
boost::uint_least32_t operator()()
|
||||
{
|
||||
boost::uint_least64_t y = x_;
|
||||
|
||||
y = ( a * y ) % m;
|
||||
|
||||
x_ = static_cast<boost::uint_least32_t>( y );
|
||||
|
||||
return x_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
|
@ -5,6 +5,11 @@
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012.
|
||||
// Use, modification and distribution is 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)
|
||||
|
||||
// For more information, see http://www.boost.org/libs/utility
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
# error Boost result_of - do not include this file!
|
||||
@ -17,46 +22,172 @@
|
||||
# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {};
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: conditional<
|
||||
is_pointer<F>::value || is_member_function_pointer<F>::value
|
||||
, boost::detail::tr1_result_of_impl<
|
||||
typename remove_cv<F>::type,
|
||||
typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
|
||||
(boost::detail::result_of_has_result_type<F>::value)>
|
||||
, boost::detail::tr1_result_of_impl<
|
||||
F,
|
||||
F(BOOST_RESULT_OF_ARGS),
|
||||
(boost::detail::result_of_has_result_type<F>::value)> >::type { };
|
||||
#endif
|
||||
|
||||
#undef BOOST_RESULT_OF_ARGS
|
||||
#ifdef BOOST_RESULT_OF_USE_DECLTYPE
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> { };
|
||||
#endif // BOOST_RESULT_OF_USE_DECLTYPE
|
||||
|
||||
#if BOOST_PP_ITERATION() >= 1
|
||||
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: conditional<detail::result_of_has_result_type<F>::value || detail::result_of_has_result<F>::value,
|
||||
tr1_result_of<F(BOOST_RESULT_OF_ARGS)>,
|
||||
detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> >::type { };
|
||||
#endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
||||
|
||||
#if defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct cpp0x_result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
||||
: conditional<
|
||||
is_member_function_pointer<F>::value
|
||||
, detail::tr1_result_of_impl<
|
||||
typename remove_cv<F>::type,
|
||||
typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
|
||||
>
|
||||
, detail::cpp0x_result_of_impl<
|
||||
F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
>
|
||||
>::type
|
||||
{};
|
||||
|
||||
#ifdef BOOST_NO_SFINAE_EXPR
|
||||
|
||||
template<typename F>
|
||||
struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION());
|
||||
|
||||
template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
|
||||
struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<R(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))> {
|
||||
R operator()(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const;
|
||||
typedef result_of_private_type const &(*pfn_t)(...);
|
||||
operator pfn_t() const volatile;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())
|
||||
: BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
|
||||
{};
|
||||
|
||||
template<typename F>
|
||||
struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F *>
|
||||
: BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
|
||||
{};
|
||||
|
||||
template<typename F>
|
||||
struct BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())
|
||||
: conditional<
|
||||
is_class<typename remove_reference<F>::type>::value,
|
||||
result_of_wrap_callable_class<F>,
|
||||
type_identity<BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<typename remove_reference<F>::type>::type> >
|
||||
>::type
|
||||
{};
|
||||
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
|
||||
struct BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION()) {
|
||||
typedef typename BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())<F>::type wrapper_t;
|
||||
static const bool value = (
|
||||
sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
|
||||
(boost::declval<wrapper_t>()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)), result_of_weird_type())
|
||||
))
|
||||
);
|
||||
typedef integral_constant<bool, value> type;
|
||||
};
|
||||
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), true>
|
||||
: lazy_enable_if<
|
||||
BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION())<F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), T)>
|
||||
, cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false>
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false>
|
||||
{
|
||||
typedef decltype(
|
||||
boost::declval<F>()(
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
|
||||
)
|
||||
) type;
|
||||
};
|
||||
|
||||
#else // BOOST_NO_SFINAE_EXPR
|
||||
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
|
||||
typename result_of_always_void<decltype(
|
||||
boost::declval<F>()(
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
|
||||
)
|
||||
)>::type> {
|
||||
typedef decltype(
|
||||
boost::declval<F>()(
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
|
||||
)
|
||||
) type;
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_SFINAE_EXPR
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
|
||||
#endif
|
||||
|
||||
#endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
||||
|
||||
#undef BOOST_RESULT_OF_ARGS
|
||||
|
||||
#if BOOST_PP_ITERATION() >= 1
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of_impl<R (T0::*)
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
||||
FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of_impl<R (T0::*)
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
const,
|
||||
FArgs, false>
|
||||
@ -64,9 +195,8 @@ struct result_of_impl<R (T0::*)
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of_impl<R (T0::*)
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
volatile,
|
||||
FArgs, false>
|
||||
@ -74,9 +204,8 @@ struct result_of_impl<R (T0::*)
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of_impl<R (T0::*)
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
const volatile,
|
||||
FArgs, false>
|
||||
|
@ -1,119 +0,0 @@
|
||||
// Boost enable_if library
|
||||
|
||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
||||
|
||||
// Use, modification, and distribution is 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)
|
||||
|
||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
||||
|
||||
|
||||
#ifndef BOOST_UTILITY_ENABLE_IF_HPP
|
||||
#define BOOST_UTILITY_ENABLE_IF_HPP
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
// Even the definition of enable_if causes problems on some compilers,
|
||||
// so it's macroed out for all compilers that do not support SFINAE
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template <bool B, class T = void>
|
||||
struct enable_if_c {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct enable_if_c<false, T> {};
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct enable_if : public enable_if_c<Cond::value, T> {};
|
||||
|
||||
template <bool B, class T>
|
||||
struct lazy_enable_if_c {
|
||||
typedef typename T::type type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct lazy_enable_if_c<false, T> {};
|
||||
|
||||
template <class Cond, class T>
|
||||
struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
|
||||
|
||||
|
||||
template <bool B, class T = void>
|
||||
struct disable_if_c {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct disable_if_c<true, T> {};
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct disable_if : public disable_if_c<Cond::value, T> {};
|
||||
|
||||
template <bool B, class T>
|
||||
struct lazy_disable_if_c {
|
||||
typedef typename T::type type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct lazy_disable_if_c<true, T> {};
|
||||
|
||||
template <class Cond, class T>
|
||||
struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { typedef void enable_if_default_T; }
|
||||
|
||||
template <typename T>
|
||||
struct enable_if_does_not_work_on_this_compiler;
|
||||
|
||||
template <bool B, class T = detail::enable_if_default_T>
|
||||
struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <bool B, class T = detail::enable_if_default_T>
|
||||
struct disable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <bool B, class T = detail::enable_if_default_T>
|
||||
struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <bool B, class T = detail::enable_if_default_T>
|
||||
struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <class Cond, class T = detail::enable_if_default_T>
|
||||
struct enable_if : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <class Cond, class T = detail::enable_if_default_T>
|
||||
struct disable_if : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <class Cond, class T = detail::enable_if_default_T>
|
||||
struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
template <class Cond, class T = detail::enable_if_default_T>
|
||||
struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_SFINAE
|
||||
|
||||
#endif
|
46
include/boost/utility/identity_type.hpp
Normal file
46
include/boost/utility/identity_type.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
// Copyright (C) 2009-2012 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// (see accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/utility/identity_type
|
||||
|
||||
/** @file
|
||||
Wrap type expressions with round parenthesis so they can be passed to macros
|
||||
even if they contain commas.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_IDENTITY_TYPE_HPP_
|
||||
#define BOOST_IDENTITY_TYPE_HPP_
|
||||
|
||||
#include <boost/type_traits/function_traits.hpp>
|
||||
|
||||
/**
|
||||
@brief This macro allows to wrap the specified type expression within extra
|
||||
round parenthesis so the type can be passed as a single macro parameter even if
|
||||
it contains commas (not already wrapped within round parenthesis).
|
||||
|
||||
@Params
|
||||
@Param{parenthesized_type,
|
||||
The type expression to be passed as macro parameter wrapped by a single set
|
||||
of round parenthesis <c>(...)</c>.
|
||||
This type expression can contain an arbitrary number of commas.
|
||||
}
|
||||
@EndParams
|
||||
|
||||
This macro works on any C++03 compiler (it does not use variadic macros).
|
||||
|
||||
This macro must be prefixed by <c>typename</c> when used within templates.
|
||||
Note that the compiler will not be able to automatically determine function
|
||||
template parameters when they are wrapped with this macro (these parameters
|
||||
need to be explicitly specified when calling the function template).
|
||||
|
||||
On some compilers (like GCC), using this macro on abstract types requires to
|
||||
add and remove a reference to the specified type.
|
||||
*/
|
||||
#define BOOST_IDENTITY_TYPE(parenthesized_type) \
|
||||
/* must NOT prefix this with `::` to work with parenthesized syntax */ \
|
||||
boost::function_traits< void parenthesized_type >::arg1_type
|
||||
|
||||
#endif // #include guard
|
||||
|
@ -5,7 +5,7 @@
|
||||
// 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/lib/optional for documentation.
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
@ -48,15 +48,13 @@ public:
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
void* apply(void* address
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
|
||||
void* apply(void* address) const
|
||||
{
|
||||
return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void* apply(void* address, std::size_t n
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
|
||||
void* apply(void* address, std::size_t n) const
|
||||
{
|
||||
for(char* next = address = this->BOOST_NESTED_TEMPLATE apply<T>(address);
|
||||
!! --n;)
|
||||
|
@ -10,28 +10,164 @@
|
||||
#define BOOST_RESULT_OF_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/ice.hpp>
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/preprocessor.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/facilities/intercept.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_member_function_pointer.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/declval.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
||||
# define BOOST_RESULT_OF_NUM_ARGS 10
|
||||
# define BOOST_RESULT_OF_NUM_ARGS 16
|
||||
#endif
|
||||
|
||||
// Use the decltype-based version of result_of by default if the compiler
|
||||
// supports N3276 <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3276.pdf>.
|
||||
// The user can force the choice by defining BOOST_RESULT_OF_USE_DECLTYPE,
|
||||
// BOOST_RESULT_OF_USE_TR1, or BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK but not more than one!
|
||||
#if (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1)) || \
|
||||
(defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)) || \
|
||||
(defined(BOOST_RESULT_OF_USE_TR1) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK))
|
||||
# error More than one of BOOST_RESULT_OF_USE_DECLTYPE, BOOST_RESULT_OF_USE_TR1 and \
|
||||
BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK cannot be defined at the same time.
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_RESULT_OF_USE_TR1
|
||||
# ifndef BOOST_RESULT_OF_USE_DECLTYPE
|
||||
# ifndef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
||||
# ifndef BOOST_NO_CXX11_DECLTYPE_N3276 // this implies !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
# define BOOST_RESULT_OF_USE_DECLTYPE
|
||||
# else
|
||||
# define BOOST_RESULT_OF_USE_TR1
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<typename F> struct result_of;
|
||||
template<typename F> struct tr1_result_of; // a TR1-style implementation of result_of
|
||||
|
||||
#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
#if !defined(BOOST_NO_SFINAE)
|
||||
namespace detail {
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
||||
typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1
|
||||
typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2
|
||||
|
||||
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
|
||||
template<class T> struct result_of_has_type {};
|
||||
|
||||
template<class T> struct result_of_has_result_type_impl
|
||||
{
|
||||
template<class U> static result_of_yes_type f( result_of_has_type<typename U::result_type>* );
|
||||
template<class U> static result_of_no_type f( ... );
|
||||
|
||||
typedef boost::integral_constant<bool, sizeof(f<T>(0)) == sizeof(result_of_yes_type)> type;
|
||||
};
|
||||
|
||||
template<class T> struct result_of_has_result_type: result_of_has_result_type_impl<T>::type
|
||||
{
|
||||
};
|
||||
|
||||
// Work around a nvcc bug by only defining has_result when it's needed.
|
||||
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
||||
|
||||
template<template<class> class C> struct result_of_has_template {};
|
||||
|
||||
template<class T> struct result_of_has_result_impl
|
||||
{
|
||||
template<class U> static result_of_yes_type f( result_of_has_template<U::template result>* );
|
||||
template<class U> static result_of_no_type f( ... );
|
||||
|
||||
typedef boost::integral_constant<bool, sizeof(f<T>(0)) == sizeof(result_of_yes_type)> type;
|
||||
};
|
||||
|
||||
template<class T> struct result_of_has_result: result_of_has_result_impl<T>::type
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
|
||||
|
||||
template<typename F> struct cpp0x_result_of;
|
||||
|
||||
#ifdef BOOST_NO_SFINAE_EXPR
|
||||
|
||||
// There doesn't seem to be any other way to turn this off such that the presence of
|
||||
// the user-defined operator,() below doesn't cause spurious warning all over the place,
|
||||
// so unconditionally turn it off.
|
||||
#if BOOST_MSVC
|
||||
# pragma warning(disable: 4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used
|
||||
#endif
|
||||
|
||||
struct result_of_private_type {};
|
||||
|
||||
struct result_of_weird_type {
|
||||
friend result_of_private_type operator,(result_of_private_type, result_of_weird_type);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
result_of_no_type result_of_is_private_type(T const &);
|
||||
result_of_yes_type result_of_is_private_type(result_of_private_type);
|
||||
|
||||
template<typename C>
|
||||
struct result_of_callable_class : C {
|
||||
result_of_callable_class();
|
||||
typedef result_of_private_type const &(*pfn_t)(...);
|
||||
operator pfn_t() const volatile;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct result_of_wrap_callable_class {
|
||||
typedef result_of_callable_class<C> type;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct result_of_wrap_callable_class<C const> {
|
||||
typedef result_of_callable_class<C> const type;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct result_of_wrap_callable_class<C volatile> {
|
||||
typedef result_of_callable_class<C> volatile type;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct result_of_wrap_callable_class<C const volatile> {
|
||||
typedef result_of_callable_class<C> const volatile type;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct result_of_wrap_callable_class<C &> {
|
||||
typedef typename result_of_wrap_callable_class<C>::type &type;
|
||||
};
|
||||
|
||||
template<typename F, bool TestCallability = true> struct cpp0x_result_of_impl;
|
||||
|
||||
#else // BOOST_NO_SFINAE_EXPR
|
||||
|
||||
template<typename T>
|
||||
struct result_of_always_void
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
|
||||
|
||||
#endif // BOOST_NO_SFINAE_EXPR
|
||||
|
||||
template<typename F>
|
||||
struct result_of_void_impl
|
||||
@ -51,27 +187,32 @@ struct result_of_void_impl<R (&)(void)>
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
// Determine the return type of a function pointer or pointer to member.
|
||||
template<typename F, typename FArgs>
|
||||
struct result_of_impl<F, FArgs, true>
|
||||
struct result_of_pointer
|
||||
: tr1_result_of_impl<typename remove_cv<F>::type, FArgs, false> { };
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct tr1_result_of_impl<F, FArgs, true>
|
||||
{
|
||||
typedef typename F::result_type type;
|
||||
};
|
||||
|
||||
template<typename FArgs>
|
||||
struct is_function_with_no_args : mpl::false_ {};
|
||||
struct is_function_with_no_args : false_type {};
|
||||
|
||||
template<typename F>
|
||||
struct is_function_with_no_args<F(void)> : mpl::true_ {};
|
||||
struct is_function_with_no_args<F(void)> : true_type {};
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct result_of_nested_result : F::template result<FArgs>
|
||||
{};
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct result_of_impl<F, FArgs, false>
|
||||
: mpl::if_<is_function_with_no_args<FArgs>,
|
||||
result_of_void_impl<F>,
|
||||
result_of_nested_result<F, FArgs> >::type
|
||||
struct tr1_result_of_impl<F, FArgs, false>
|
||||
: conditional<is_function_with_no_args<FArgs>::value,
|
||||
result_of_void_impl<F>,
|
||||
result_of_nested_result<F, FArgs> >::type
|
||||
{};
|
||||
|
||||
} // end namespace detail
|
||||
@ -79,6 +220,11 @@ struct result_of_impl<F, FArgs, false>
|
||||
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#if 0
|
||||
// inform dependency trackers, as they can't see through macro includes
|
||||
#include <boost/utility/detail/result_of_iterate.hpp>
|
||||
#endif
|
||||
|
||||
#else
|
||||
# define BOOST_NO_RESULT_OF 1
|
||||
#endif
|
||||
|
516
include/boost/utility/string_ref.hpp
Normal file
516
include/boost/utility/string_ref.hpp
Normal file
@ -0,0 +1,516 @@
|
||||
/*
|
||||
Copyright (c) Marshall Clow 2012-2015.
|
||||
Copyright (c) Glen Joseph Fernandes 2019 (glenjofe@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)
|
||||
|
||||
For more information, see http://www.boost.org
|
||||
|
||||
Based on the StringRef implementation in LLVM (http://llvm.org) and
|
||||
N3422 by Jeffrey Yasskin
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BOOST_STRING_REF_HPP
|
||||
#define BOOST_STRING_REF_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/io/ostream_put.hpp>
|
||||
#include <boost/utility/string_ref_fwd.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_GCC) && ((BOOST_GCC+0) / 100) <= 406)
|
||||
// GCC 4.6 cannot handle a defaulted function with noexcept specifier
|
||||
#define BOOST_STRING_REF_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
// A helper functor because sometimes we don't have lambdas
|
||||
template <typename charT, typename traits>
|
||||
class string_ref_traits_eq {
|
||||
public:
|
||||
string_ref_traits_eq ( charT ch ) : ch_(ch) {}
|
||||
bool operator () ( charT val ) const { return traits::eq ( ch_, val ); }
|
||||
charT ch_;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
class basic_string_ref {
|
||||
public:
|
||||
// types
|
||||
typedef charT value_type;
|
||||
typedef const charT* pointer;
|
||||
typedef const charT& reference;
|
||||
typedef const charT& const_reference;
|
||||
typedef pointer const_iterator; // impl-defined
|
||||
typedef const_iterator iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
static BOOST_CONSTEXPR_OR_CONST size_type npos = size_type(-1);
|
||||
|
||||
// construct/copy
|
||||
BOOST_CONSTEXPR basic_string_ref () BOOST_NOEXCEPT
|
||||
: ptr_(NULL), len_(0) {}
|
||||
|
||||
// by defaulting these functions, basic_string_ref becomes
|
||||
// trivially copy/move constructible.
|
||||
BOOST_CONSTEXPR basic_string_ref (const basic_string_ref &rhs) BOOST_NOEXCEPT
|
||||
#ifndef BOOST_STRING_REF_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
= default;
|
||||
#else
|
||||
: ptr_(rhs.ptr_), len_(rhs.len_) {}
|
||||
#endif
|
||||
|
||||
basic_string_ref& operator=(const basic_string_ref &rhs) BOOST_NOEXCEPT
|
||||
#ifndef BOOST_STRING_REF_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
= default;
|
||||
#else
|
||||
{
|
||||
ptr_ = rhs.ptr_;
|
||||
len_ = rhs.len_;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
basic_string_ref(const charT* str) BOOST_NOEXCEPT
|
||||
: ptr_(str), len_(traits::length(str)) {}
|
||||
|
||||
template<typename Allocator>
|
||||
basic_string_ref(const std::basic_string<charT, traits, Allocator>& str)
|
||||
: ptr_(str.data()), len_(str.length()) {}
|
||||
|
||||
// #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
// // Constructing a string_ref from a temporary string is a bad idea
|
||||
// template<typename Allocator>
|
||||
// basic_string_ref( std::basic_string<charT, traits, Allocator>&&)
|
||||
// = delete;
|
||||
// #endif
|
||||
|
||||
BOOST_CONSTEXPR basic_string_ref(const charT* str, size_type len) BOOST_NOEXCEPT
|
||||
: ptr_(str), len_(len) {}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
|
||||
template<typename Allocator>
|
||||
explicit operator std::basic_string<charT, traits, Allocator>() const {
|
||||
return std::basic_string<charT, traits, Allocator> ( begin(), end());
|
||||
}
|
||||
#endif
|
||||
|
||||
std::basic_string<charT, traits> to_string () const {
|
||||
return std::basic_string<charT, traits> ( begin(), end());
|
||||
}
|
||||
|
||||
// iterators
|
||||
BOOST_CONSTEXPR const_iterator begin() const { return ptr_; }
|
||||
BOOST_CONSTEXPR const_iterator cbegin() const { return ptr_; }
|
||||
BOOST_CONSTEXPR const_iterator end() const { return ptr_ + len_; }
|
||||
BOOST_CONSTEXPR const_iterator cend() const { return ptr_ + len_; }
|
||||
const_reverse_iterator rbegin() const { return const_reverse_iterator (end()); }
|
||||
const_reverse_iterator crbegin() const { return const_reverse_iterator (end()); }
|
||||
const_reverse_iterator rend() const { return const_reverse_iterator (begin()); }
|
||||
const_reverse_iterator crend() const { return const_reverse_iterator (begin()); }
|
||||
|
||||
// capacity
|
||||
BOOST_CONSTEXPR size_type size() const { return len_; }
|
||||
BOOST_CONSTEXPR size_type length() const { return len_; }
|
||||
BOOST_CONSTEXPR size_type max_size() const { return len_; }
|
||||
BOOST_CONSTEXPR bool empty() const { return len_ == 0; }
|
||||
|
||||
// element access
|
||||
BOOST_CONSTEXPR const charT& operator[](size_type pos) const { return ptr_[pos]; }
|
||||
|
||||
const charT& at(size_t pos) const {
|
||||
if ( pos >= len_ )
|
||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "boost::string_ref::at" ) );
|
||||
return ptr_[pos];
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR const charT& front() const { return ptr_[0]; }
|
||||
BOOST_CONSTEXPR const charT& back() const { return ptr_[len_-1]; }
|
||||
BOOST_CONSTEXPR const charT* data() const { return ptr_; }
|
||||
|
||||
// modifiers
|
||||
void clear() { len_ = 0; }
|
||||
void remove_prefix(size_type n) {
|
||||
if ( n > len_ )
|
||||
n = len_;
|
||||
ptr_ += n;
|
||||
len_ -= n;
|
||||
}
|
||||
|
||||
void remove_suffix(size_type n) {
|
||||
if ( n > len_ )
|
||||
n = len_;
|
||||
len_ -= n;
|
||||
}
|
||||
|
||||
|
||||
// basic_string_ref string operations
|
||||
basic_string_ref substr(size_type pos, size_type n=npos) const {
|
||||
if ( pos > size())
|
||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_ref::substr" ) );
|
||||
return basic_string_ref(data() + pos, (std::min)(size() - pos, n));
|
||||
}
|
||||
|
||||
int compare(basic_string_ref x) const {
|
||||
const int cmp = traits::compare ( ptr_, x.ptr_, (std::min)(len_, x.len_));
|
||||
return cmp != 0 ? cmp : ( len_ == x.len_ ? 0 : len_ < x.len_ ? -1 : 1 );
|
||||
}
|
||||
|
||||
bool starts_with(charT c) const { return !empty() && traits::eq ( c, front()); }
|
||||
bool starts_with(basic_string_ref x) const {
|
||||
return len_ >= x.len_ && traits::compare ( ptr_, x.ptr_, x.len_ ) == 0;
|
||||
}
|
||||
|
||||
bool ends_with(charT c) const { return !empty() && traits::eq ( c, back()); }
|
||||
bool ends_with(basic_string_ref x) const {
|
||||
return len_ >= x.len_ && traits::compare ( ptr_ + len_ - x.len_, x.ptr_, x.len_ ) == 0;
|
||||
}
|
||||
|
||||
size_type find(basic_string_ref s) const {
|
||||
if (s.empty()) return 0;
|
||||
const_iterator iter = std::search ( this->cbegin (), this->cend (),
|
||||
s.cbegin (), s.cend (), traits::eq );
|
||||
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
|
||||
}
|
||||
|
||||
size_type find(charT c) const {
|
||||
const_iterator iter = std::find_if ( this->cbegin (), this->cend (),
|
||||
detail::string_ref_traits_eq<charT, traits> ( c ));
|
||||
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
|
||||
}
|
||||
|
||||
size_type rfind(basic_string_ref s) const {
|
||||
if (s.empty()) return 0;
|
||||
const_reverse_iterator iter = std::search ( this->crbegin (), this->crend (),
|
||||
s.crbegin (), s.crend (), traits::eq );
|
||||
return iter == this->crend () ? npos : (std::distance(iter, this->crend()) - s.size());
|
||||
}
|
||||
|
||||
size_type rfind(charT c) const {
|
||||
const_reverse_iterator iter = std::find_if ( this->crbegin (), this->crend (),
|
||||
detail::string_ref_traits_eq<charT, traits> ( c ));
|
||||
return iter == this->crend () ? npos : (this->size() - 1 - std::distance(this->crbegin(), iter));
|
||||
}
|
||||
|
||||
size_type find_first_of(charT c) const { return find (c); }
|
||||
size_type find_last_of (charT c) const { return rfind (c); }
|
||||
|
||||
size_type find_first_of(basic_string_ref s) const {
|
||||
const_iterator iter = std::find_first_of
|
||||
( this->cbegin (), this->cend (), s.cbegin (), s.cend (), traits::eq );
|
||||
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
|
||||
}
|
||||
|
||||
size_type find_last_of(basic_string_ref s) const {
|
||||
const_reverse_iterator iter = std::find_first_of
|
||||
( this->crbegin (), this->crend (), s.cbegin (), s.cend (), traits::eq );
|
||||
return iter == this->crend () ? npos : (this->size() - 1 - std::distance(this->crbegin(), iter));
|
||||
}
|
||||
|
||||
size_type find_first_not_of(basic_string_ref s) const {
|
||||
const_iterator iter = find_not_of ( this->cbegin (), this->cend (), s );
|
||||
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
|
||||
}
|
||||
|
||||
size_type find_first_not_of(charT c) const {
|
||||
for ( const_iterator iter = this->cbegin (); iter != this->cend (); ++iter )
|
||||
if ( !traits::eq ( c, *iter ))
|
||||
return std::distance ( this->cbegin (), iter );
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_type find_last_not_of(basic_string_ref s) const {
|
||||
const_reverse_iterator iter = find_not_of ( this->crbegin (), this->crend (), s );
|
||||
return iter == this->crend () ? npos : (this->size() - 1 - std::distance(this->crbegin(), iter));
|
||||
}
|
||||
|
||||
size_type find_last_not_of(charT c) const {
|
||||
for ( const_reverse_iterator iter = this->crbegin (); iter != this->crend (); ++iter )
|
||||
if ( !traits::eq ( c, *iter ))
|
||||
return this->size() - 1 - std::distance(this->crbegin(), iter);
|
||||
return npos;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template <typename Iterator>
|
||||
Iterator find_not_of ( Iterator first, Iterator last, basic_string_ref s ) const {
|
||||
for ( ; first != last ; ++first )
|
||||
if ( 0 == traits::find ( s.ptr_, s.len_, *first ))
|
||||
return first;
|
||||
return last;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const charT *ptr_;
|
||||
std::size_t len_;
|
||||
};
|
||||
|
||||
|
||||
// Comparison operators
|
||||
// Equality
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator==(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
|
||||
if ( x.size () != y.size ()) return false;
|
||||
return x.compare(y) == 0;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator==(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
|
||||
return x == basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator==(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) == y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator==(basic_string_ref<charT, traits> x, const charT * y) {
|
||||
return x == basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator==(const charT * x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) == y;
|
||||
}
|
||||
|
||||
// Inequality
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator!=(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
|
||||
if ( x.size () != y.size ()) return true;
|
||||
return x.compare(y) != 0;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator!=(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
|
||||
return x != basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator!=(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) != y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator!=(basic_string_ref<charT, traits> x, const charT * y) {
|
||||
return x != basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator!=(const charT * x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) != y;
|
||||
}
|
||||
|
||||
// Less than
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator<(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
|
||||
return x.compare(y) < 0;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator<(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
|
||||
return x < basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator<(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) < y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator<(basic_string_ref<charT, traits> x, const charT * y) {
|
||||
return x < basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator<(const charT * x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) < y;
|
||||
}
|
||||
|
||||
// Greater than
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator>(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
|
||||
return x.compare(y) > 0;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator>(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
|
||||
return x > basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator>(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) > y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator>(basic_string_ref<charT, traits> x, const charT * y) {
|
||||
return x > basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator>(const charT * x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) > y;
|
||||
}
|
||||
|
||||
// Less than or equal to
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator<=(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
|
||||
return x.compare(y) <= 0;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator<=(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
|
||||
return x <= basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator<=(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) <= y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator<=(basic_string_ref<charT, traits> x, const charT * y) {
|
||||
return x <= basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator<=(const charT * x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) <= y;
|
||||
}
|
||||
|
||||
// Greater than or equal to
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator>=(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
|
||||
return x.compare(y) >= 0;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator>=(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
|
||||
return x >= basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline bool operator>=(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) >= y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator>=(basic_string_ref<charT, traits> x, const charT * y) {
|
||||
return x >= basic_string_ref<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline bool operator>=(const charT * x, basic_string_ref<charT, traits> y) {
|
||||
return basic_string_ref<charT, traits>(x) >= y;
|
||||
}
|
||||
|
||||
// Inserter
|
||||
template<class charT, class traits>
|
||||
inline std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
|
||||
return boost::io::ostream_put(os, str.data(), str.size());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// numeric conversions
|
||||
//
|
||||
// These are short-term implementations.
|
||||
// In a production environment, I would rather avoid the copying.
|
||||
//
|
||||
inline int stoi (string_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoi ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline long stol (string_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stol ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long stoul (string_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoul ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline long long stoll (string_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoll ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long long stoull (string_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoull ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline float stof (string_ref str, size_t* idx=0) {
|
||||
return std::stof ( std::string(str), idx );
|
||||
}
|
||||
|
||||
inline double stod (string_ref str, size_t* idx=0) {
|
||||
return std::stod ( std::string(str), idx );
|
||||
}
|
||||
|
||||
inline long double stold (string_ref str, size_t* idx=0) {
|
||||
return std::stold ( std::string(str), idx );
|
||||
}
|
||||
|
||||
inline int stoi (wstring_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoi ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline long stol (wstring_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stol ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long stoul (wstring_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoul ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline long long stoll (wstring_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoll ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long long stoull (wstring_ref str, size_t* idx=0, int base=10) {
|
||||
return std::stoull ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline float stof (wstring_ref str, size_t* idx=0) {
|
||||
return std::stof ( std::wstring(str), idx );
|
||||
}
|
||||
|
||||
inline double stod (wstring_ref str, size_t* idx=0) {
|
||||
return std::stod ( std::wstring(str), idx );
|
||||
}
|
||||
|
||||
inline long double stold (wstring_ref str, size_t* idx=0) {
|
||||
return std::stold ( std::wstring(str), idx );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
namespace std {
|
||||
// Hashing
|
||||
template<> struct hash<boost::string_ref>;
|
||||
template<> struct hash<boost::u16string_ref>;
|
||||
template<> struct hash<boost::u32string_ref>;
|
||||
template<> struct hash<boost::wstring_ref>;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
37
include/boost/utility/string_ref_fwd.hpp
Normal file
37
include/boost/utility/string_ref_fwd.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) Marshall Clow 2012-2012.
|
||||
|
||||
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)
|
||||
|
||||
For more information, see http://www.boost.org
|
||||
|
||||
Based on the StringRef implementation in LLVM (http://llvm.org) and
|
||||
N3422 by Jeffrey Yasskin
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BOOST_STRING_REF_FWD_HPP
|
||||
#define BOOST_STRING_REF_FWD_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<typename charT, typename traits = std::char_traits<charT> > class basic_string_ref;
|
||||
typedef basic_string_ref<char, std::char_traits<char> > string_ref;
|
||||
typedef basic_string_ref<wchar_t, std::char_traits<wchar_t> > wstring_ref;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
typedef basic_string_ref<char16_t, std::char_traits<char16_t> > u16string_ref;
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
typedef basic_string_ref<char32_t, std::char_traits<char32_t> > u32string_ref;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
671
include/boost/utility/string_view.hpp
Normal file
671
include/boost/utility/string_view.hpp
Normal file
@ -0,0 +1,671 @@
|
||||
/*
|
||||
Copyright (c) Marshall Clow 2012-2015.
|
||||
Copyright (c) Beman Dawes 2015
|
||||
Copyright (c) Glen Joseph Fernandes 2019 (glenjofe@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)
|
||||
|
||||
For more information, see http://www.boost.org
|
||||
|
||||
Based on the StringRef implementation in LLVM (http://llvm.org) and
|
||||
N3422 by Jeffrey Yasskin
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
|
||||
Updated July 2015 to reflect the Library Fundamentals TS
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html
|
||||
*/
|
||||
|
||||
#ifndef BOOST_STRING_VIEW_HPP
|
||||
#define BOOST_STRING_VIEW_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/io/ostream_put.hpp>
|
||||
#include <boost/utility/string_view_fwd.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <iosfwd>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_GCC) && ((BOOST_GCC+0) / 100) <= 406)
|
||||
// GCC 4.6 cannot handle a defaulted function with noexcept specifier
|
||||
#define BOOST_STRING_VIEW_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
// A helper functor because sometimes we don't have lambdas
|
||||
template <typename charT, typename traits>
|
||||
class string_view_traits_eq {
|
||||
public:
|
||||
string_view_traits_eq ( charT ch ) : ch_(ch) {}
|
||||
bool operator()( charT val ) const { return traits::eq (ch_, val); }
|
||||
charT ch_;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename charT, typename traits> // traits defaulted in string_view_fwd.hpp
|
||||
class basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef traits traits_type;
|
||||
typedef charT value_type;
|
||||
typedef charT* pointer;
|
||||
typedef const charT* const_pointer;
|
||||
typedef charT& reference;
|
||||
typedef const charT& const_reference;
|
||||
typedef const_pointer const_iterator; // impl-defined
|
||||
typedef const_iterator iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
static BOOST_CONSTEXPR_OR_CONST size_type npos = size_type(-1);
|
||||
|
||||
// construct/copy
|
||||
BOOST_CONSTEXPR basic_string_view() BOOST_NOEXCEPT
|
||||
: ptr_(NULL), len_(0) {}
|
||||
|
||||
// by defaulting these functions, basic_string_ref becomes
|
||||
// trivially copy/move constructible.
|
||||
BOOST_CONSTEXPR basic_string_view(const basic_string_view &rhs) BOOST_NOEXCEPT
|
||||
#ifndef BOOST_STRING_VIEW_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
= default;
|
||||
#else
|
||||
: ptr_(rhs.ptr_), len_(rhs.len_) {}
|
||||
#endif
|
||||
|
||||
basic_string_view& operator=(const basic_string_view &rhs) BOOST_NOEXCEPT
|
||||
#ifndef BOOST_STRING_VIEW_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
= default;
|
||||
#else
|
||||
{
|
||||
ptr_ = rhs.ptr_;
|
||||
len_ = rhs.len_;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Allocator>
|
||||
basic_string_view(const std::basic_string<charT, traits, Allocator>& str) BOOST_NOEXCEPT
|
||||
: ptr_(str.data()), len_(str.length()) {}
|
||||
|
||||
// #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
// // Constructing a string_view from a temporary string is a bad idea
|
||||
// template<typename Allocator>
|
||||
// basic_string_view( std::basic_string<charT, traits, Allocator>&&)
|
||||
// = delete;
|
||||
// #endif
|
||||
|
||||
BOOST_CONSTEXPR basic_string_view(const charT* str)
|
||||
: ptr_(str), len_(traits::length(str)) {}
|
||||
|
||||
BOOST_CONSTEXPR basic_string_view(const charT* str, size_type len)
|
||||
: ptr_(str), len_(len) {}
|
||||
|
||||
// iterators
|
||||
BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return ptr_; }
|
||||
BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return ptr_; }
|
||||
BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return ptr_ + len_; }
|
||||
BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return ptr_ + len_; }
|
||||
const_reverse_iterator rbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator crbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator rend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); }
|
||||
const_reverse_iterator crend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); }
|
||||
|
||||
// capacity
|
||||
BOOST_CONSTEXPR size_type size() const BOOST_NOEXCEPT { return len_; }
|
||||
BOOST_CONSTEXPR size_type length() const BOOST_NOEXCEPT { return len_; }
|
||||
BOOST_CONSTEXPR size_type max_size() const BOOST_NOEXCEPT { return len_; }
|
||||
BOOST_CONSTEXPR bool empty() const BOOST_NOEXCEPT { return len_ == 0; }
|
||||
|
||||
// element access
|
||||
BOOST_CONSTEXPR const_reference operator[](size_type pos) const BOOST_NOEXCEPT { return ptr_[pos]; }
|
||||
|
||||
BOOST_CONSTEXPR const_reference at(size_t pos) const {
|
||||
return pos >= len_ ? BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")), ptr_[0] : ptr_[pos];
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR const_reference front() const { return ptr_[0]; }
|
||||
BOOST_CONSTEXPR const_reference back() const { return ptr_[len_-1]; }
|
||||
BOOST_CONSTEXPR const_pointer data() const BOOST_NOEXCEPT { return ptr_; }
|
||||
|
||||
// modifiers
|
||||
void clear() BOOST_NOEXCEPT { len_ = 0; } // Boost extension
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void remove_prefix(size_type n) {
|
||||
if ( n > len_ )
|
||||
n = len_;
|
||||
ptr_ += n;
|
||||
len_ -= n;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void remove_suffix(size_type n) {
|
||||
if ( n > len_ )
|
||||
n = len_;
|
||||
len_ -= n;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void swap(basic_string_view& s) BOOST_NOEXCEPT {
|
||||
std::swap(ptr_, s.ptr_);
|
||||
std::swap(len_, s.len_);
|
||||
}
|
||||
|
||||
// basic_string_view string operations
|
||||
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
|
||||
template<typename Allocator>
|
||||
explicit operator std::basic_string<charT, traits, Allocator>() const {
|
||||
return std::basic_string<charT, traits, Allocator>(begin(), end());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
|
||||
template<typename Allocator = std::allocator<charT> >
|
||||
std::basic_string<charT, traits, Allocator> to_string(const Allocator& a = Allocator()) const {
|
||||
return std::basic_string<charT, traits, Allocator>(begin(), end(), a);
|
||||
}
|
||||
#else
|
||||
std::basic_string<charT, traits> to_string() const {
|
||||
return std::basic_string<charT, traits>(begin(), end());
|
||||
}
|
||||
|
||||
template<typename Allocator>
|
||||
std::basic_string<charT, traits, Allocator> to_string(const Allocator& a) const {
|
||||
return std::basic_string<charT, traits, Allocator>(begin(), end(), a);
|
||||
}
|
||||
#endif
|
||||
|
||||
size_type copy(charT* s, size_type n, size_type pos=0) const {
|
||||
if (pos > size())
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range("string_view::copy" ));
|
||||
size_type rlen = (std::min)(n, len_ - pos);
|
||||
traits_type::copy(s, data() + pos, rlen);
|
||||
return rlen;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR basic_string_view substr(size_type pos, size_type n=npos) const {
|
||||
if ( pos > size())
|
||||
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_view::substr" ) );
|
||||
return basic_string_view(data() + pos, (std::min)(size() - pos, n));
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR int compare(basic_string_view x) const BOOST_NOEXCEPT {
|
||||
const int cmp = traits::compare(ptr_, x.ptr_, (std::min)(len_, x.len_));
|
||||
return cmp != 0 ? cmp : (len_ == x.len_ ? 0 : len_ < x.len_ ? -1 : 1);
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR int compare(size_type pos1, size_type n1, basic_string_view x)
|
||||
const BOOST_NOEXCEPT {
|
||||
return substr(pos1, n1).compare(x);
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR int compare(size_type pos1, size_type n1,
|
||||
basic_string_view x, size_type pos2, size_type n2) const {
|
||||
return substr(pos1, n1).compare(x.substr(pos2, n2));
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR int compare(const charT* x) const {
|
||||
return compare(basic_string_view(x));
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR int compare(size_type pos1, size_type n1, const charT* x) const {
|
||||
return substr(pos1, n1).compare(basic_string_view(x));
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR int compare(size_type pos1, size_type n1,
|
||||
const charT* x, size_type n2) const {
|
||||
return substr(pos1, n1).compare(basic_string_view(x, n2));
|
||||
}
|
||||
|
||||
// Searches
|
||||
BOOST_CONSTEXPR bool starts_with(charT c) const BOOST_NOEXCEPT { // Boost extension
|
||||
return !empty() && traits::eq(c, front());
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR bool starts_with(basic_string_view x) const BOOST_NOEXCEPT { // Boost extension
|
||||
return len_ >= x.len_ && traits::compare(ptr_, x.ptr_, x.len_) == 0;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR bool ends_with(charT c) const BOOST_NOEXCEPT { // Boost extension
|
||||
return !empty() && traits::eq(c, back());
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR bool ends_with(basic_string_view x) const BOOST_NOEXCEPT { // Boost extension
|
||||
return len_ >= x.len_ &&
|
||||
traits::compare(ptr_ + len_ - x.len_, x.ptr_, x.len_) == 0;
|
||||
}
|
||||
|
||||
// find
|
||||
BOOST_CXX14_CONSTEXPR size_type find(basic_string_view s, size_type pos = 0) const BOOST_NOEXCEPT {
|
||||
if (pos > size())
|
||||
return npos;
|
||||
if (s.empty())
|
||||
return pos;
|
||||
if (s.size() > size() - pos)
|
||||
return npos;
|
||||
const charT* cur = ptr_ + pos;
|
||||
const charT* last = cend() - s.size() + 1;
|
||||
for (; cur != last ; ++cur) {
|
||||
cur = traits::find(cur, last - cur, s[0]);
|
||||
if (!cur)
|
||||
return npos;
|
||||
if (traits::compare(cur, s.cbegin(), s.size()) == 0)
|
||||
return cur - ptr_;
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type find(charT c, size_type pos = 0) const BOOST_NOEXCEPT {
|
||||
if (pos > size())
|
||||
return npos;
|
||||
const charT* ret_ptr = traits::find(ptr_ + pos, len_ - pos, c);
|
||||
if (ret_ptr)
|
||||
return ret_ptr - ptr_;
|
||||
return npos;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type find(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
|
||||
{ return find(basic_string_view(s, n), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find(const charT* s, size_type pos = 0) const BOOST_NOEXCEPT
|
||||
{ return find(basic_string_view(s), pos); }
|
||||
|
||||
// rfind
|
||||
BOOST_CXX14_CONSTEXPR size_type rfind(basic_string_view s, size_type pos = npos) const BOOST_NOEXCEPT {
|
||||
if (len_ < s.len_)
|
||||
return npos;
|
||||
if (pos > len_ - s.len_)
|
||||
pos = len_ - s.len_;
|
||||
if (s.len_ == 0u) // an empty string is always found
|
||||
return pos;
|
||||
for (const charT* cur = ptr_ + pos; ; --cur) {
|
||||
if (traits::compare(cur, s.ptr_, s.len_) == 0)
|
||||
return cur - ptr_;
|
||||
if (cur == ptr_)
|
||||
return npos;
|
||||
};
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type rfind(charT c, size_type pos = npos) const BOOST_NOEXCEPT
|
||||
{ return rfind(basic_string_view(&c, 1), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type rfind(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
|
||||
{ return rfind(basic_string_view(s, n), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type rfind(const charT* s, size_type pos = npos) const BOOST_NOEXCEPT
|
||||
{ return rfind(basic_string_view(s), pos); }
|
||||
|
||||
// find_first_of
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_of(basic_string_view s, size_type pos = 0) const BOOST_NOEXCEPT {
|
||||
if (pos >= len_ || s.len_ == 0)
|
||||
return npos;
|
||||
const_iterator iter = std::find_first_of
|
||||
(this->cbegin () + pos, this->cend (), s.cbegin (), s.cend (), traits::eq);
|
||||
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_of(charT c, size_type pos = 0) const BOOST_NOEXCEPT
|
||||
{ return find(c, pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_of(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
|
||||
{ return find_first_of(basic_string_view(s, n), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_of(const charT* s, size_type pos = 0) const BOOST_NOEXCEPT
|
||||
{ return find_first_of(basic_string_view(s), pos); }
|
||||
|
||||
// find_last_of
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_of(basic_string_view s, size_type pos = npos) const BOOST_NOEXCEPT {
|
||||
if (s.len_ == 0u)
|
||||
return npos;
|
||||
if (pos >= len_)
|
||||
pos = 0;
|
||||
else
|
||||
pos = len_ - (pos+1);
|
||||
const_reverse_iterator iter = std::find_first_of
|
||||
( this->crbegin () + pos, this->crend (), s.cbegin (), s.cend (), traits::eq );
|
||||
return iter == this->crend () ? npos : reverse_distance ( this->crbegin (), iter);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_of(charT c, size_type pos = npos) const BOOST_NOEXCEPT
|
||||
{ return find_last_of(basic_string_view(&c, 1), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_of(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
|
||||
{ return find_last_of(basic_string_view(s, n), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_of(const charT* s, size_type pos = npos) const BOOST_NOEXCEPT
|
||||
{ return find_last_of(basic_string_view(s), pos); }
|
||||
|
||||
// find_first_not_of
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_not_of(basic_string_view s, size_type pos = 0) const BOOST_NOEXCEPT {
|
||||
if (pos >= len_)
|
||||
return npos;
|
||||
if (s.len_ == 0)
|
||||
return pos;
|
||||
const_iterator iter = find_not_of ( this->cbegin () + pos, this->cend (), s );
|
||||
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_not_of(charT c, size_type pos = 0) const BOOST_NOEXCEPT
|
||||
{ return find_first_not_of(basic_string_view(&c, 1), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_not_of(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
|
||||
{ return find_first_not_of(basic_string_view(s, n), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_first_not_of(const charT* s, size_type pos = 0) const BOOST_NOEXCEPT
|
||||
{ return find_first_not_of(basic_string_view(s), pos); }
|
||||
|
||||
// find_last_not_of
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_not_of(basic_string_view s, size_type pos = npos) const BOOST_NOEXCEPT {
|
||||
if (pos >= len_)
|
||||
pos = len_ - 1;
|
||||
if (s.len_ == 0u)
|
||||
return pos;
|
||||
pos = len_ - (pos+1);
|
||||
const_reverse_iterator iter = find_not_of ( this->crbegin () + pos, this->crend (), s );
|
||||
return iter == this->crend () ? npos : reverse_distance ( this->crbegin (), iter );
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_not_of(charT c, size_type pos = npos) const BOOST_NOEXCEPT
|
||||
{ return find_last_not_of(basic_string_view(&c, 1), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_not_of(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
|
||||
{ return find_last_not_of(basic_string_view(s, n), pos); }
|
||||
BOOST_CXX14_CONSTEXPR size_type find_last_not_of(const charT* s, size_type pos = npos) const BOOST_NOEXCEPT
|
||||
{ return find_last_not_of(basic_string_view(s), pos); }
|
||||
|
||||
private:
|
||||
template <typename r_iter>
|
||||
size_type reverse_distance(r_iter first, r_iter last) const BOOST_NOEXCEPT {
|
||||
// Portability note here: std::distance is not NOEXCEPT, but calling it with a string_view::reverse_iterator will not throw.
|
||||
return len_ - 1 - std::distance ( first, last );
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
Iterator find_not_of(Iterator first, Iterator last, basic_string_view s) const BOOST_NOEXCEPT {
|
||||
for (; first != last ; ++first)
|
||||
if ( 0 == traits::find(s.ptr_, s.len_, *first))
|
||||
return first;
|
||||
return last;
|
||||
}
|
||||
|
||||
const charT *ptr_;
|
||||
std::size_t len_;
|
||||
};
|
||||
|
||||
|
||||
// Comparison operators
|
||||
// Equality
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator==(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
if (x.size () != y.size ()) return false;
|
||||
return x.compare(y) == 0;
|
||||
}
|
||||
|
||||
// Inequality
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator!=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
if ( x.size () != y.size ()) return true;
|
||||
return x.compare(y) != 0;
|
||||
}
|
||||
|
||||
// Less than
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return x.compare(y) < 0;
|
||||
}
|
||||
|
||||
// Greater than
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return x.compare(y) > 0;
|
||||
}
|
||||
|
||||
// Less than or equal to
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return x.compare(y) <= 0;
|
||||
}
|
||||
|
||||
// Greater than or equal to
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return x.compare(y) >= 0;
|
||||
}
|
||||
|
||||
// "sufficient additional overloads of comparison functions"
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator==(basic_string_view<charT, traits> x,
|
||||
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
|
||||
return x == basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator==(const std::basic_string<charT, traits, Allocator> & x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) == y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator==(basic_string_view<charT, traits> x,
|
||||
const charT * y) BOOST_NOEXCEPT {
|
||||
return x == basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator==(const charT * x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) == y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator!=(basic_string_view<charT, traits> x,
|
||||
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
|
||||
return x != basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator!=(const std::basic_string<charT, traits, Allocator> & x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) != y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator!=(basic_string_view<charT, traits> x,
|
||||
const charT * y) BOOST_NOEXCEPT {
|
||||
return x != basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator!=(const charT * x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) != y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<(basic_string_view<charT, traits> x,
|
||||
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
|
||||
return x < basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<(const std::basic_string<charT, traits, Allocator> & x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) < y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<(basic_string_view<charT, traits> x,
|
||||
const charT * y) BOOST_NOEXCEPT {
|
||||
return x < basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<(const charT * x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) < y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>(basic_string_view<charT, traits> x,
|
||||
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
|
||||
return x > basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>(const std::basic_string<charT, traits, Allocator> & x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) > y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>(basic_string_view<charT, traits> x,
|
||||
const charT * y) BOOST_NOEXCEPT {
|
||||
return x > basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>(const charT * x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) > y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<=(basic_string_view<charT, traits> x,
|
||||
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
|
||||
return x <= basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<=(const std::basic_string<charT, traits, Allocator> & x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) <= y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<=(basic_string_view<charT, traits> x,
|
||||
const charT * y) BOOST_NOEXCEPT {
|
||||
return x <= basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator<=(const charT * x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) <= y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>=(basic_string_view<charT, traits> x,
|
||||
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
|
||||
return x >= basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits, typename Allocator>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>=(const std::basic_string<charT, traits, Allocator> & x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) >= y;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>=(basic_string_view<charT, traits> x,
|
||||
const charT * y) BOOST_NOEXCEPT {
|
||||
return x >= basic_string_view<charT, traits>(y);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
inline BOOST_CXX14_CONSTEXPR bool operator>=(const charT * x,
|
||||
basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
|
||||
return basic_string_view<charT, traits>(x) >= y;
|
||||
}
|
||||
|
||||
// Inserter
|
||||
template<class charT, class traits>
|
||||
inline std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os,
|
||||
const basic_string_view<charT,traits>& str) {
|
||||
return boost::io::ostream_put(os, str.data(), str.size());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// numeric conversions
|
||||
//
|
||||
// These are short-term implementations.
|
||||
// In a production environment, I would rather avoid the copying.
|
||||
//
|
||||
inline int stoi (string_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoi ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline long stol (string_view str, size_t* idx=0, int base=10) {
|
||||
return std::stol ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long stoul (string_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoul ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline long long stoll (string_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoll ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long long stoull (string_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoull ( std::string(str), idx, base );
|
||||
}
|
||||
|
||||
inline float stof (string_view str, size_t* idx=0) {
|
||||
return std::stof ( std::string(str), idx );
|
||||
}
|
||||
|
||||
inline double stod (string_view str, size_t* idx=0) {
|
||||
return std::stod ( std::string(str), idx );
|
||||
}
|
||||
|
||||
inline long double stold (string_view str, size_t* idx=0) {
|
||||
return std::stold ( std::string(str), idx );
|
||||
}
|
||||
|
||||
inline int stoi (wstring_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoi ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline long stol (wstring_view str, size_t* idx=0, int base=10) {
|
||||
return std::stol ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long stoul (wstring_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoul ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline long long stoll (wstring_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoll ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline unsigned long long stoull (wstring_view str, size_t* idx=0, int base=10) {
|
||||
return std::stoull ( std::wstring(str), idx, base );
|
||||
}
|
||||
|
||||
inline float stof (wstring_view str, size_t* idx=0) {
|
||||
return std::stof ( std::wstring(str), idx );
|
||||
}
|
||||
|
||||
inline double stod (wstring_view str, size_t* idx=0) {
|
||||
return std::stod ( std::wstring(str), idx );
|
||||
}
|
||||
|
||||
inline long double stold (wstring_view str, size_t* idx=0) {
|
||||
return std::stold ( std::wstring(str), idx );
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class charT, class traits>
|
||||
std::size_t hash_value(basic_string_view<charT, traits> s) {
|
||||
return boost::hash_range(s.begin(), s.end());
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
namespace std {
|
||||
// Hashing
|
||||
template<> struct hash<boost::string_view>;
|
||||
template<> struct hash<boost::u16string_view>;
|
||||
template<> struct hash<boost::u32string_view>;
|
||||
template<> struct hash<boost::wstring_view>;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
39
include/boost/utility/string_view_fwd.hpp
Normal file
39
include/boost/utility/string_view_fwd.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright (c) Marshall Clow 2012-2012.
|
||||
|
||||
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)
|
||||
|
||||
For more information, see http://www.boost.org
|
||||
|
||||
Based on the StringRef implementation in LLVM (http://llvm.org) and
|
||||
N3422 by Jeffrey Yasskin
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
|
||||
Updated July 2015 to reflect the Library Fundamentals TS
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BOOST_STRING_VIEW_FWD_HPP
|
||||
#define BOOST_STRING_VIEW_FWD_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<typename charT, typename traits = std::char_traits<charT> > class basic_string_view;
|
||||
typedef basic_string_view<char, std::char_traits<char> > string_view;
|
||||
typedef basic_string_view<wchar_t, std::char_traits<wchar_t> > wstring_view;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
typedef basic_string_view<char16_t, std::char_traits<char16_t> > u16string_view;
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
typedef basic_string_view<char32_t, std::char_traits<char32_t> > u32string_view;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -5,7 +5,7 @@
|
||||
// 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/lib/optional for documentation.
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
@ -54,8 +54,8 @@ public:
|
||||
|
||||
void* apply (void* address, std::size_t n) const
|
||||
{
|
||||
for(char* next = address = this->apply(address); !! --n;)
|
||||
this->apply(next = next+sizeof(T));
|
||||
for(void* next = address = this->apply(address); !! --n;)
|
||||
this->apply(next = static_cast<char *>(next) + sizeof(T));
|
||||
return address;
|
||||
}
|
||||
|
||||
|
@ -1,81 +1,243 @@
|
||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
||||
// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
|
||||
// Copyright 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)
|
||||
//
|
||||
// 21 Ago 2002 (Created) Fernando Cacciola
|
||||
// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker
|
||||
// 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola
|
||||
// 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola
|
||||
// 20 Feb 2009 (Fixed logical const-ness issues) Niels Dekker, Fernando Cacciola
|
||||
// 03 Apr 2010 (Added initialized<T>, suggested by Jeffrey Hellrung, fixing #3472) Niels Dekker
|
||||
// 30 May 2010 (Made memset call conditional, fixing #3869) Niels Dekker
|
||||
//
|
||||
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
||||
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
||||
|
||||
#include <boost/detail/select_type.hpp>
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
// Note: The implementation of boost::value_initialized had to deal with the
|
||||
// fact that various compilers haven't fully implemented value-initialization.
|
||||
// The constructor of boost::value_initialized<T> works around these compiler
|
||||
// issues, by clearing the bytes of T, before constructing the T object it
|
||||
// contains. More details on these issues are at libs/utility/value_init.htm
|
||||
|
||||
#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
|
||||
#include <boost/swap.hpp>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
// It is safe to ignore the following warning from MSVC 7.1 or higher:
|
||||
// "warning C4351: new behavior: elements of array will be default initialized"
|
||||
#pragma warning(disable: 4351)
|
||||
// It is safe to ignore the following MSVC warning, which may pop up when T is
|
||||
// a const type: "warning C4512: assignment operator could not be generated".
|
||||
#pragma warning(disable: 4512)
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION
|
||||
// Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
|
||||
// suggests that a workaround should be applied, because of compiler issues
|
||||
// regarding value-initialization.
|
||||
#define BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
|
||||
#endif
|
||||
|
||||
// Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND
|
||||
// switches the value-initialization workaround either on or off.
|
||||
#ifndef BOOST_DETAIL_VALUE_INIT_WORKAROUND
|
||||
#ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
|
||||
#define BOOST_DETAIL_VALUE_INIT_WORKAROUND 1
|
||||
#else
|
||||
#define BOOST_DETAIL_VALUE_INIT_WORKAROUND 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace vinit_detail {
|
||||
namespace detail {
|
||||
|
||||
struct zero_init
|
||||
{
|
||||
zero_init()
|
||||
{
|
||||
}
|
||||
|
||||
zero_init( void * p, std::size_t n )
|
||||
{
|
||||
std::memset( p, 0, n );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
class const_T_base
|
||||
class initialized
|
||||
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
|
||||
: detail::zero_init
|
||||
#endif
|
||||
{
|
||||
protected :
|
||||
private:
|
||||
|
||||
const_T_base() : x() {}
|
||||
T data_;
|
||||
|
||||
T x ;
|
||||
} ;
|
||||
|
||||
template<class T>
|
||||
struct non_const_T_base
|
||||
{
|
||||
protected :
|
||||
|
||||
non_const_T_base() : x() {}
|
||||
|
||||
mutable T x ;
|
||||
} ;
|
||||
|
||||
template<class T>
|
||||
struct select_base
|
||||
{
|
||||
typedef
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
typename
|
||||
#endif
|
||||
::boost::detail::if_true< ::boost::is_const<T>::value >
|
||||
::template then< const_T_base<T>, non_const_T_base<T> >::type type ;
|
||||
} ;
|
||||
|
||||
} // namespace vinit_detail
|
||||
|
||||
template<class T>
|
||||
class value_initialized : private vinit_detail::select_base<T>::type
|
||||
{
|
||||
public :
|
||||
|
||||
value_initialized() {}
|
||||
BOOST_GPU_ENABLED
|
||||
initialized():
|
||||
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
|
||||
zero_init( &const_cast< char& >( reinterpret_cast<char const volatile&>( data_ ) ), sizeof( data_ ) ),
|
||||
#endif
|
||||
data_()
|
||||
{
|
||||
}
|
||||
|
||||
operator T&() const { return this->x ; }
|
||||
BOOST_GPU_ENABLED
|
||||
explicit initialized(T const & arg): data_( arg )
|
||||
{
|
||||
}
|
||||
|
||||
T& data() const { return this->x ; }
|
||||
BOOST_GPU_ENABLED
|
||||
T const & data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
T& data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
void swap(initialized & arg)
|
||||
{
|
||||
::boost::swap( this->data(), arg.data() );
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
operator T const &() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
operator T&()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
T const& get ( initialized<T> const& x )
|
||||
{
|
||||
return x.data() ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
T& get ( initialized<T>& x )
|
||||
{
|
||||
return x.data() ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
void swap ( initialized<T> & lhs, initialized<T> & rhs )
|
||||
{
|
||||
lhs.swap(rhs) ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
class value_initialized
|
||||
{
|
||||
private :
|
||||
|
||||
// initialized<T> does value-initialization by default.
|
||||
initialized<T> m_data;
|
||||
|
||||
public :
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
value_initialized()
|
||||
:
|
||||
m_data()
|
||||
{ }
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
T const & data() const
|
||||
{
|
||||
return m_data.data();
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
T& data()
|
||||
{
|
||||
return m_data.data();
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
void swap(value_initialized & arg)
|
||||
{
|
||||
m_data.swap(arg.m_data);
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
operator T const &() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
operator T&()
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
T const& get ( value_initialized<T> const& x )
|
||||
{
|
||||
return x.data() ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
T& get ( value_initialized<T>& x )
|
||||
{
|
||||
return x.data() ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs )
|
||||
{
|
||||
lhs.swap(rhs) ;
|
||||
}
|
||||
|
||||
|
||||
class initialized_value_t
|
||||
{
|
||||
public :
|
||||
|
||||
template <class T> BOOST_GPU_ENABLED operator T() const
|
||||
{
|
||||
return initialized<T>().data();
|
||||
}
|
||||
};
|
||||
|
||||
initialized_value_t const initialized_value = {} ;
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
42
index.html
42
index.html
@ -12,23 +12,33 @@
|
||||
<p>The Boost Utility Library isn't really a single library at all. It is just a
|
||||
collection for components too small to be called libraries in their own right.</p>
|
||||
<p>But that doesn't mean there isn't useful stuff here. Take a look:</p>
|
||||
<blockquote>
|
||||
<p>
|
||||
<a href="assert.html">assert</a><br>
|
||||
<a href="base_from_member.html">base_from_member</a><br>
|
||||
<a href="call_traits.htm">call_traits</a><br>
|
||||
<a href="checked_delete.html">checked_delete</a><br>
|
||||
<a href="compressed_pair.htm">compressed_pair</a><br>
|
||||
<a href="current_function.html">current_function</a><br>
|
||||
<a href="enable_if.html">enable_if</a><br>
|
||||
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
|
||||
<a href="operators.htm">operators</a><br>
|
||||
<a href="throw_exception.html">throw_exception</a><br>
|
||||
<a href="utility.htm">utility</a><br>
|
||||
<a href="value_init.htm">value_init</a></p>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li><a href="doc/html/base_from_member.html">base_from_member</a></li>
|
||||
<li><a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a></li>
|
||||
<li><a href="call_traits.htm">call_traits</a></li>
|
||||
<li><a href="doc/html/compressed_pair.html">compressed_pair</a></li>
|
||||
<li><a href="in_place_factories.html">in_place_factory</a></li>
|
||||
<li><a href="iterator_adaptors.htm">iterator_adaptors</a></li>
|
||||
<li><a href="operators.htm">operators</a></li>
|
||||
<li><a href="utility.htm#result_of">result_of</a></li>
|
||||
<li><a href="throw_exception.html">throw_exception</a></li>
|
||||
<li><a href="utility.htm">utility</a></li>
|
||||
<li><a href="doc/html/string_ref.html">string_ref</a></li>
|
||||
<li><a href="value_init.htm">value_init</a></li>
|
||||
</ul>
|
||||
<p>Over time useful stuff here has moved to more appropriate Boost libraries:</p>
|
||||
<ul>
|
||||
<li><a href="../core/doc/html/core/addressof.html">addressof</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../core/doc/html/core/checked_delete.html">checked_delete</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../type_traits/doc/html/boost_typetraits/reference/declval.html">declval</a> (moved to Boost.TypeTraits)</li>
|
||||
<li><a href="../core/doc/html/core/enable_if.html">enable_if</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../iterator/doc/generator_iterator.htm">generator iterator adaptors</a> (moved to Boost.Iterator)</li>
|
||||
<li><a href="../iterator/doc/html/iterator/algorithms/next_prior.html">next/prior</a> (moved to Boost.Iterator)</li>
|
||||
<li><a href="../core/doc/html/core/noncopyable.html">noncopyable</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../io/doc/html/io.html">ostream_string</a> (moved to Boost.IO)</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See
|
||||
accompanying file <a href="../../LICENSE_1_0.txt">
|
||||
LICENSE_1_0.txt</a> or copy at
|
||||
|
135
meta/libraries.json
Normal file
135
meta/libraries.json
Normal file
@ -0,0 +1,135 @@
|
||||
[
|
||||
{
|
||||
"key": "utility",
|
||||
"name": "Utility",
|
||||
"authors": [
|
||||
"Dave Abrahams and others"
|
||||
],
|
||||
"description": "Class noncopyable plus checked_delete(), checked_array_delete(), next(), prior() function templates, plus base-from-member idiom.",
|
||||
"documentation": "utility.htm",
|
||||
"category": [
|
||||
"Algorithms",
|
||||
"Function-objects",
|
||||
"Memory",
|
||||
"Miscellaneous",
|
||||
"Patterns"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/call_traits",
|
||||
"name": "Call Traits",
|
||||
"authors": [
|
||||
"John Maddock, Howard Hinnant, et al"
|
||||
],
|
||||
"description": "Defines types for passing parameters.",
|
||||
"documentation": "call_traits.htm",
|
||||
"category": [
|
||||
"Generic"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/compressed_pair",
|
||||
"name": "Compressed Pair",
|
||||
"authors": [
|
||||
"John Maddock, Howard Hinnant, et al"
|
||||
],
|
||||
"description": "Empty member optimization.",
|
||||
"documentation": "compressed_pair.htm",
|
||||
"category": [
|
||||
"Data",
|
||||
"Patterns"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/identity_type",
|
||||
"name": "Identity Type",
|
||||
"authors": [
|
||||
"Lorenzo Caminiti"
|
||||
],
|
||||
"description": "Wrap types within round parenthesis so they can always be passed as macro parameters.",
|
||||
"documentation": "identity_type/",
|
||||
"category": [
|
||||
"Preprocessor"
|
||||
],
|
||||
"maintainers": [
|
||||
"Lorenzo Caminiti <lorcaminiti -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/in_place_factories",
|
||||
"name": "In Place Factory, Typed In Place Factory",
|
||||
"authors": [
|
||||
"Fernando Cacciola"
|
||||
],
|
||||
"description": "Generic in-place construction of contained objects with a variadic argument-list.",
|
||||
"documentation": "in_place_factories.html",
|
||||
"category": [
|
||||
"Generic"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/operators",
|
||||
"name": "Operators",
|
||||
"authors": [
|
||||
"Dave Abrahams",
|
||||
"Jeremy Siek"
|
||||
],
|
||||
"description": "Templates ease arithmetic classes and iterators.",
|
||||
"documentation": "operators.htm",
|
||||
"category": [
|
||||
"Generic",
|
||||
"Iterators",
|
||||
"Math"
|
||||
],
|
||||
"maintainers": [
|
||||
"Daniel Frey <d.frey -at- gmx.de>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/result_of",
|
||||
"name": "Result Of",
|
||||
"description": "Determines the type of a function call expression.",
|
||||
"documentation": "utility.htm#result_of",
|
||||
"category": [
|
||||
"Function-objects"
|
||||
],
|
||||
"authors": "",
|
||||
"maintainers": [
|
||||
"Daniel Walker <daniel.j.walker -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/string_ref",
|
||||
"name": "string_ref",
|
||||
"description": "String view templates.",
|
||||
"documentation": "doc/html/string_ref.html",
|
||||
"category": [
|
||||
"Containers"
|
||||
],
|
||||
"authors": "Marshall Clow",
|
||||
"maintainers": [
|
||||
"Marshall Clow <marshall -at- idio.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/value_initialized",
|
||||
"name": "Value Initialized",
|
||||
"authors": [
|
||||
"Fernando Cacciola"
|
||||
],
|
||||
"description": "Wrapper for uniform-syntax value initialization, based on the original idea of David Abrahams.",
|
||||
"documentation": "value_init.htm",
|
||||
"category": [
|
||||
"Miscellaneous"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
]
|
@ -1,36 +0,0 @@
|
||||
// boost class noncopyable test program ------------------------------------//
|
||||
|
||||
// (C) Copyright Beman Dawes 1999. 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 for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 9 Jun 99 Add unnamed namespace
|
||||
// 2 Jun 99 Initial Version
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <iostream>
|
||||
|
||||
// This program demonstrates compiler errors resulting from trying to copy
|
||||
// construct or copy assign a class object derived from class noncopyable.
|
||||
|
||||
namespace
|
||||
{
|
||||
class DontTreadOnMe : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
DontTreadOnMe() { std::cout << "defanged!" << std::endl; }
|
||||
}; // DontTreadOnMe
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
DontTreadOnMe object1;
|
||||
DontTreadOnMe object2(object1);
|
||||
object1 = object2;
|
||||
return 0;
|
||||
} // main
|
||||
|
@ -1,405 +0,0 @@
|
||||
// (C) Copyright David Abrahams 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)
|
||||
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 1 Apr 2001 Fixes for ICL; use BOOST_STATIC_CONSTANT
|
||||
// 11 Feb 2001 Fixes for Borland (David Abrahams)
|
||||
// 23 Jan 2001 Added test for wchar_t (David Abrahams)
|
||||
// 23 Jan 2001 Now statically selecting a test for signed numbers to avoid
|
||||
// warnings with fancy compilers. Added commentary and
|
||||
// additional dumping of traits data for tested types (David
|
||||
// Abrahams).
|
||||
// 21 Jan 2001 Initial version (David Abrahams)
|
||||
|
||||
#include <boost/detail/numeric_traits.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <climits>
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#ifndef BOOST_NO_LIMITS
|
||||
# include <limits>
|
||||
#endif
|
||||
|
||||
// =================================================================================
|
||||
// template class complement_traits<Number> --
|
||||
//
|
||||
// statically computes the max and min for 1s and 2s-complement binary
|
||||
// numbers. This helps on platforms without <limits> support. It also shows
|
||||
// an example of a recursive template that works with MSVC!
|
||||
//
|
||||
|
||||
template <unsigned size> struct complement; // forward
|
||||
|
||||
// The template complement, below, does all the real work, using "poor man's
|
||||
// partial specialization". We need complement_traits_aux<> so that MSVC doesn't
|
||||
// complain about undefined min/max as we're trying to recursively define them.
|
||||
template <class Number, unsigned size>
|
||||
struct complement_traits_aux
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, max = complement<size>::template traits<Number>::max);
|
||||
BOOST_STATIC_CONSTANT(Number, min = complement<size>::template traits<Number>::min);
|
||||
};
|
||||
|
||||
template <unsigned size>
|
||||
struct complement
|
||||
{
|
||||
template <class Number>
|
||||
struct traits
|
||||
{
|
||||
private:
|
||||
// indirection through complement_traits_aux necessary to keep MSVC happy
|
||||
typedef complement_traits_aux<Number, size - 1> prev;
|
||||
public:
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
|
||||
// GCC 4.0.2 ICEs on these C-style casts
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
Number((prev::max) << CHAR_BIT)
|
||||
+ Number(UCHAR_MAX));
|
||||
BOOST_STATIC_CONSTANT(Number, min = Number((prev::min) << CHAR_BIT));
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
Number(Number(prev::max) << CHAR_BIT)
|
||||
+ Number(UCHAR_MAX));
|
||||
BOOST_STATIC_CONSTANT(Number, min = Number(Number(prev::min) << CHAR_BIT));
|
||||
#endif
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
// Template class complement_base<> -- defines values for min and max for
|
||||
// complement<1>, at the deepest level of recursion. Uses "poor man's partial
|
||||
// specialization" again.
|
||||
template <bool is_signed> struct complement_base;
|
||||
|
||||
template <> struct complement_base<false>
|
||||
{
|
||||
template <class Number>
|
||||
struct values
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, min = 0);
|
||||
BOOST_STATIC_CONSTANT(Number, max = UCHAR_MAX);
|
||||
};
|
||||
};
|
||||
|
||||
template <> struct complement_base<true>
|
||||
{
|
||||
template <class Number>
|
||||
struct values
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, min = SCHAR_MIN);
|
||||
BOOST_STATIC_CONSTANT(Number, max = SCHAR_MAX);
|
||||
};
|
||||
};
|
||||
|
||||
// Base specialization of complement, puts an end to the recursion.
|
||||
template <>
|
||||
struct complement<1>
|
||||
{
|
||||
template <class Number>
|
||||
struct traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = boost::detail::is_signed<Number>::value);
|
||||
BOOST_STATIC_CONSTANT(Number, min =
|
||||
complement_base<is_signed>::template values<Number>::min);
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
complement_base<is_signed>::template values<Number>::max);
|
||||
};
|
||||
};
|
||||
|
||||
// Now here's the "pretty" template you're intended to actually use.
|
||||
// complement_traits<Number>::min, complement_traits<Number>::max are the
|
||||
// minimum and maximum values of Number if Number is a built-in integer type.
|
||||
template <class Number>
|
||||
struct complement_traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, max = (complement_traits_aux<Number, sizeof(Number)>::max));
|
||||
BOOST_STATIC_CONSTANT(Number, min = (complement_traits_aux<Number, sizeof(Number)>::min));
|
||||
};
|
||||
|
||||
// =================================================================================
|
||||
|
||||
// Support for streaming various numeric types in exactly the format I want. I
|
||||
// needed this in addition to all the assertions so that I could see exactly
|
||||
// what was going on.
|
||||
//
|
||||
// Numbers go through a 2-stage conversion process (by default, though, no real
|
||||
// conversion).
|
||||
//
|
||||
template <class T> struct stream_as {
|
||||
typedef T t1;
|
||||
typedef T t2;
|
||||
};
|
||||
|
||||
// char types first get converted to unsigned char, then to unsigned.
|
||||
template <> struct stream_as<char> {
|
||||
typedef unsigned char t1;
|
||||
typedef unsigned t2;
|
||||
};
|
||||
template <> struct stream_as<unsigned char> {
|
||||
typedef unsigned char t1; typedef unsigned t2;
|
||||
};
|
||||
template <> struct stream_as<signed char> {
|
||||
typedef unsigned char t1; typedef unsigned t2;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
|
||||
|
||||
// With this library implementation, __int64 and __uint64 get streamed as strings
|
||||
template <> struct stream_as<boost::uintmax_t> {
|
||||
typedef std::string t1;
|
||||
typedef std::string t2;
|
||||
};
|
||||
|
||||
template <> struct stream_as<boost::intmax_t> {
|
||||
typedef std::string t1;
|
||||
typedef std::string t2;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Standard promotion process for streaming
|
||||
template <class T> struct promote
|
||||
{
|
||||
static typename stream_as<T>::t1 from(T x) {
|
||||
typedef typename stream_as<T>::t1 t1;
|
||||
return t1(x);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
|
||||
|
||||
// On this platform, stream them as long/unsigned long if they fit.
|
||||
// Otherwise, write a string.
|
||||
template <> struct promote<boost::uintmax_t> {
|
||||
std::string static from(const boost::uintmax_t x) {
|
||||
if (x > ULONG_MAX)
|
||||
return std::string("large unsigned value");
|
||||
else
|
||||
return boost::lexical_cast<std::string>((unsigned long)x);
|
||||
}
|
||||
};
|
||||
template <> struct promote<boost::intmax_t> {
|
||||
std::string static from(const boost::intmax_t x) {
|
||||
if (x > boost::intmax_t(ULONG_MAX))
|
||||
return std::string("large positive signed value");
|
||||
else if (x >= 0)
|
||||
return boost::lexical_cast<std::string>((unsigned long)x);
|
||||
|
||||
if (x < boost::intmax_t(LONG_MIN))
|
||||
return std::string("large negative signed value");
|
||||
else
|
||||
return boost::lexical_cast<std::string>((long)x);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// This is the function which converts types to the form I want to stream them in.
|
||||
template <class T>
|
||||
typename stream_as<T>::t2 stream_number(T x)
|
||||
{
|
||||
return promote<T>::from(x);
|
||||
}
|
||||
// =================================================================================
|
||||
|
||||
//
|
||||
// Tests for built-in signed and unsigned types
|
||||
//
|
||||
|
||||
// Tag types for selecting tests
|
||||
struct unsigned_tag {};
|
||||
struct signed_tag {};
|
||||
|
||||
// Tests for unsigned numbers. The extra default Number parameter works around
|
||||
// an MSVC bug.
|
||||
template <class Number>
|
||||
void test_aux(unsigned_tag, Number*)
|
||||
{
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
BOOST_STATIC_ASSERT(!boost::detail::is_signed<Number>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
(sizeof(Number) < sizeof(boost::intmax_t))
|
||||
| (boost::is_same<difference_type, boost::intmax_t>::value));
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
|
||||
// GCC 4.0.2 ICEs on this C-style cases
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::min) == Number(0));
|
||||
#else
|
||||
// Force casting to Number here to work around the fact that it's an enum on MSVC
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::min) == Number(0));
|
||||
#endif
|
||||
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
const Number test_max = (sizeof(Number) < sizeof(boost::intmax_t))
|
||||
? max
|
||||
: max / 2 - 1;
|
||||
|
||||
std::cout << std::hex << "(unsigned) min = " << stream_number(min) << ", max = "
|
||||
<< stream_number(max) << "..." << std::flush;
|
||||
std::cout << "difference_type = " << typeid(difference_type).name() << "..."
|
||||
<< std::flush;
|
||||
|
||||
difference_type d1 = boost::detail::numeric_distance(Number(0), test_max);
|
||||
difference_type d2 = boost::detail::numeric_distance(test_max, Number(0));
|
||||
|
||||
std::cout << "0->" << stream_number(test_max) << "==" << std::dec << stream_number(d1) << "; "
|
||||
<< std::hex << stream_number(test_max) << "->0==" << std::dec << stream_number(d2) << "..." << std::flush;
|
||||
|
||||
assert(d1 == difference_type(test_max));
|
||||
assert(d2 == -difference_type(test_max));
|
||||
}
|
||||
|
||||
// Tests for signed numbers. The extra default Number parameter works around an
|
||||
// MSVC bug.
|
||||
struct out_of_range_tag {};
|
||||
struct in_range_tag {};
|
||||
|
||||
// This test morsel gets executed for numbers whose difference will always be
|
||||
// representable in intmax_t
|
||||
template <class Number>
|
||||
void signed_test(in_range_tag, Number*)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(boost::detail::is_signed<Number>::value);
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
difference_type d1 = boost::detail::numeric_distance(min, max);
|
||||
difference_type d2 = boost::detail::numeric_distance(max, min);
|
||||
|
||||
std::cout << stream_number(min) << "->" << stream_number(max) << "==";
|
||||
std::cout << std::dec << stream_number(d1) << "; ";
|
||||
std::cout << std::hex << stream_number(max) << "->" << stream_number(min)
|
||||
<< "==" << std::dec << stream_number(d2) << "..." << std::flush;
|
||||
assert(d1 == difference_type(max) - difference_type(min));
|
||||
assert(d2 == difference_type(min) - difference_type(max));
|
||||
}
|
||||
|
||||
// This test morsel gets executed for numbers whose difference may exceed the
|
||||
// capacity of intmax_t.
|
||||
template <class Number>
|
||||
void signed_test(out_of_range_tag, Number*)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(boost::detail::is_signed<Number>::value);
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
difference_type min_distance = complement_traits<difference_type>::min;
|
||||
difference_type max_distance = complement_traits<difference_type>::max;
|
||||
|
||||
const Number n1 = Number(min + max_distance);
|
||||
const Number n2 = Number(max + min_distance);
|
||||
difference_type d1 = boost::detail::numeric_distance(min, n1);
|
||||
difference_type d2 = boost::detail::numeric_distance(max, n2);
|
||||
|
||||
std::cout << stream_number(min) << "->" << stream_number(n1) << "==";
|
||||
std::cout << std::dec << stream_number(d1) << "; ";
|
||||
std::cout << std::hex << stream_number(max) << "->" << stream_number(n2)
|
||||
<< "==" << std::dec << stream_number(d2) << "..." << std::flush;
|
||||
assert(d1 == max_distance);
|
||||
assert(d2 == min_distance);
|
||||
}
|
||||
|
||||
template <class Number>
|
||||
void test_aux(signed_tag, Number*)
|
||||
{
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
BOOST_STATIC_ASSERT(boost::detail::is_signed<Number>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
(sizeof(Number) < sizeof(boost::intmax_t))
|
||||
| (boost::is_same<difference_type, Number>::value));
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
|
||||
// GCC 4.0.2 ICEs on this cast
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::min) < Number(0));
|
||||
#else
|
||||
// Force casting to Number here to work around the fact that it's an enum on MSVC
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::min) < Number(0));
|
||||
#endif
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
std::cout << std::hex << "min = " << stream_number(min) << ", max = "
|
||||
<< stream_number(max) << "..." << std::flush;
|
||||
std::cout << "difference_type = " << typeid(difference_type).name() << "..."
|
||||
<< std::flush;
|
||||
|
||||
typedef typename boost::detail::if_true<
|
||||
(sizeof(Number) < sizeof(boost::intmax_t))>
|
||||
::template then<
|
||||
in_range_tag,
|
||||
out_of_range_tag
|
||||
>::type
|
||||
range_tag;
|
||||
signed_test<Number>(range_tag(), 0);
|
||||
}
|
||||
|
||||
|
||||
// Test for all numbers. The extra default Number parameter works around an MSVC
|
||||
// bug.
|
||||
template <class Number>
|
||||
void test(Number* = 0)
|
||||
{
|
||||
std::cout << "testing " << typeid(Number).name() << ":\n"
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
<< "is_signed: " << (std::numeric_limits<Number>::is_signed ? "true\n" : "false\n")
|
||||
<< "is_bounded: " << (std::numeric_limits<Number>::is_bounded ? "true\n" : "false\n")
|
||||
<< "digits: " << std::numeric_limits<Number>::digits << "\n"
|
||||
#endif
|
||||
<< "..." << std::flush;
|
||||
|
||||
// factoring out difference_type for the assert below confused Borland :(
|
||||
typedef boost::detail::is_signed<
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
typename
|
||||
#endif
|
||||
boost::detail::numeric_traits<Number>::difference_type
|
||||
> is_signed;
|
||||
BOOST_STATIC_ASSERT(is_signed::value);
|
||||
|
||||
typedef typename boost::detail::if_true<
|
||||
boost::detail::is_signed<Number>::value
|
||||
>::template then<signed_tag, unsigned_tag>::type signedness;
|
||||
|
||||
test_aux<Number>(signedness(), 0);
|
||||
std::cout << "passed" << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<unsigned char>();
|
||||
test<signed char>();
|
||||
test<wchar_t>();
|
||||
test<short>();
|
||||
test<unsigned short>();
|
||||
test<int>();
|
||||
test<unsigned int>();
|
||||
test<long>();
|
||||
test<unsigned long>();
|
||||
#if defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T)
|
||||
test< ::boost::long_long_type>();
|
||||
test< ::boost::ulong_long_type>();
|
||||
#elif defined(BOOST_MSVC)
|
||||
// The problem of not having compile-time static class constants other than
|
||||
// enums prevents this from working, since values get truncated.
|
||||
// test<boost::uintmax_t>();
|
||||
// test<boost::intmax_t>();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
195
operators.htm
195
operators.htm
@ -119,8 +119,8 @@
|
||||
also want <code>x > y, x >= y,</code> and <code>x <= y</code>.
|
||||
Moreover, unless your class has really surprising behavior, some of these
|
||||
related operators can be defined in terms of others (e.g. <code>x >= y
|
||||
<=> !(x < y)</code>). Replicating this boilerplate for multiple
|
||||
classes is both tedious and error-prone. The <cite><a href=
|
||||
is equivalent to !(x < y)</code>). Replicating this boilerplate for
|
||||
multiple classes is both tedious and error-prone. The <cite><a href=
|
||||
"../../boost/operators.hpp">boost/operators.hpp</a></cite> templates help
|
||||
by generating operators for you at namespace scope based on other
|
||||
operators you've defined in your class.</p>
|
||||
@ -132,18 +132,18 @@
|
||||
class MyInt
|
||||
: boost::operators<MyInt>
|
||||
{
|
||||
bool operator<(const MyInt& x) const;
|
||||
bool operator<(const MyInt& x) const;
|
||||
bool operator==(const MyInt& x) const;
|
||||
MyInt& operator+=(const MyInt& x);
|
||||
MyInt& operator-=(const MyInt& x);
|
||||
MyInt& operator*=(const MyInt& x);
|
||||
MyInt& operator/=(const MyInt& x);
|
||||
MyInt& operator%=(const MyInt& x);
|
||||
MyInt& operator|=(const MyInt& x);
|
||||
MyInt& operator&=(const MyInt& x);
|
||||
MyInt& operator^=(const MyInt& x);
|
||||
MyInt& operator++();
|
||||
MyInt& operator--();
|
||||
MyInt& operator+=(const MyInt& x);
|
||||
MyInt& operator-=(const MyInt& x);
|
||||
MyInt& operator*=(const MyInt& x);
|
||||
MyInt& operator/=(const MyInt& x);
|
||||
MyInt& operator%=(const MyInt& x);
|
||||
MyInt& operator|=(const MyInt& x);
|
||||
MyInt& operator&=(const MyInt& x);
|
||||
MyInt& operator^=(const MyInt& x);
|
||||
MyInt& operator++();
|
||||
MyInt& operator--();
|
||||
};
|
||||
</pre>
|
||||
</blockquote>
|
||||
@ -345,7 +345,7 @@ class MyInt
|
||||
</ul>
|
||||
|
||||
<p>As Daniel Krügler pointed out, this technique violates 14.6.5/2
|
||||
and is thus non-portable. The reasoning is, that the operators injected
|
||||
and is thus non-portable. The reasoning is, that the operators injected
|
||||
by the instantiation of e.g.
|
||||
<code>less_than_comparable<myclass></code> can not be found
|
||||
by ADL according to the rules given by 3.4.2/2, since myclass is
|
||||
@ -445,13 +445,16 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
optional template parameter <code>B</code>, which is not shown, for the
|
||||
<a href="#chaining">base class chaining</a> technique.</p>
|
||||
|
||||
<p>The primary operand type <code>T</code> needs to be of class type,
|
||||
built-in types are not supported.</p>
|
||||
|
||||
<table cellpadding="5" border="1" align="center">
|
||||
<caption>
|
||||
Simple Arithmetic Operator Template Classes
|
||||
</caption>
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<td colspan="4">
|
||||
<table align="center" border="1">
|
||||
<caption>
|
||||
<em>Key</em>
|
||||
@ -479,6 +482,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<th>Supplied Operations</th>
|
||||
|
||||
<th>Requirements</th>
|
||||
|
||||
<th>Propagates <code>constexpr</code>?</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -493,6 +498,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>.<br>
|
||||
Return convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -510,6 +518,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < u</code>. <code>t > u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -521,6 +532,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>t == t1</code>.<br>
|
||||
Return convertible to <code>bool</code>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -534,6 +548,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>t == u</code>.<br>
|
||||
Return convertible to <code>bool</code>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -545,6 +562,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp += t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -557,6 +576,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp += u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -569,6 +590,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp -= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -581,6 +604,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp -= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -591,6 +616,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp -= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -603,6 +630,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp *= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -616,6 +645,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp *= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -627,6 +658,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp /= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -638,6 +671,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp /= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -648,6 +683,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp /= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -659,6 +696,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp %= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -670,6 +709,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp %= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -680,6 +721,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp %= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -691,6 +734,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp |= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -703,6 +748,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp |= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -714,6 +761,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp &= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -726,6 +775,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp &= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -737,6 +788,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp ^= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -749,6 +802,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp ^= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -759,6 +814,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(t); ++t</code><br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -769,6 +826,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(t); --t;</code><br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -781,6 +840,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp <<= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -793,6 +854,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp <<= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -805,6 +868,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp >>= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -817,6 +882,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp >>= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -828,6 +895,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>.<br>
|
||||
Return convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -839,6 +909,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < u</code>. <code>t > u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -853,6 +926,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>. <code>t == t1</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -871,6 +947,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -917,7 +996,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
created, <code>operator+=</code> is called on it and it is copied to the
|
||||
function return value (which is another unnamed object of type
|
||||
<code>T</code>). The standard doesn't generally allow the intermediate
|
||||
object to be optimized away:
|
||||
object to be optimized away:
|
||||
|
||||
<blockquote>
|
||||
3.7.2/2: Automatic storage duration<br>
|
||||
@ -928,7 +1007,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
unused, except that a class object or its copy may be eliminated as
|
||||
specified in 12.8.
|
||||
</blockquote>
|
||||
The reference to 12.8 is important for us:
|
||||
The reference to 12.8 is important for us:
|
||||
|
||||
<blockquote>
|
||||
12.8/15: Copying class objects<br>
|
||||
@ -942,7 +1021,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
</blockquote>
|
||||
This optimization is known as the named return value optimization (NRVO),
|
||||
which leads us to the following implementation for
|
||||
<code>operator+</code>:
|
||||
<code>operator+</code>:
|
||||
<pre>
|
||||
T operator+( const T& lhs, const T& rhs )
|
||||
{
|
||||
@ -956,7 +1035,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
even implement it in an incorrect way which makes it useless here.
|
||||
Without the NRVO, the NRVO-friendly code is no worse than the original
|
||||
code showed above, but there is another possible implementation, which
|
||||
has some very special properties:
|
||||
has some very special properties:
|
||||
<pre>
|
||||
T operator+( T lhs, const T& rhs )
|
||||
{
|
||||
@ -982,7 +1061,7 @@ T operator+( T lhs, const T& rhs )
|
||||
will force the NRVO-friendly implementation to be used even for compilers
|
||||
that don't implement the NRVO. <br>
|
||||
<br>
|
||||
|
||||
|
||||
<h3><a name="grpd_oprs">Grouped Arithmetic Operators</a></h3>
|
||||
|
||||
<p>The following templates provide common groups of related operations.
|
||||
@ -1420,9 +1499,9 @@ T operator+( T lhs, const T& rhs )
|
||||
|
||||
<tr>
|
||||
<td><code><a name=
|
||||
"euclidian_ring_operators1">euclidian_ring_operators<T></a></code><br>
|
||||
"euclidean_ring_operators1">euclidean_ring_operators<T></a></code><br>
|
||||
|
||||
<code>euclidian_ring_operators1<T></code></td>
|
||||
<code>euclidean_ring_operators1<T></code></td>
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
@ -1439,9 +1518,9 @@ T operator+( T lhs, const T& rhs )
|
||||
|
||||
<tr>
|
||||
<td><code><a name=
|
||||
"euclidian_ring_operators2">euclidian_ring_operators<T,
|
||||
"euclidean_ring_operators2">euclidean_ring_operators<T,
|
||||
U></a></code><br>
|
||||
<code>euclidian_ring_operators2<T, U></code></td>
|
||||
<code>euclidean_ring_operators2<T, U></code></td>
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
@ -1464,14 +1543,14 @@ T operator+( T lhs, const T& rhs )
|
||||
|
||||
<tr>
|
||||
<td><code><a name=
|
||||
"ordered_euclidian_ring_operators1">ordered_euclidian_ring_operators<T></a></code><br>
|
||||
"ordered_euclidean_ring_operators1">ordered_euclidean_ring_operators<T></a></code><br>
|
||||
|
||||
<code>ordered_euclidian_ring_operators1<T></code></td>
|
||||
<code>ordered_euclidean_ring_operators1<T></code></td>
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
"#euclidian_ring_operators1">euclidian_ring_operators<T></a></code></li>
|
||||
"#euclidean_ring_operators1">euclidean_ring_operators<T></a></code></li>
|
||||
|
||||
<li><code><a href=
|
||||
"#totally_ordered1">totally_ordered<T></a></code></li>
|
||||
@ -1481,14 +1560,14 @@ T operator+( T lhs, const T& rhs )
|
||||
|
||||
<tr>
|
||||
<td><code><a name=
|
||||
"ordered_euclidian_ring_operators2">ordered_euclidian_ring_operators<T,
|
||||
"ordered_euclidean_ring_operators2">ordered_euclidean_ring_operators<T,
|
||||
U></a></code><br>
|
||||
<code>ordered_euclidian_ring_operators2<T, U></code></td>
|
||||
<code>ordered_euclidean_ring_operators2<T, U></code></td>
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
"#euclidian_ring_operators2">euclidian_ring_operators<T,
|
||||
"#euclidean_ring_operators2">euclidean_ring_operators<T,
|
||||
U></a></code></li>
|
||||
|
||||
<li><code><a href="#totally_ordered2">totally_ordered<T,
|
||||
@ -1498,6 +1577,15 @@ T operator+( T lhs, const T& rhs )
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>Spelling: euclidean vs. euclidian</h4>
|
||||
|
||||
<p>Older versions of the Boost.Operators library used
|
||||
"<code>euclidian</code>", but it was pointed out that
|
||||
"<code>euclidean</code>" is the more common spelling.
|
||||
To be compatible with older version, the library now supports
|
||||
both spellings.
|
||||
</p>
|
||||
|
||||
<h3><a name="ex_oprs">Example</a> Templates</h3>
|
||||
|
||||
<p>The arithmetic operator class templates <code><a href=
|
||||
@ -1574,11 +1662,10 @@ T operator+( T lhs, const T& rhs )
|
||||
<h3><a name="a_demo">Arithmetic Operators Demonstration</a> and Test
|
||||
Program</h3>
|
||||
|
||||
<p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite>
|
||||
<p>The <cite><a href="test/operators_test.cpp">operators_test.cpp</a></cite>
|
||||
program demonstrates the use of the arithmetic operator templates, and
|
||||
can also be used to verify correct operation. Check the <a href=
|
||||
"../../status/compiler_status.html">compiler status report</a> for the
|
||||
test results with selected platforms.</p>
|
||||
can also be used to verify correct operation. Check the compiler status
|
||||
report for the test results with selected platforms.</p>
|
||||
|
||||
<h2><a name="deref">Dereference</a> Operators and Iterator Helpers</h2>
|
||||
|
||||
@ -1656,8 +1743,8 @@ T operator+( T lhs, const T& rhs )
|
||||
|
||||
<td><code>P operator->() const</code></td>
|
||||
|
||||
<td><code>(&*i)</code>. Return convertible to
|
||||
<code>P</code>.</td>
|
||||
<td><code>*i</code>. Address of the returned value convertible
|
||||
to <code>P</code>.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -1856,7 +1943,7 @@ T operator+( T lhs, const T& rhs )
|
||||
V, D, P, R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href="#input_iteratable">input_iteratable<T,
|
||||
@ -1870,7 +1957,7 @@ T operator+( T lhs, const T& rhs )
|
||||
"output_iterator_helper">output_iterator_helper<T></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
@ -1886,7 +1973,7 @@ T operator+( T lhs, const T& rhs )
|
||||
R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href="#forward_iteratable">forward_iteratable<T,
|
||||
@ -1901,7 +1988,7 @@ T operator+( T lhs, const T& rhs )
|
||||
V, D, P, R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
@ -1917,7 +2004,7 @@ T operator+( T lhs, const T& rhs )
|
||||
V, D, P, R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
@ -1968,8 +2055,8 @@ struct function_output_iterator
|
||||
template<typename T>
|
||||
function_output_iterator& operator=(T const& value)
|
||||
{
|
||||
this->func(value);
|
||||
return *this;
|
||||
this->func(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1987,7 +2074,7 @@ struct function_output_iterator
|
||||
|
||||
<h3><a name="i_demo">Iterator Demonstration</a> and Test Program</h3>
|
||||
|
||||
<p>The <cite><a href="iterators_test.cpp">iterators_test.cpp</a></cite>
|
||||
<p>The <cite><a href="test/iterators_test.cpp">iterators_test.cpp</a></cite>
|
||||
program demonstrates the use of the iterator templates, and can also be
|
||||
used to verify correct operation. The following is the custom iterator
|
||||
defined in the test program. It demonstrates a correct (though trivial)
|
||||
@ -2022,20 +2109,20 @@ public:
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
<p>Check the <a href="../../status/compiler_status.html">compiler status
|
||||
<p>Check the <a href="http://www.boost.org/development/testing.html">compiler status
|
||||
report</a> for the test results with selected platforms.</p>
|
||||
<hr>
|
||||
|
||||
<h2><a name="contributors">Contributors</a></h2>
|
||||
|
||||
<dl>
|
||||
<dt><a href="../../people/dave_abrahams.htm">Dave Abrahams</a></dt>
|
||||
<dt><a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a></dt>
|
||||
|
||||
<dd>Started the library and contributed the arithmetic operators in
|
||||
<cite><a href=
|
||||
"../../boost/operators.hpp">boost/operators.hpp</a></cite>.</dd>
|
||||
|
||||
<dt><a href="../../people/jeremy_siek.htm">Jeremy Siek</a></dt>
|
||||
<dt><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a></dt>
|
||||
|
||||
<dd>Contributed the <a href="#deref">dereference operators and iterator
|
||||
helpers</a> in <cite><a href=
|
||||
@ -2043,19 +2130,19 @@ public:
|
||||
contributed <cite><a href=
|
||||
"iterators_test.cpp">iterators_test.cpp</a></cite>.</dd>
|
||||
|
||||
<dt><a href="../../people/aleksey_gurtovoy.htm">Aleksey
|
||||
<dt><a href="http://www.boost.org/people/aleksey_gurtovoy.htm">Aleksey
|
||||
Gurtovoy</a></dt>
|
||||
|
||||
<dd>Contributed the code to support <a href="#chaining">base class
|
||||
chaining</a> while remaining backward-compatible with old versions of
|
||||
the library.</dd>
|
||||
|
||||
<dt><a href="../../people/beman_dawes.html">Beman Dawes</a></dt>
|
||||
<dt><a href="http://www.boost.org/people/beman_dawes.html">Beman Dawes</a></dt>
|
||||
|
||||
<dd>Contributed <cite><a href=
|
||||
"operators_test.cpp">operators_test.cpp</a></cite>.</dd>
|
||||
"test/operators_test.cpp">operators_test.cpp</a></cite>.</dd>
|
||||
|
||||
<dt><a href="../../people/daryle_walker.html">Daryle Walker</a></dt>
|
||||
<dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a></dt>
|
||||
|
||||
<dd>Contributed classes for the shift operators, equivalence, partial
|
||||
ordering, and arithmetic conversions. Added the grouped operator
|
||||
@ -2119,11 +2206,11 @@ public:
|
||||
backward-compatible.</p>
|
||||
<hr>
|
||||
|
||||
<p>Revised: 29 Oct 2004</p>
|
||||
<p>Revised: 7 Aug 2008</p>
|
||||
|
||||
<p>Copyright © Beman Dawes, David Abrahams, 1999-2001.</p>
|
||||
<p>Copyright © Daniel Frey, 2002-2004.</p>
|
||||
<p>Use, modification, and distribution is subject to the Boost Software
|
||||
<p>Copyright © Daniel Frey, 2002-2009.</p>
|
||||
<p>Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file
|
||||
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
|
134
ref_ct_test.cpp
134
ref_ct_test.cpp
@ -1,134 +0,0 @@
|
||||
// Copyright David Abrahams and Aleksey Gurtovoy
|
||||
// 2002-2004. 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)
|
||||
|
||||
// compile-time test for "boost/ref.hpp" header content
|
||||
// see 'ref_test.cpp' for run-time part
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
template< typename T, typename U >
|
||||
void ref_test(boost::reference_wrapper<U>)
|
||||
{
|
||||
typedef typename boost::reference_wrapper<U>::type type;
|
||||
BOOST_STATIC_ASSERT((boost::is_same<U,type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T,type>::value));
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void assignable_test(T x)
|
||||
{
|
||||
x = x;
|
||||
}
|
||||
|
||||
template< bool R, typename T >
|
||||
void is_reference_wrapper_test(T)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(boost::is_reference_wrapper<T>::value == R);
|
||||
}
|
||||
|
||||
template< typename R, typename Ref >
|
||||
void cxx_reference_test(Ref)
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
|
||||
typedef typename boost::remove_const<Ref>::type ref;
|
||||
BOOST_STATIC_ASSERT((boost::is_same<R,ref>::value));
|
||||
#else
|
||||
BOOST_STATIC_ASSERT((boost::is_same<R,Ref>::value));
|
||||
#endif
|
||||
}
|
||||
|
||||
template< typename R, typename Ref >
|
||||
void unwrap_reference_test(Ref)
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
|
||||
typedef typename boost::remove_const<Ref>::type ref;
|
||||
typedef typename boost::unwrap_reference<ref>::type type;
|
||||
#else
|
||||
typedef typename boost::unwrap_reference<Ref>::type type;
|
||||
#endif
|
||||
BOOST_STATIC_ASSERT((boost::is_same<R,type>::value));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
int& ri = i;
|
||||
|
||||
int const ci = 0;
|
||||
int const& rci = ci;
|
||||
|
||||
// 'ref/cref' functions test
|
||||
ref_test<int>(boost::ref(i));
|
||||
ref_test<int>(boost::ref(ri));
|
||||
ref_test<int const>(boost::ref(ci));
|
||||
ref_test<int const>(boost::ref(rci));
|
||||
|
||||
ref_test<int const>(boost::cref(i));
|
||||
ref_test<int const>(boost::cref(ri));
|
||||
ref_test<int const>(boost::cref(ci));
|
||||
ref_test<int const>(boost::cref(rci));
|
||||
|
||||
// test 'assignable' requirement
|
||||
assignable_test(boost::ref(i));
|
||||
assignable_test(boost::ref(ri));
|
||||
assignable_test(boost::cref(i));
|
||||
assignable_test(boost::cref(ci));
|
||||
assignable_test(boost::cref(rci));
|
||||
|
||||
// 'is_reference_wrapper' test
|
||||
is_reference_wrapper_test<true>(boost::ref(i));
|
||||
is_reference_wrapper_test<true>(boost::ref(ri));
|
||||
is_reference_wrapper_test<true>(boost::cref(i));
|
||||
is_reference_wrapper_test<true>(boost::cref(ci));
|
||||
is_reference_wrapper_test<true>(boost::cref(rci));
|
||||
|
||||
is_reference_wrapper_test<false>(i);
|
||||
is_reference_wrapper_test<false, int&>(ri);
|
||||
is_reference_wrapper_test<false>(ci);
|
||||
is_reference_wrapper_test<false, int const&>(rci);
|
||||
|
||||
// ordinary references/function template arguments deduction test
|
||||
cxx_reference_test<int>(i);
|
||||
cxx_reference_test<int>(ri);
|
||||
cxx_reference_test<int>(ci);
|
||||
cxx_reference_test<int>(rci);
|
||||
|
||||
cxx_reference_test<int&, int&>(i);
|
||||
cxx_reference_test<int&, int&>(ri);
|
||||
cxx_reference_test<int const&, int const&>(i);
|
||||
cxx_reference_test<int const&, int const&>(ri);
|
||||
cxx_reference_test<int const&, int const&>(ci);
|
||||
cxx_reference_test<int const&, int const&>(rci);
|
||||
|
||||
// 'unwrap_reference' test
|
||||
unwrap_reference_test<int>(boost::ref(i));
|
||||
unwrap_reference_test<int>(boost::ref(ri));
|
||||
unwrap_reference_test<int const>(boost::cref(i));
|
||||
unwrap_reference_test<int const>(boost::cref(ci));
|
||||
unwrap_reference_test<int const>(boost::cref(rci));
|
||||
|
||||
unwrap_reference_test<int>(i);
|
||||
unwrap_reference_test<int>(ri);
|
||||
unwrap_reference_test<int>(ci);
|
||||
unwrap_reference_test<int>(rci);
|
||||
unwrap_reference_test<int&, int&>(i);
|
||||
unwrap_reference_test<int&, int&>(ri);
|
||||
unwrap_reference_test<int const&, int const&>(i);
|
||||
unwrap_reference_test<int const&, int const&>(ri);
|
||||
unwrap_reference_test<int const&, int const&>(ci);
|
||||
unwrap_reference_test<int const&, int const&>(rci);
|
||||
|
||||
return 0;
|
||||
}
|
78
ref_test.cpp
78
ref_test.cpp
@ -1,78 +0,0 @@
|
||||
// Copyright David Abrahams and Aleksey Gurtovoy
|
||||
// 2002-2004. 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)
|
||||
|
||||
// run-time test for "boost/ref.hpp" header content
|
||||
// see 'ref_ct_test.cpp' for compile-time part
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__ICL)
|
||||
# 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
|
||||
|
||||
#include <boost/ref.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
|
||||
|
||||
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
namespace {
|
||||
using namespace boost;
|
||||
|
||||
template <class T>
|
||||
struct ref_wrapper
|
||||
{
|
||||
// Used to verify implicit conversion
|
||||
static T* get_pointer(T& x)
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
static T const* get_const_pointer(T const& x)
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
template <class Arg>
|
||||
static T* passthru(Arg x)
|
||||
{
|
||||
return get_pointer(x);
|
||||
}
|
||||
|
||||
template <class Arg>
|
||||
static T const* cref_passthru(Arg x)
|
||||
{
|
||||
return get_const_pointer(x);
|
||||
}
|
||||
|
||||
static void test(T x)
|
||||
{
|
||||
BOOST_CHECK(passthru(ref(x)) == &x);
|
||||
BOOST_CHECK(&ref(x).get() == &x);
|
||||
|
||||
BOOST_CHECK(cref_passthru(cref(x)) == &x);
|
||||
BOOST_CHECK(&cref(x).get() == &x);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace unnamed
|
||||
|
||||
int test_main(int, char * [])
|
||||
{
|
||||
ref_wrapper<int>::test(1);
|
||||
ref_wrapper<int const>::test(1);
|
||||
return 0;
|
||||
}
|
@ -1,322 +0,0 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
||||
<meta name="ProgId" content="FrontPage.Editor.Document">
|
||||
<title>Shared Container Iterator Documentation</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
|
||||
<img src="../../boost.png" alt="boost.png (6897 bytes)"
|
||||
align="center" width="277" height="86">
|
||||
|
||||
<h1>Shared Container Iterator</h1>
|
||||
|
||||
Defined in header
|
||||
<a href="../../boost/shared_container_iterator.hpp">boost/shared_container_iterator.hpp</a>
|
||||
|
||||
<p>
|
||||
The purpose of the shared container iterator is to attach the lifetime
|
||||
of a container to the lifetime of its iterators. In other words, the
|
||||
container will not be deleted until after all its iterators are
|
||||
destroyed. The shared container iterator is typically used to
|
||||
implement functions that return iterators over a range of objects that
|
||||
only need to exist for the lifetime of the iterators. By returning a
|
||||
pair of shared iterators from a function, the callee can return a
|
||||
heap-allocated range of objects whose lifetime is automatically managed.
|
||||
<p>
|
||||
The shared container iterator augments an iterator over a shared
|
||||
container. It maintains a reference count on the shared
|
||||
container. If only shared container iterators hold references to
|
||||
the container, the container's lifetime will end when the last shared
|
||||
container iterator over it is destroyed. In any case, the shared
|
||||
container is guaranteed to persist beyond the lifetime of all
|
||||
the iterators. In all other ways, the
|
||||
shared container iterator behaves the same as its base iterator.
|
||||
|
||||
|
||||
<h2>Synopsis</h2>
|
||||
|
||||
<pre>
|
||||
namespace boost {
|
||||
template <typename <a href="http://www.sgi.com/tech/stl/Container.html">Container</a>>
|
||||
class shared_container_iterator;
|
||||
|
||||
template <typename <a href="http://www.sgi.com/tech/stl/Container.html">Container</a>>
|
||||
shared_container_iterator<Container>
|
||||
make_shared_container_iterator(typename Container::iterator base,
|
||||
boost::shared_ptr<Container> const& container);
|
||||
|
||||
std::pair<
|
||||
typename shared_container_iterator<Container>,
|
||||
typename shared_container_iterator<Container>
|
||||
>
|
||||
make_shared_container_range(boost::shared_ptr<Container> const& container);
|
||||
}
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a name="generator">The Shared Container Iterator Type</a></h2>
|
||||
|
||||
<pre>
|
||||
template <typename Container> class shared_container_iterator;
|
||||
</pre>
|
||||
|
||||
The class template <tt>shared_container_iterator</tt>
|
||||
is the shared container iterator type. The <tt>Container</tt> template
|
||||
type argument must model the
|
||||
<a href="http://www.sgi.com/tech/stl/Container.html">Container</a>
|
||||
concept.
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<p>
|
||||
The following example illustrates how to create an iterator that
|
||||
regulates the lifetime of a reference counted <tt>std::vector</tt>.
|
||||
Though the original shared pointer <tt>ints</tt> ceases to exist
|
||||
after <tt>set_range()</tt> returns, the
|
||||
<tt>shared_counter_iterator</tt> objects maintain references to the
|
||||
underlying vector and thereby extend the container's lifetime.
|
||||
<p>
|
||||
<a href="./shared_iterator_example1.cpp">shared_iterator_example1.cpp</a>:
|
||||
<PRE>
|
||||
<font color="#008040">#include "shared_container_iterator.hpp"</font>
|
||||
<font color="#008040">#include "boost/shared_ptr.hpp"</font>
|
||||
<font color="#008040">#include <algorithm></font>
|
||||
<font color="#008040">#include <iostream></font>
|
||||
<font color="#008040">#include <vector></font>
|
||||
|
||||
<B>typedef</B> boost::shared_container_iterator< std::vector<<B>int</B>> > iterator;
|
||||
|
||||
|
||||
<B>void</B> set_range(iterator& i, iterator& end) {
|
||||
|
||||
boost::shared_ptr< std::vector<<B>int</B>> > ints(<B>new</B> std::vector<<B>int</B>>());
|
||||
|
||||
ints->push_back(<font color="#0000A0">0</font>);
|
||||
ints->push_back(<font color="#0000A0">1</font>);
|
||||
ints->push_back(<font color="#0000A0">2</font>);
|
||||
ints->push_back(<font color="#0000A0">3</font>);
|
||||
ints->push_back(<font color="#0000A0">4</font>);
|
||||
ints->push_back(<font color="#0000A0">5</font>);
|
||||
|
||||
i = iterator(ints->begin(),ints);
|
||||
end = iterator(ints->end(),ints);
|
||||
}
|
||||
|
||||
|
||||
<B>int</B> main() {
|
||||
|
||||
iterator i,end;
|
||||
|
||||
set_range(i,end);
|
||||
|
||||
std::copy(i,end,std::ostream_iterator<<B>int</B>>(std::cout,<font color="#0000FF">","</font>));
|
||||
std::cout.put(<font color="#0000FF">'\n'</font>);
|
||||
|
||||
<B>return</B> <font color="#0000A0">0</font>;
|
||||
}
|
||||
</PRE>
|
||||
|
||||
The output from this part is:
|
||||
<pre>
|
||||
0,1,2,3,4,5,
|
||||
</pre>
|
||||
|
||||
<h3>Template Parameters</h3>
|
||||
|
||||
<Table border>
|
||||
<TR>
|
||||
<TH>Parameter</TH><TH>Description</TH>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><a
|
||||
href="http://www.sgi.com/tech/stl/Container.html"><tt>Container</tt></a></TD>
|
||||
<TD>The type of the container that we wish to iterate over. It must be
|
||||
a model of the
|
||||
<a href="http://www.sgi.com/tech/stl/Container.html"><tt>Container</tt></a>
|
||||
concept.
|
||||
</TD>
|
||||
</TR>
|
||||
</Table>
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
The <tt>shared_container_iterator<Container></tt> type models the
|
||||
same iterator concept as the base iterator
|
||||
(<tt>Container::iterator</tt>).
|
||||
|
||||
<h3>Members</h3>
|
||||
|
||||
The shared container iterator type implements the member functions and
|
||||
operators required of the <a
|
||||
href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">Random Access Iterator</a>
|
||||
concept, though only operations defined for the base iterator will be valid.
|
||||
In addition it has the following constructor:
|
||||
|
||||
<pre>
|
||||
shared_container_iterator(Container::iterator const& it,
|
||||
boost::shared_ptr<Container> const& container)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
|
||||
<h2><a name="make_iterator">The Shared Container Iterator Object Generator</a></h2>
|
||||
|
||||
<pre>
|
||||
template <typename Container>
|
||||
shared_container_iterator<Container>
|
||||
make_shared_container_iterator(Container::iterator base,
|
||||
boost::shared_ptr<Container> const& container)
|
||||
</pre>
|
||||
|
||||
This function provides an alternative to directly constructing a
|
||||
shared container iterator. Using the object generator, a shared
|
||||
container iterator can be created and passed to a function without
|
||||
explicitly specifying its type.
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
This example, similar to the previous, uses
|
||||
<tt>make_shared_container_iterator()</tt> to create the iterators.
|
||||
|
||||
<p>
|
||||
<a href="./shared_iterator_example2.cpp">shared_iterator_example2.cpp</a>:
|
||||
|
||||
<PRE>
|
||||
<font color="#008040">#include "shared_container_iterator.hpp"</font>
|
||||
<font color="#008040">#include "boost/shared_ptr.hpp"</font>
|
||||
<font color="#008040">#include <algorithm></font>
|
||||
<font color="#008040">#include <iterator></font>
|
||||
<font color="#008040">#include <iostream></font>
|
||||
<font color="#008040">#include <vector></font>
|
||||
|
||||
|
||||
<B>template</B> <<B>typename</B> Iterator>
|
||||
<B>void</B> print_range_nl (Iterator begin, Iterator end) {
|
||||
<B>typedef</B> <B>typename</B> std::iterator_traits<Iterator>::value_type val;
|
||||
std::copy(begin,end,std::ostream_iterator<val>(std::cout,<font color="#0000FF">","</font>));
|
||||
std::cout.put(<font color="#0000FF">'\n'</font>);
|
||||
}
|
||||
|
||||
|
||||
<B>int</B> main() {
|
||||
|
||||
<B>typedef</B> boost::shared_ptr< std::vector<<B>int</B>> > ints_t;
|
||||
{
|
||||
ints_t ints(<B>new</B> std::vector<<B>int</B>>());
|
||||
|
||||
ints->push_back(<font color="#0000A0">0</font>);
|
||||
ints->push_back(<font color="#0000A0">1</font>);
|
||||
ints->push_back(<font color="#0000A0">2</font>);
|
||||
ints->push_back(<font color="#0000A0">3</font>);
|
||||
ints->push_back(<font color="#0000A0">4</font>);
|
||||
ints->push_back(<font color="#0000A0">5</font>);
|
||||
|
||||
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
|
||||
boost::make_shared_container_iterator(ints->end(),ints));
|
||||
}
|
||||
|
||||
|
||||
|
||||
<B>return</B> <font color="#0000A0">0</font>;
|
||||
}
|
||||
</PRE>
|
||||
|
||||
Observe that the <tt>shared_container_iterator</tt> type is never
|
||||
explicitly named. The output from this example is the same as the previous.
|
||||
|
||||
<h2><a name="make_range">The Shared Container Iterator Range Generator</a></h2>
|
||||
|
||||
<pre>
|
||||
template <typename Container>
|
||||
std::pair<
|
||||
shared_container_iterator<Container>,
|
||||
shared_container_iterator<Container>
|
||||
>
|
||||
make_shared_container_range(boost::shared_ptr<Container> const& container);
|
||||
</pre>
|
||||
|
||||
Class <tt>shared_container_iterator</tt> is meant primarily to return,
|
||||
using iterators, a range of values that we can guarantee will be alive as
|
||||
long as the iterators are. This is a convenience
|
||||
function to do just that. It is equivalent to
|
||||
|
||||
<pre>
|
||||
std::make_pair(make_shared_container_iterator(container->begin(),container),
|
||||
make_shared_container_iterator(container->end(),container));
|
||||
</pre>
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
In the following example, a range of values is returned as a pair of
|
||||
<tt>shared_container_iterator</tt> objects.
|
||||
|
||||
|
||||
<p>
|
||||
<a href="./shared_iterator_example3.cpp">shared_iterator_example3.cpp</a>:
|
||||
|
||||
<PRE>
|
||||
<font color="#008040">#include "shared_container_iterator.hpp"</font>
|
||||
<font color="#008040">#include "boost/shared_ptr.hpp"</font>
|
||||
<font color="#008040">#include "boost/tuple/tuple.hpp" // for boost::tie</font>
|
||||
<font color="#008040">#include <algorithm> // for std::copy</font>
|
||||
<font color="#008040">#include <iostream> </font>
|
||||
<font color="#008040">#include <vector></font>
|
||||
|
||||
|
||||
<B>typedef</B> boost::shared_container_iterator< std::vector<<B>int</B>> > iterator;
|
||||
|
||||
std::pair<iterator,iterator>
|
||||
return_range() {
|
||||
boost::shared_ptr< std::vector<<B>int</B>> > range(<B>new</B> std::vector<<B>int</B>>());
|
||||
range->push_back(<font color="#0000A0">0</font>);
|
||||
range->push_back(<font color="#0000A0">1</font>);
|
||||
range->push_back(<font color="#0000A0">2</font>);
|
||||
range->push_back(<font color="#0000A0">3</font>);
|
||||
range->push_back(<font color="#0000A0">4</font>);
|
||||
range->push_back(<font color="#0000A0">5</font>);
|
||||
<B>return</B> boost::make_shared_container_range(range);
|
||||
}
|
||||
|
||||
|
||||
<B>int</B> main() {
|
||||
|
||||
|
||||
iterator i,end;
|
||||
|
||||
boost::tie(i,end) = return_range();
|
||||
|
||||
std::copy(i,end,std::ostream_iterator<<B>int</B>>(std::cout,<font color="#0000FF">","</font>));
|
||||
std::cout.put(<font color="#0000FF">'\n'</font>);
|
||||
|
||||
<B>return</B> <font color="#0000A0">0</font>;
|
||||
}
|
||||
</PRE>
|
||||
|
||||
Though the <tt>range</tt> object only lives for the duration of the
|
||||
<tt>return_range</tt> call, the reference counted
|
||||
<tt>std::vector</tt> will live until <tt>i</tt> and <tt>end</tt>
|
||||
are both destroyed. The output from this example is the same as
|
||||
the previous two.
|
||||
|
||||
|
||||
<hr>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Mon Aug 11 11:27:03 EST 2003
|
||||
<!-- hhmts end -->
|
||||
<p><EFBFBD> Copyright 2003 The Trustees of Indiana University.
|
||||
Use, modification and distribution is 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)</p>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,42 +0,0 @@
|
||||
// Copyright 2003 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is 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/shared_container_iterator.hpp"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
||||
|
||||
|
||||
void set_range(iterator& i, iterator& end) {
|
||||
|
||||
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
|
||||
|
||||
ints->push_back(0);
|
||||
ints->push_back(1);
|
||||
ints->push_back(2);
|
||||
ints->push_back(3);
|
||||
ints->push_back(4);
|
||||
ints->push_back(5);
|
||||
|
||||
i = iterator(ints->begin(),ints);
|
||||
end = iterator(ints->end(),ints);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
iterator i,end;
|
||||
|
||||
set_range(i,end);
|
||||
|
||||
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
||||
std::cout.put('\n');
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
// Copyright 2003 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is 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/shared_container_iterator.hpp"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
template <typename Iterator>
|
||||
void print_range_nl (Iterator begin, Iterator end) {
|
||||
typedef typename std::iterator_traits<Iterator>::value_type val;
|
||||
std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
|
||||
std::cout.put('\n');
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
typedef boost::shared_ptr< std::vector<int> > ints_t;
|
||||
{
|
||||
ints_t ints(new std::vector<int>());
|
||||
|
||||
ints->push_back(0);
|
||||
ints->push_back(1);
|
||||
ints->push_back(2);
|
||||
ints->push_back(3);
|
||||
ints->push_back(4);
|
||||
ints->push_back(5);
|
||||
|
||||
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
|
||||
boost::make_shared_container_iterator(ints->end(),ints));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// Copyright 2003 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is 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/shared_container_iterator.hpp"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include "boost/tuple/tuple.hpp" // for boost::tie
|
||||
#include <algorithm> // for std::copy
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
||||
|
||||
std::pair<iterator,iterator>
|
||||
return_range() {
|
||||
boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
|
||||
range->push_back(0);
|
||||
range->push_back(1);
|
||||
range->push_back(2);
|
||||
range->push_back(3);
|
||||
range->push_back(4);
|
||||
range->push_back(5);
|
||||
return boost::make_shared_container_range(range);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
|
||||
iterator i,end;
|
||||
|
||||
boost::tie(i,end) = return_range();
|
||||
|
||||
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
||||
std::cout.put('\n');
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
// Copyright 2003 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is 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)
|
||||
|
||||
// Shared container iterator adaptor
|
||||
// Author: Ronald Garcia
|
||||
// See http://boost.org/libs/utility/shared_container_iterator.html
|
||||
// for documentation.
|
||||
|
||||
//
|
||||
// shared_iterator_test.cpp - Regression tests for shared_container_iterator.
|
||||
//
|
||||
|
||||
|
||||
#include "boost/shared_container_iterator.hpp"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
struct resource {
|
||||
static int count;
|
||||
resource() { ++count; }
|
||||
resource(resource const&) { ++count; }
|
||||
~resource() { --count; }
|
||||
};
|
||||
int resource::count = 0;
|
||||
|
||||
typedef std::vector<resource> resources_t;
|
||||
|
||||
typedef boost::shared_container_iterator< resources_t > iterator;
|
||||
|
||||
|
||||
void set_range(iterator& i, iterator& end) {
|
||||
|
||||
boost::shared_ptr< resources_t > objs(new resources_t());
|
||||
|
||||
for (int j = 0; j != 6; ++j)
|
||||
objs->push_back(resource());
|
||||
|
||||
i = iterator(objs->begin(),objs);
|
||||
end = iterator(objs->end(),objs);
|
||||
assert(resource::count == 6);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
assert(resource::count == 0);
|
||||
|
||||
{
|
||||
iterator i;
|
||||
{
|
||||
iterator end;
|
||||
set_range(i,end);
|
||||
assert(resource::count == 6);
|
||||
}
|
||||
assert(resource::count == 6);
|
||||
}
|
||||
assert(resource::count == 0);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,36 +1,47 @@
|
||||
# Copyright David Abrahams 2003. 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.
|
||||
# Copyright David Abrahams 2003.
|
||||
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
# For more information, see http://www.boost.org/
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
# Please keep the tests ordered by filename
|
||||
test-suite utility
|
||||
:
|
||||
[ run ../addressof_test.cpp ]
|
||||
[ run ../assert_test.cpp ]
|
||||
[ run ../base_from_member_test.cpp ]
|
||||
[ run ../binary_search_test.cpp ]
|
||||
[ run ../call_traits_test.cpp : -u ]
|
||||
[ compile-fail ../checked_delete_test.cpp ]
|
||||
[ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/<link>static : -u ]
|
||||
[ run ../current_function_test.cpp : : : <test-info>always_show_run_output ]
|
||||
[ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ compile-fail ../noncopyable_test.cpp ]
|
||||
[ run ../numeric_traits_test.cpp ]
|
||||
[ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ compile ../ref_ct_test.cpp ]
|
||||
[ run ../ref_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ compile result_of_test.cpp ]
|
||||
[ run ../shared_iterator_test.cpp ]
|
||||
[ run ../value_init_test.cpp ]
|
||||
[ compile-fail ../value_init_test_fail1.cpp ]
|
||||
[ compile-fail ../value_init_test_fail2.cpp ]
|
||||
[ compile-fail ../value_init_test_fail3.cpp ]
|
||||
;
|
||||
run base_from_member_test.cpp ;
|
||||
run base_from_member_ref_test.cpp ;
|
||||
|
||||
run binary_test.cpp ;
|
||||
|
||||
run call_traits_test.cpp : -u ;
|
||||
|
||||
run compressed_pair_test.cpp ;
|
||||
run compressed_pair_final_test.cpp ;
|
||||
|
||||
run iterators_test.cpp ;
|
||||
|
||||
run operators_test.cpp ;
|
||||
compile operators_constexpr_test.cpp ;
|
||||
|
||||
compile result_of_test.cpp ;
|
||||
|
||||
# compile-fail string_ref_from_rvalue.cpp ;
|
||||
run string_ref_test1.cpp ;
|
||||
run string_ref_test2.cpp ;
|
||||
run string_ref_test_io.cpp ;
|
||||
# compile-fail string_view_from_rvalue.cpp ;
|
||||
compile string_view_constexpr_test1.cpp ;
|
||||
run string_view_test1.cpp ;
|
||||
run string_view_test2.cpp ;
|
||||
run string_view_test_io.cpp ;
|
||||
|
||||
run value_init_test.cpp ;
|
||||
run value_init_test2.cpp ;
|
||||
run value_init_test3.cpp ;
|
||||
run value_init_workaround_test.cpp ;
|
||||
run initialized_test.cpp ;
|
||||
compile-fail value_init_test_fail1.cpp ;
|
||||
compile-fail value_init_test_fail2.cpp ;
|
||||
compile-fail value_init_test_fail3.cpp ;
|
||||
compile-fail initialized_test_fail1.cpp ;
|
||||
compile-fail initialized_test_fail2.cpp ;
|
||||
|
29
test/base_from_member_ref_test.cpp
Normal file
29
test/base_from_member_ref_test.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Test that a base_from_member<T&> can be properly constructed
|
||||
//
|
||||
// Copyright 2014 Agustin Berge
|
||||
//
|
||||
// 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/utility/base_from_member.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct foo : boost::base_from_member<int&>
|
||||
{
|
||||
explicit foo(int& ref) : boost::base_from_member<int&>(ref)
|
||||
{
|
||||
BOOST_TEST(&member == &ref);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
foo f(i);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -10,15 +10,14 @@
|
||||
// 14 Jun 2003 Adjusted code for Boost.Test changes (Daryle Walker)
|
||||
// 29 Aug 2001 Initial Version (Daryle Walker)
|
||||
|
||||
#include <boost/test/minimal.hpp> // for BOOST_CHECK, main
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_NO_MEMBER_TEMPLATES
|
||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||
#include <boost/noncopyable.hpp> // for boost::noncopyable
|
||||
|
||||
#include <boost/utility/base_from_member.hpp> // for boost::base_from_member
|
||||
|
||||
#include <functional> // for std::binary_function, std::less
|
||||
#include <functional> // for std::less
|
||||
#include <iostream> // for std::cout (std::ostream, std::endl indirectly)
|
||||
#include <set> // for std::set
|
||||
#include <typeinfo> // for std::type_info
|
||||
@ -46,7 +45,6 @@ template < typename T >
|
||||
|
||||
// A custom comparison type is needed
|
||||
struct object_id_compare
|
||||
: std::binary_function<object_id, object_id, bool>
|
||||
{
|
||||
bool operator ()( object_id const &a, object_id const &b ) const;
|
||||
|
||||
@ -173,13 +171,13 @@ object_registrar obj_reg;
|
||||
|
||||
// Main functionality
|
||||
int
|
||||
test_main( int , char * [] )
|
||||
main()
|
||||
{
|
||||
BOOST_CHECK( obj_reg.db_.empty() );
|
||||
BOOST_CHECK( obj_reg.defrauders_in_.empty() );
|
||||
BOOST_CHECK( obj_reg.defrauders_out_.empty() );
|
||||
BOOST_CHECK( obj_reg.overeager_.empty() );
|
||||
BOOST_CHECK( obj_reg.overkilled_.empty() );
|
||||
BOOST_TEST( obj_reg.db_.empty() );
|
||||
BOOST_TEST( obj_reg.defrauders_in_.empty() );
|
||||
BOOST_TEST( obj_reg.defrauders_out_.empty() );
|
||||
BOOST_TEST( obj_reg.overeager_.empty() );
|
||||
BOOST_TEST( obj_reg.overkilled_.empty() );
|
||||
|
||||
// Make a separate block to examine pre- and post-effects
|
||||
{
|
||||
@ -187,20 +185,20 @@ test_main( int , char * [] )
|
||||
using std::endl;
|
||||
|
||||
bad_class bc;
|
||||
BOOST_CHECK( obj_reg.db_.size() == 3 );
|
||||
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
|
||||
BOOST_TEST( obj_reg.db_.size() == 3 );
|
||||
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
|
||||
|
||||
good_class_1 gc1;
|
||||
BOOST_CHECK( obj_reg.db_.size() == 6 );
|
||||
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
|
||||
BOOST_TEST( obj_reg.db_.size() == 6 );
|
||||
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
|
||||
|
||||
good_class_2 gc2;
|
||||
BOOST_CHECK( obj_reg.db_.size() == 11 );
|
||||
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
|
||||
BOOST_TEST( obj_reg.db_.size() == 11 );
|
||||
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
|
||||
|
||||
BOOST_CHECK( obj_reg.defrauders_out_.empty() );
|
||||
BOOST_CHECK( obj_reg.overeager_.empty() );
|
||||
BOOST_CHECK( obj_reg.overkilled_.empty() );
|
||||
BOOST_TEST( obj_reg.defrauders_out_.empty() );
|
||||
BOOST_TEST( obj_reg.overeager_.empty() );
|
||||
BOOST_TEST( obj_reg.overkilled_.empty() );
|
||||
|
||||
// Getting the addresses of the objects ensure
|
||||
// that they're used, and not optimized away.
|
||||
@ -209,13 +207,13 @@ test_main( int , char * [] )
|
||||
cout << "Object 'gc2' is at " << &gc2 << '.' << endl;
|
||||
}
|
||||
|
||||
BOOST_CHECK( obj_reg.db_.empty() );
|
||||
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
|
||||
BOOST_CHECK( obj_reg.defrauders_out_.size() == 1 );
|
||||
BOOST_CHECK( obj_reg.overeager_.empty() );
|
||||
BOOST_CHECK( obj_reg.overkilled_.empty() );
|
||||
BOOST_TEST( obj_reg.db_.empty() );
|
||||
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
|
||||
BOOST_TEST( obj_reg.defrauders_out_.size() == 1 );
|
||||
BOOST_TEST( obj_reg.overeager_.empty() );
|
||||
BOOST_TEST( obj_reg.overkilled_.empty() );
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@ -281,7 +279,7 @@ object_id_compare::operator ()
|
||||
}
|
||||
else
|
||||
{
|
||||
return a.second->before( *b.second );
|
||||
return a.second->before( *b.second ) != 0;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user