forked from boostorg/range
Compare commits
636 Commits
boost-1.33
...
develop
Author | SHA1 | Date | |
---|---|---|---|
f0e109312c | |||
3920ef2e7a | |||
41bff33b2c | |||
b2e4d5ad4b | |||
d52236c0b8 | |||
014c48f1b1 | |||
9c783ecbef | |||
d6e0a32f2e | |||
95095cf4bb | |||
88c6199aed | |||
fd40a25fea | |||
da69f60d3e | |||
6fc6e92adc | |||
e13030df17 | |||
6776ffa8e8 | |||
000b4882aa | |||
486c74fbeb | |||
f3ff60c3bc | |||
72e2a4457a | |||
bb27d50b31 | |||
5572b24a71 | |||
b42165a916 | |||
9a2960f01b | |||
4ed7887128 | |||
ee1ec1cf57 | |||
3b04f1a65e | |||
45d3aae111 | |||
0e8ad01bf9 | |||
c25b0e5069 | |||
994ff83292 | |||
77e5b868a0 | |||
474efda11a | |||
f1215fbda2 | |||
5f04231144 | |||
4e0b172a23 | |||
21a06a93aa | |||
6b3750f209 | |||
1bf2db29c0 | |||
9f03cc44d8 | |||
911d8a427d | |||
3496282d3b | |||
ce24356018 | |||
dbb6ef424f | |||
77a4dd5124 | |||
4ec46acdf5 | |||
cecebeea51 | |||
802fda6701 | |||
4ad147a220 | |||
221ae46c2b | |||
eced0cfac8 | |||
9f94c8703b | |||
023f45be01 | |||
364f755d99 | |||
af9f65e06e | |||
b91cb90dca | |||
7efe3c68f6 | |||
357bf3b980 | |||
9192996a93 | |||
4cfd4d8287 | |||
70d1727ed3 | |||
406226eccd | |||
05532829bd | |||
c24661a636 | |||
11dd528eb0 | |||
314b5d6b3c | |||
4dd5ad0f64 | |||
f1906e914e | |||
795046f8fc | |||
2aaa802e6a | |||
5b2500872d | |||
b1d5d23514 | |||
aaebfa5b20 | |||
95a62a3b3a | |||
67929cd7df | |||
5408f220dd | |||
937a411c3f | |||
1dac6a796e | |||
1234c59a39 | |||
e0d2e492a1 | |||
619c074146 | |||
4614777aaf | |||
83a352fa58 | |||
0e0d77cfab | |||
d1f36fba8d | |||
4283443532 | |||
3771624560 | |||
4a729678fd | |||
dfa3697764 | |||
efdd98332b | |||
8b98b696ff | |||
97951d2a8b | |||
efa2dc71f9 | |||
d99628981d | |||
e65434eb4f | |||
93513a3801 | |||
93eb91e63e | |||
f3a4246bd9 | |||
796080bbb8 | |||
370f1a4cd2 | |||
7d564572e2 | |||
9afc3bcbe2 | |||
69409ed63a | |||
23e5801e2a | |||
e476e1900a | |||
452b1bb7e7 | |||
7b89c747d6 | |||
deb3ae9800 | |||
56d470635d | |||
5c70a54597 | |||
f829c55c72 | |||
910fc7bf82 | |||
67c18ac1f1 | |||
5787c56994 | |||
9e5680b590 | |||
1b4f8100ef | |||
7567dce0c1 | |||
e48b9c38e7 | |||
283b8beddc | |||
4ce15f9b52 | |||
bb43887430 | |||
5a37aa4e98 | |||
0e931f4a80 | |||
5196baa1b0 | |||
1947daf1b5 | |||
7ca999c662 | |||
e7ebe14707 | |||
3225aaf82b | |||
262c0f96b3 | |||
1a3aeeb336 | |||
78a8f5bf3d | |||
9bf860fd30 | |||
64c83341ab | |||
6241dc62aa | |||
f83381d938 | |||
926318105e | |||
140866b402 | |||
490ba3fdcd | |||
e4f456d438 | |||
adcb071dc6 | |||
4f66482414 | |||
7fad9837fb | |||
11dbb1cb5a | |||
e961e66909 | |||
8847fd63cb | |||
62941f740d | |||
0c930a3697 | |||
09084d6355 | |||
9ca1622dd0 | |||
7669f52547 | |||
c6c4a8f3c1 | |||
3d5f3611ba | |||
8c1180f7f2 | |||
8ea11f9281 | |||
811b27141a | |||
a53bd134b2 | |||
0b28fd043f | |||
474c62ab16 | |||
de206a64db | |||
435ca994bf | |||
4a80ccd50d | |||
6f11252633 | |||
2356783e17 | |||
688d1bc418 | |||
dcbe4f9365 | |||
9b3a21b5e3 | |||
e362bb1855 | |||
1965b797d8 | |||
4f3bdbe4d3 | |||
8bb3a85f68 | |||
0e9a9e613b | |||
18e5bfd037 | |||
51b8115fc1 | |||
4617c43b5e | |||
a58e59ec67 | |||
470a28ecb6 | |||
1e509e6749 | |||
7d13f63d5d | |||
d6bce30c4f | |||
b0b08e0039 | |||
c865de5aa6 | |||
dc0a6b6340 | |||
7fb879a283 | |||
af2f17ccc5 | |||
4716c1efec | |||
9d8034d541 | |||
48dfb68045 | |||
1617a513d2 | |||
c2a7ac4197 | |||
1e25d862bc | |||
8a8b511109 | |||
1fd0ded6b1 | |||
fbf91ce2da | |||
edc7bb5fd9 | |||
0ffe40272a | |||
7896e79373 | |||
d6dd1ad193 | |||
cf6fabe950 | |||
3b9aabb925 | |||
1eecd2c2f6 | |||
e33c501c05 | |||
3ecf600434 | |||
31ace63a0c | |||
61e02039dd | |||
fc172fc509 | |||
a0dad84a13 | |||
264017e2a9 | |||
12d4af20dd | |||
5ba77001dd | |||
5ce6dc7814 | |||
749b1c5456 | |||
344f578934 | |||
6ee61a6578 | |||
fe1a592e46 | |||
c555a1228f | |||
4c8164a9aa | |||
5918e7e63e | |||
e0e6fefb1e | |||
36bb8a82fb | |||
e43796c42c | |||
60025220f5 | |||
698a083e65 | |||
ac99249c89 | |||
4ec54072d3 | |||
ec3c98bc25 | |||
5f2560f753 | |||
d7fde2736c | |||
4cdf15a0f6 | |||
3b3e590e73 | |||
117bcd83d6 | |||
3419a28a9f | |||
e3f605a02f | |||
9e5144bab9 | |||
35595211b6 | |||
449e78e0b0 | |||
fa629a53bd | |||
311225e0a1 | |||
edb81e828b | |||
083df800b5 | |||
ed0febc902 | |||
a6bd3e6e44 | |||
70256bd8b0 | |||
f1de74a6ac | |||
52933ebd40 | |||
cbf385ac05 | |||
2f71c4b69b | |||
4ebbbba82b | |||
be85e295e8 | |||
f86d487706 | |||
90faa3941c | |||
9d0d5199ba | |||
343e74b8e3 | |||
7cd8b9ec24 | |||
7147a00fd7 | |||
3ed0626756 | |||
6c6be971ed | |||
94c31a790b | |||
74fa42ed13 | |||
4960d8dab2 | |||
e089e0748f | |||
e26866d3fa | |||
09cc98f60d | |||
69759731bb | |||
59f39e5d7f | |||
194f357eeb | |||
b84385cfce | |||
5d6867d35c | |||
0d93777ece | |||
6206535453 | |||
a4633c2c1e | |||
bd1fd9610e | |||
379fbc51e3 | |||
438e735dcc | |||
c96897198a | |||
b5f60f0448 | |||
8de7e29fc7 | |||
43ab929257 | |||
c9a04a1a9a | |||
ef388661b3 | |||
b3180d3a5a | |||
c9b96f2c88 | |||
ea6ca22e3f | |||
42a7f0c70c | |||
4cb056c80b | |||
17c0fa271c | |||
d87e1f3ade | |||
132828a8db | |||
63acc5c633 | |||
8b60f2c768 | |||
79d2a66831 | |||
3afac93b7f | |||
3af0142509 | |||
19f0726533 | |||
502abb9884 | |||
9b477525de | |||
fd0f99c767 | |||
259e917eaf | |||
665477de19 | |||
2a065b2420 | |||
b130e25804 | |||
49cfefdef5 | |||
f064012939 | |||
ceffd1cf79 | |||
298de4cd85 | |||
9e6bdc13ba | |||
654ae838ee | |||
b07224c752 | |||
1d91272a55 | |||
d70210e6f2 | |||
8e7eeeb6d9 | |||
7cd6631cae | |||
96054b0b48 | |||
b795de8310 | |||
e513fb7e01 | |||
9928939724 | |||
87ecc0caee | |||
2d78bde327 | |||
946d451d03 | |||
b60d4c7172 | |||
d1aea63c2f | |||
ebbfe65595 | |||
738bd42696 | |||
caeff56002 | |||
d3b13dd490 | |||
01b4147e09 | |||
a8084dcb12 | |||
ec4783e655 | |||
e7880d8963 | |||
226dbab183 | |||
3d3dea1411 | |||
fbc0057432 | |||
6f0ab4a8be | |||
4c28983459 | |||
58d1ee1444 | |||
2735dcff18 | |||
e7185c2966 | |||
5366172708 | |||
b02c60e468 | |||
c55650216f | |||
1e6ba3c885 | |||
4f34d95156 | |||
650b75d2d7 | |||
8af782611e | |||
34cea300e5 | |||
cca9739022 | |||
30e6df5a15 | |||
2285f909f6 | |||
0addcfadeb | |||
426e0c39a8 | |||
f662a07bcc | |||
90ce7f3703 | |||
a59819fc6e | |||
2480b52f5b | |||
b4f00e3c18 | |||
43d2ca8549 | |||
b0c1cf556f | |||
8be23dd1aa | |||
1eb5554da9 | |||
3d3631744f | |||
991bd7f8be | |||
c908e04144 | |||
1c18f42e83 | |||
fe79a8efdd | |||
58d57f9b7b | |||
4971da58ee | |||
4df157ac11 | |||
45a1acb980 | |||
537f2474c9 | |||
f228ab608a | |||
cbd915a988 | |||
fc88bc06ad | |||
4a44cc75c9 | |||
86b169dab3 | |||
36843ccdba | |||
17e4f7024d | |||
3379affd4a | |||
958b4fbf6e | |||
61979ff421 | |||
1d51c3afb2 | |||
2726efa8c1 | |||
a417560f09 | |||
b7f443e583 | |||
f49e347772 | |||
bf4ca510ea | |||
665c4a3234 | |||
bda0d613c1 | |||
dceccc9de9 | |||
dc46fc13ab | |||
a72eae6099 | |||
5a04c9e05b | |||
e6279d4436 | |||
11238e4c19 | |||
1cb6a99c80 | |||
2f3d82be9f | |||
47e478d099 | |||
c4bd4bf4ce | |||
41b76f8f5c | |||
846f11a96c | |||
8810c4c4aa | |||
91428c2110 | |||
44c26a3356 | |||
b06fca8378 | |||
3b3889b70f | |||
5ed6116490 | |||
df1a3a334f | |||
126e6861d7 | |||
d490a84c8d | |||
10af4fc1e0 | |||
f8bb8aafbf | |||
c6a6a46db4 | |||
cc8a1413cb | |||
1131136d4a | |||
3cd6a7277f | |||
19a2090ef8 | |||
67f457ade1 | |||
7315e2c14e | |||
cafea6aea5 | |||
96c78123f0 | |||
868858b844 | |||
367582d0f4 | |||
6d46ce412f | |||
2da424d940 | |||
a5d94bbe21 | |||
716cf7795e | |||
55fd3ca5b2 | |||
c506d2537f | |||
efb7b50a8a | |||
674be9dfa0 | |||
fd63de33e9 | |||
014fdb8ace | |||
9cf925c079 | |||
4fc942f45e | |||
48fc316156 | |||
c66fb8e807 | |||
3adf4d2869 | |||
de24df7962 | |||
dfa0764d53 | |||
d68174a51d | |||
612cec17bb | |||
1ff26bc99b | |||
4b96ce34aa | |||
65b22bfa38 | |||
9e48730a0e | |||
fb8994f51c | |||
ce9d9b4726 | |||
26c095d022 | |||
22c4ab4a06 | |||
a06f11589f | |||
109bf20484 | |||
183e449a31 | |||
7c3b66d520 | |||
334bc28136 | |||
40714ccc7e | |||
5bb66037d3 | |||
74a01a4487 | |||
ef000176d8 | |||
ca2328ed87 | |||
db345d4e8e | |||
aebb16feef | |||
794fd3e226 | |||
88001ada37 | |||
5b1d0544e2 | |||
c9802507ab | |||
91d62c2c1a | |||
3ef3363c2d | |||
7e065ca313 | |||
1d5fb47238 | |||
83c89f3038 | |||
e3e1fc43d3 | |||
5364ea2cad | |||
ec58d739eb | |||
925b3ad355 | |||
abc18532e4 | |||
f9eeb5d447 | |||
a47f15a98f | |||
adc4b5db3b | |||
1dea353fa3 | |||
3e2d5cb786 | |||
f6c15771e2 | |||
4641e2e69d | |||
a1cb3d9795 | |||
4830359a93 | |||
cf63ba0dc9 | |||
dfc30e334d | |||
22fcae4fcb | |||
47b40f66e1 | |||
350a1f8bfc | |||
13b748a228 | |||
cab01e8ba3 | |||
eea32403ef | |||
067b63da8e | |||
52c04e94f9 | |||
b573b6c9bf | |||
a24a69f38e | |||
6e2e1d592b | |||
704ce0186a | |||
3a6c6c6bcd | |||
c6c4634aca | |||
a420ef96bc | |||
29b2053f5c | |||
cee9ffc1a8 | |||
6cc4cbf1a1 | |||
debce93f63 | |||
71c2ca614c | |||
d0544400af | |||
f8f29ae7d3 | |||
39d77206e1 | |||
690ebf406e | |||
22c72c53eb | |||
b4ae711d4e | |||
629ab6adbf | |||
40d20d65ca | |||
bed353556f | |||
b0d1db7c2e | |||
1461479a17 | |||
29fa877949 | |||
7663f559f2 | |||
a39946c55d | |||
90f4eca5cd | |||
52b9581e4f | |||
c8c808b04e | |||
bcc0ea30cf | |||
deefb61ec6 | |||
837bf05867 | |||
12d904a5e4 | |||
5e7948667e | |||
a65512ed5c | |||
26b096f65d | |||
2dab8cfbc9 | |||
a85afbe470 | |||
8724a83c49 | |||
e7902d439b | |||
d20121bf12 | |||
b4f99d66b5 | |||
d1c2c5ce3f | |||
15a697f86b | |||
dbef3564c4 | |||
b948d9af17 | |||
95d424012b | |||
36a99eb0a0 | |||
f117011b60 | |||
7c0d73b8cf | |||
405ebd8cca | |||
94b45ef51e | |||
e115ac1006 | |||
8b712359a2 | |||
428e72ed22 | |||
062e820882 | |||
73db2a05b6 | |||
4d381e8564 | |||
507d1e8075 | |||
d31787daae | |||
fd00cc129f | |||
8291ce67fc | |||
14a9a1906b | |||
dbfa1df088 | |||
f65c137e73 | |||
5afec2b74f | |||
8085605217 | |||
a33d5c22c5 | |||
901266b76a | |||
0eb365edbe | |||
2e0d7eab4a | |||
637dc618d1 | |||
dd1459f221 | |||
ba96d075b2 | |||
a2f3a45214 | |||
6ac0cfe09c | |||
7b3857a9a8 | |||
2605b9ee45 | |||
1509d5603b | |||
93deddde63 | |||
68a63cab85 | |||
06c54ccd48 | |||
2e298b5e60 | |||
00e70244a5 | |||
3f98d69c94 | |||
4767db522b | |||
f6e555dda3 | |||
01826978d6 | |||
336c12b60f | |||
82768af3d2 | |||
8984de1c74 | |||
4db083cd6d | |||
f4cde208f2 | |||
d130dff5ec | |||
aa9158b199 | |||
bbd9fdb7bd | |||
17514e1d44 | |||
d759c23552 | |||
cf9ad808a6 | |||
028bff0c22 | |||
33a8016af3 | |||
24466ae189 | |||
c8ffe55ae5 | |||
a862a573df | |||
25e932149c | |||
0b0dfc0e06 | |||
e0a76af0f9 | |||
51650f1aa2 | |||
c54e15d374 | |||
fd448ffa31 | |||
aeb47120e3 | |||
22b7b4ec8e | |||
21b558fe5e | |||
33c8f3e3ec | |||
523f8a5926 | |||
a933622ae1 | |||
3bd0d886c4 | |||
f49be0b382 | |||
e46eae8144 | |||
007117cefb | |||
12cf02586c | |||
73bb3d899a | |||
4a8987865e | |||
f885495565 | |||
dc34cd6079 | |||
5850d7ce3e | |||
554f832234 | |||
dc96b440be | |||
ee024f588b | |||
8e715b3810 | |||
1ac9efbd6a | |||
d2f0c15826 | |||
ae953cda6b | |||
b22773b2e3 | |||
e50a544c2a | |||
4b362a9cff | |||
c75dc3ae02 | |||
fa03f39333 | |||
6478f85444 | |||
51f7fe9878 | |||
c08103b1c5 | |||
a2b6c3f5ec | |||
e76e9cda28 | |||
cd6a5e6a7f | |||
e82a7fab5d |
151
.travis.yml
Normal file
151
.travis.yml
Normal file
@ -0,0 +1,151 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc-5 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc-5 CXXSTD=14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc-6 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc-6 CXXSTD=14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc-7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc-7 CXXSTD=14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=03,11
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=14,1z
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/range
|
||||
- python tools/boostdep/depinst/depinst.py range
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- ./b2 -j 3 libs/range/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
41
CMakeLists.txt
Normal file
41
CMakeLists.txt
Normal file
@ -0,0 +1,41 @@
|
||||
# Generated by `boostdep --cmake range`
|
||||
# Copyright 2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(boost_range VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_range INTERFACE)
|
||||
add_library(Boost::range ALIAS boost_range)
|
||||
|
||||
target_include_directories(boost_range INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_range
|
||||
INTERFACE
|
||||
Boost::array
|
||||
Boost::assert
|
||||
Boost::concept_check
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::conversion
|
||||
Boost::core
|
||||
Boost::detail
|
||||
Boost::iterator
|
||||
Boost::mpl
|
||||
Boost::optional
|
||||
Boost::preprocessor
|
||||
Boost::regex
|
||||
Boost::static_assert
|
||||
Boost::tuple
|
||||
Boost::type_traits
|
||||
Boost::utility
|
||||
)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
1
doc/.gitignore
vendored
Normal file
1
doc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.html
|
35
doc/Jamfile.v2
Normal file
35
doc/Jamfile.v2
Normal file
@ -0,0 +1,35 @@
|
||||
#// Boost.Range library
|
||||
#//
|
||||
#// Copyright Thorsten Ottosen 2003-2008. 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/range/
|
||||
#//
|
||||
|
||||
project boost/libs/range/doc ;
|
||||
using boostbook ;
|
||||
using quickbook ;
|
||||
|
||||
path-constant images_location : html ;
|
||||
|
||||
boostbook quickbook
|
||||
:
|
||||
boost_range.qbk
|
||||
:
|
||||
<xsl:param>boost.root=../../../..
|
||||
<xsl:param>chunk.section.depth=4
|
||||
<xsl:param>chunk.first.sections=1
|
||||
<xsl:param>toc.section.depth=3
|
||||
<xsl:param>toc.max.depth=3
|
||||
<xsl:param>generate.section.toc.level=4
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
|
||||
<format>pdf:<xsl:param>img.src.path=$(images_location)/
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : quickbook ;
|
||||
explicit boostrelease ;
|
@ -1,542 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost.Range Range Implementation </title>
|
||||
<meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table >
|
||||
<tr >
|
||||
<td ><img src="../../../boost.png" width="100%" border="0"></td>
|
||||
<td ><h1 ><br>
|
||||
Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Synopsis and Reference </h2>
|
||||
|
||||
<ul >
|
||||
<li>
|
||||
<a href="#overview">Overview</a>
|
||||
<li >
|
||||
<a href="#Synopsis" >Synopsis</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#Semantics" >Semantics</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#minimal_interface">Extending the library</a>
|
||||
</ul>
|
||||
<hr size="1" >
|
||||
|
||||
<a name="overview"></a>
|
||||
<h3>Overview</h3>
|
||||
<p>
|
||||
Four types of objects are currently supported by the library:
|
||||
<ul >
|
||||
<li >
|
||||
standard-like containers
|
||||
</li>
|
||||
<li >
|
||||
<code >std::pair<iterator,iterator></code>
|
||||
</li>
|
||||
<li >
|
||||
null terminated strings (this includes <code >char[]</code>,<code >wchar_t[]</code>,
|
||||
<code >char*</code>, and <code >wchar_t*</code>)
|
||||
</li>
|
||||
<li >
|
||||
built-in arrays
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Even though the behavior of the primary templates are exactly such that standard
|
||||
containers will be supported by default, the requirements are much lower than
|
||||
the standard container requirements. For example, the utility class <a
|
||||
href="utility_class.html#iter_range"><code>iterator_range</code></a> implements
|
||||
the <a href="#minimal_interface">minimal interface</a> required to make the
|
||||
class a <a href="range.html#forward_range">Forward Range</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please also see <a href="range.html">Range concepts</a> for more details.
|
||||
</p>
|
||||
|
||||
<a name="Synopsis" ></a> <h3 >Synopsis</h3>
|
||||
|
||||
<p >
|
||||
|
||||
<pre>
|
||||
<span class=keyword>namespace </span><span class=identifier>boost</span>
|
||||
<span class=special>{
|
||||
</span><span class=comment>//
|
||||
// Single Pass Range metafunctions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a href="#range_value"><span
|
||||
class=identifier>range_value</span></a><span class=special>;
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a href="#range_iterator"><span
|
||||
class=identifier>range_iterator</span></a><span class=special>;
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a href="#range_const_iterator"><span
|
||||
class=identifier>range_const_iterator</span></a><span class=special>;
|
||||
|
||||
</span><span class=comment>//
|
||||
// Forward Range metafunctions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a href="#range_difference"><span
|
||||
class=identifier>range_difference</span></a><span class=special>;
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a href="#range_size"><span
|
||||
class=identifier>range_size</span></a><span class=special>;
|
||||
|
||||
</span><span class=comment>//
|
||||
// Bidirectional Range metafunctions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a
|
||||
href="#range_reverse_iterator"><span
|
||||
class=identifier>range_reverse_iterator</span></a><span class=special>;
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a
|
||||
href="#range_const_reverse_iterator"><span
|
||||
class=identifier>range_const_reverse_iterator</span></a><span class=special>;
|
||||
|
||||
</span><span class=comment>//
|
||||
// Special metafunctions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a href="#range_result_iterator"><span
|
||||
class=identifier>range_result_iterator</span></a><span class=special>;
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>struct </span><a
|
||||
href="#range_reverse_result_iterator"><span
|
||||
class=identifier>range_reverse_result_iterator</span></a><span class=special>;
|
||||
|
||||
</span><span class=comment>//
|
||||
// Single Pass Range functions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#begin"><span class=identifier>begin</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_const_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#begin"><span class=identifier>begin</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#end"><span class=identifier>end</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_const_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#end"><span class=identifier>end</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>bool
|
||||
</span><a href="#empty"><span class=identifier>empty</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=comment>//
|
||||
// Forward Range functions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_size</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#size"><span class=identifier>size</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=comment>//
|
||||
// Bidirectional Range functions
|
||||
//
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#rbegin"><span class=identifier>rbegin</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_const_reverse_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#rbegin"><span class=identifier>rbegin</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#rend"><span class=identifier>rend</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_const_reverse_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type
|
||||
</span><a href="#rend"><span class=identifier>rend</span></a><span class=special>( </span><span class=keyword>const </span><span
|
||||
class=identifier>T</span><span class=special>& </span><span class=identifier>c </span><span class=special>);
|
||||
</span>
|
||||
<span class=comment>//
|
||||
// Special const Range functions
|
||||
//
|
||||
</span>
|
||||
<span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>></span>
|
||||
<span class=keyword>typename </span><span class=identifier>range_const_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span>
|
||||
<a href="#const_begin"><span class=identifier>const_begin</span></a><span class=special>(</span><span class=keyword> const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
</span>
|
||||
<span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>></span>
|
||||
<span class=keyword>typename </span><span class=identifier>range_const_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span>
|
||||
<a href="#const_end"><span class=identifier>const_end</span></a><span class=special>(</span><span class=keyword> const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
</span>
|
||||
<span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>></span>
|
||||
<span class=keyword>typename </span><span class=identifier>range_const_reverse_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span>
|
||||
<a href="#const_rbegin"><span class=identifier>const_rbegin</span></a><span class=special>(</span><span class=keyword> const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
</span>
|
||||
<span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>></span>
|
||||
<span class=keyword>typename </span><span class=identifier>range_const_reverse_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span>
|
||||
<a href="#const_rend"><span class=identifier>const_rend</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>);</span>
|
||||
|
||||
<span class=special>} </span><span class=comment>// namespace 'boost'
|
||||
</span>
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
<a name="Semantics" ></a> <h3 >Semantics</h3>
|
||||
|
||||
<h4>notation</h4>
|
||||
<p>
|
||||
<table cellpadding="5" border="1">
|
||||
<tr>
|
||||
<th>Type
|
||||
<th>Object
|
||||
<th>Describes
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>X</code>
|
||||
<td><code>x</code>
|
||||
<td>any type
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>T</code> </td>
|
||||
<td><code>t</code>
|
||||
<td>denotes behavior of the primary templates</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>P</code>
|
||||
<td><code>p</code>
|
||||
<td>denotes <code>std::pair<iterator,iterator></code>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>A[sz]</code>
|
||||
<td><code>a</code>
|
||||
<td>denotes an array of type <code>A</code> of size <code>sz</code>
|
||||
<tr>
|
||||
<tr>
|
||||
<td><code>Char*</code>
|
||||
<td><code>s</code>
|
||||
<td>denotes either <code>char*</code> or <code>wchar_t*</code>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please notice in tables below that when four lines appear in a cell, the first
|
||||
line will describe the primary template, the second line pairs of iterators, the
|
||||
third line arrays and the last line null-terminated strings.
|
||||
</p>
|
||||
<h4>Metafunctions</h4>
|
||||
<p>
|
||||
<table border="1" cellpadding="5" >
|
||||
<tr >
|
||||
<th >Expression</th>
|
||||
<th >Return type</th>
|
||||
<th >Complexity</th>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_value" ></a>
|
||||
<td ><code >range_value<X>::type</code></td>
|
||||
<td ><code >T::value_type</code><br>
|
||||
<code >boost::iterator_value<P::first_type>::type</code><br>
|
||||
<code >A</code><br>
|
||||
<code>Char</code>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_iterator" ></a>
|
||||
<td ><code >range_iterator<X>::type</code></td>
|
||||
<td ><code >T::iterator</code><br>
|
||||
<code >P::first_type</code><br>
|
||||
<code >A*</code><br>
|
||||
<code>Char*</code>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_const_iterator" ></a>
|
||||
<td ><code >range_const_iterator<X>::type</code></td>
|
||||
<td ><code >T::const_iterator</code><br>
|
||||
<code >P::first_type</code><br>
|
||||
<code >const A*</code><br>
|
||||
<code>const Char*</code>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_difference" ></a>
|
||||
<td ><code >range_difference<X>::type</code></td>
|
||||
<td ><code >T::difference_type</code><br>
|
||||
<code
|
||||
>boost_iterator_difference<P::first_type>::type</code><br>
|
||||
<code >std::ptrdiff_t</code><br>
|
||||
<code >std::ptrdiff_t</code><br>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_size" ></a>
|
||||
<td ><code >range_size<X>::type</code></td>
|
||||
<td ><code >T::size_type</code><br>
|
||||
<code >std::size_t</code><br>
|
||||
<code >std::size_t</code><br>
|
||||
<code >std::size_t</code><br>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_result_iterator" ></a>
|
||||
<td ><code >range_result_iterator<X>::type</code></td>
|
||||
<td ><code >range_const_iterator<X>::type</code> if <code
|
||||
>X</code> is <code >const</code> <br>
|
||||
<code >range_iterator<X>::type</code> otherwise </td>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_reverse_iterator" ></a>
|
||||
<td ><code >range_reverse_iterator<X>::type</code></td>
|
||||
<td ><code >boost::reverse_iterator< typename range_iterator<T>::type ></code><br>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_const_reverse_iterator" ></a>
|
||||
<td ><code >range_const_reverse_iterator<X>::type</code></td>
|
||||
<td ><code >boost::reverse_iterator< typename range_const_iterator<T>::type ></code>
|
||||
<br>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="range_reverse_result_iterator" ></a>
|
||||
<td ><code >range_reverse_result_iterator<X>::type</code></td>
|
||||
<td ><code >boost::reverse_iterator< typename range_result_iterator<T>::type
|
||||
></code>
|
||||
<td >compile time</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
The special metafunctions <code>range_result_iterator</code> and <code>range_reverse_result_iterator</code>
|
||||
are not part of any Range concept, but they are very useful when implementing
|
||||
certain Range classes like <a
|
||||
href="utility_class.html#sub_range"><code>sub_range</code></a> because of their
|
||||
ability to select iterators based on constness.
|
||||
</p>
|
||||
|
||||
<h4>Functions</h4>
|
||||
<p>
|
||||
<table border="1" cellpadding="5" >
|
||||
<tr >
|
||||
<th >Expression</th>
|
||||
<th >Return type</th>
|
||||
<th >Returns</th>
|
||||
<th >Complexity</th>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="begin" ></a>
|
||||
<td ><code >begin(x)</code></td>
|
||||
<td ><code >range_result_iterator<X>::type</code></td>
|
||||
<td ><code >t.begin()</code><br>
|
||||
<code >p.first</code><br>
|
||||
<code >a</code><br>
|
||||
<code>s</code>
|
||||
<td >constant time</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="end" ></a>
|
||||
<td ><code >end(x)</code></td>
|
||||
<td ><code >range_result_iterator<X>::type</code></td>
|
||||
<td ><code >t.end()</code><br>
|
||||
<code >p.second</code><br>
|
||||
<code >a + sz</code> <br>
|
||||
<code >s + std::char_traits<X>::length( s )</code> if <code >X</code> is <code >Char*</code>
|
||||
<br>
|
||||
<code >s + sz - 1</code> if <code >X</code> is <code >Char[sz]</code> <br>
|
||||
|
||||
|
||||
<td >linear if <code >X</code> is <code >Char*</code> <br>
|
||||
constant time otherwise</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="empty" ></a>
|
||||
<td ><code >empty(x)</code></td>
|
||||
<td ><code >bool</code></td>
|
||||
<td ><code >begin(x) == end( x )</code><br>
|
||||
<td >linear if <code >X</code> is <code >Char*</code> <br>
|
||||
constant time otherwise<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="size" ></a>
|
||||
<td ><code >size(x)</code></td>
|
||||
<td ><code >range_size<X>::type</code></td>
|
||||
<td ><code >t.size()</code><br>
|
||||
<code>std::distance(p.first,p.second)</code><br>
|
||||
<code >sz</code><br>
|
||||
<code>end(s) - s</code>
|
||||
|
||||
<td >linear if <code >X</code> is <code >Char*</code> <br>
|
||||
or if <code >std::distance()</code> is linear <br>
|
||||
constant time otherwise</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="rbegin" ></a>
|
||||
<td ><code >rbegin(x)</code></td>
|
||||
<td ><code >range_reverse_result_iterator<X>::type</code></td>
|
||||
<td ><code >range_reverse_result_iterator<X>::type( end(x) )</code> <br>
|
||||
<td >same as <code>end(x)</code> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="rend" ></a>
|
||||
<td ><code >rend(x)</code></td>
|
||||
<td ><code >range_reverse_result_iterator<X>::type</code></td>
|
||||
<td ><code >range_reverse_result_iterator<X>::type( begin(x) )</code>
|
||||
<td >same as <code>begin(x)</code></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="const_begin" ></a>
|
||||
<td ><code >const_begin(x)</code></td>
|
||||
<td ><code >range_const_iterator<X>::type</code></td>
|
||||
<td ><code >range_const_iterator<X>::type( begin(x) )</code>
|
||||
<br> <td >same as <code>begin(x)</code> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="const_end" ></a>
|
||||
<td ><code >const_end(x)</code></td>
|
||||
<td ><code >range_const_iterator<X>::type</code></td>
|
||||
<td ><code >range_const_iterator<X>::type( end(x) )</code>
|
||||
<td >same as <code>end(x)</code></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="const_rbegin" ></a>
|
||||
<td ><code >const_rbegin(x)</code></td>
|
||||
<td ><code >range_const_reverse_iterator<X>::type</code></td>
|
||||
<td ><code >range_const_reverse_iterator<X>::type( rbegin(x) )</code>
|
||||
<br> <td >same as <code>rbegin(x)</code> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<a name="const_rend" ></a>
|
||||
<td ><code >const_rend(x)</code></td>
|
||||
<td ><code >range_const_reverse_iterator<X>::type</code></td>
|
||||
<td ><code >range_const_reverse_iterator<X>::type( rend(x) )</code>
|
||||
<td >same as <code>rend(x)</code></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The special <code>const</code> functions are not part of any Range concept,
|
||||
but are very useful when you want to document clearly that your code is
|
||||
read-only.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<a name=minimal_interface></a> <h3>Extending the library</h3>
|
||||
<p>
|
||||
The primary templates in this library are implemented such that standard
|
||||
containers will work automatically and so will <code>boost::<a
|
||||
href=../../array/index.html>array</a></code>. Below is given an overview of
|
||||
which member functions and member types a class must specify to
|
||||
be useable as a certain Range concept.
|
||||
</p>
|
||||
<p>
|
||||
<table cellpadding="5" border="1">
|
||||
<tr>
|
||||
<th>Member function</th>
|
||||
<th>Related concept</th>
|
||||
<tr>
|
||||
<td><code>begin()</code></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>end()</code> </td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>size()</code></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
Notice that <code>rbegin()</code> and <code>rend()</code> member functions
|
||||
are not needed even though the container can support bidirectional iteration.
|
||||
</p>
|
||||
<p>
|
||||
The required member types are:
|
||||
</p>
|
||||
<p>
|
||||
<table cellpadding="5" border="1">
|
||||
<tr>
|
||||
<th>Member type</th>
|
||||
<th>Related concept</th>
|
||||
<tr>
|
||||
<tr>
|
||||
<td><code>value_type</code></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>iterator</code></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>const_iterator</code></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>difference_type</code></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>size_type</code></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
Again one should notice that member types <code>reverse_iterator</code> and
|
||||
<code>const_reverse_iterator</code> are not needed.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
199
doc/boost_range.qbk
Normal file
199
doc/boost_range.qbk
Normal file
@ -0,0 +1,199 @@
|
||||
[/==============================================================================
|
||||
Copyright (C) 2003-2010 Thorsten Ottosen, Neil Groves
|
||||
|
||||
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
|
||||
==============================================================================/]
|
||||
[library Range
|
||||
[quickbook 1.5]
|
||||
[version 2.0]
|
||||
[authors [Ottosen, Thorsten], [Groves, Neil]]
|
||||
[copyright 2003-2010 Thorsten Ottosen, Neil Groves]
|
||||
[purpose Half-open range library]
|
||||
[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])
|
||||
]
|
||||
]
|
||||
|
||||
[/ Converted to Quickbook format by Darren Garvey, 2007]
|
||||
|
||||
[def __note__ [$images/note.png]]
|
||||
[def __alert__ [$images/alert.png]]
|
||||
[def __tip__ [$images/tip.png]]
|
||||
[def __caution__ [$images/caution.png]]
|
||||
|
||||
[def __boost_range_home__ [link range Boost.Range]]
|
||||
[def __ranges__ [link range.concepts Ranges]]
|
||||
[def __range_concepts__ [link range.concepts Range concepts]]
|
||||
[def __forward_range__ [link range.concepts.forward_range Forward Range]]
|
||||
[def __single_pass_range__ [link range.concepts.single_pass_range Single Pass Range]]
|
||||
[def __bidirectional_range__ [link range.concepts.bidirectional_range Bidirectional Range]]
|
||||
[def __random_access_range__ [link range.concepts.random_access_range Random Access Range]]
|
||||
|
||||
[def __iterator_range__ [link range.reference.utilities.iterator_range `iterator_range`]]
|
||||
[def __sub_range__ [link range.reference.utilities.sub_range `sub_range`]]
|
||||
[def __minimal_interface__ [link range.reference.extending minimal interface]]
|
||||
[def __range_result_iterator__ [link range.reference.concept_implementation.semantics.metafunctions `range_result_iterator`]]
|
||||
[def __extending_for_udts__ [link range.reference.extending Extending the library for UDTs]]
|
||||
[def __implementation_of_metafunctions__ [link range.reference.concept_implementation.semantics.metafunctions Implementation of metafunctions]]
|
||||
[def __implementation_of_functions__ [link range.reference.concept_implementation.semantics.functions Implementation of functions]]
|
||||
|
||||
[def __range_value__ [link range.reference.concept_implementation.semantics.metafunctions `range_value`]]
|
||||
[def __range_iterator__ [link range.reference.concept_implementation.semantics.metafunctions `range_iterator`]]
|
||||
[def __range_difference__ [link range.reference.concept_implementation.semantics.metafunctions `range_difference`]]
|
||||
[def __range_pointer__ [link range.reference.concept_implementation.semantics.metafunctions `range_pointer`]]
|
||||
[def __range_category__ [link range.reference.concept_implementation.semantics.metafunctions `range_category`]]
|
||||
[def __range_reverse_iterator__ [link range.reference.concept_implementation.semantics.metafunctions `range_reverse_iterator`]]
|
||||
[def __begin__ [link range.reference.concept_implementation.semantics.functions `begin`]]
|
||||
[def __const_begin__ [link range.reference.concept_implementation.semantics.functions `const_begin`]]
|
||||
[def __end__ [link range.reference.concept_implementation.semantics.functions `end`]]
|
||||
[def __const_end__ [link range.reference.concept_implementation.semantics.functions `const_end`]]
|
||||
[def __empty__ [link range.reference.concept_implementation.semantics.functions `empty`]]
|
||||
[def __distance__ [link range.reference.concept_implementation.semantics.functions `distance`]]
|
||||
[def __size__ [link range.reference.concept_implementation.semantics.functions `size`]]
|
||||
[def __rbegin__ [link range.reference.concept_implementation.semantics.functions `rbegin`]]
|
||||
[def __const_rbegin__ [link range.reference.concept_implementation.semantics.functions `const_rbegin`]]
|
||||
[def __rend__ [link range.reference.concept_implementation.semantics.functions `rend`]]
|
||||
[def __const_rend__ [link range.reference.concept_implementation.semantics.functions `const_rend`]]
|
||||
[def __as_array__ [link range.reference.concept_implementation.semantics.functions `as_array`]]
|
||||
[def __as_literal__ [link range.reference.concept_implementation.semantics.functions `as_literal`]]
|
||||
[def __counting_range__ [link range.reference.ranges.counting_range `counting_range`]]
|
||||
[def __irange__ [link range.reference.ranges.irange `irange`]]
|
||||
[def __istream_range__ [link range.reference.ranges.istream_range `istream_range`]]
|
||||
[def __combine__ [link range.reference.utilities.combine `combine`]]
|
||||
[def __join__ [link range.reference.utilities.join `join`]]
|
||||
|
||||
[def __range_adaptors__ [link range.reference.adaptors Range adaptors]]
|
||||
[def __range_adaptors_adjacent_filtered__ [link range.reference.adaptors.reference.adjacent_filtered adjacent_filtered]]
|
||||
[def __range_adaptors_copied__ [link range.reference.adaptors.reference.copied copied]]
|
||||
[def __range_adaptors_filtered__ [link range.reference.adaptors.reference.filtered filtered]]
|
||||
[def __range_adaptors_formatted__ [link.range.reference.adaptors.reference.formatted formatted]]
|
||||
[def __range_adaptors_indexed__ [link range.reference.adaptors.reference.indexed indexed]]
|
||||
[def __range_adaptors_indirected__ [link range.reference.adaptors.reference.indirected indirected]]
|
||||
[def __range_adaptors_map_keys__ [link range.reference.adaptors.reference.map_keys map_keys]]
|
||||
[def __range_adaptors_map_values__ [link range.reference.adaptors.reference.map_values map_values]]
|
||||
[def __range_adaptors_replaced__ [link range.reference.adaptors.reference.replaced replaced]]
|
||||
[def __range_adaptors_replaced_if__ [link range.reference.adaptors.reference.replaced_if replaced_if]]
|
||||
[def __range_adaptors_reversed__ [link range.reference.adaptors.reference.reversed reversed]]
|
||||
[def __range_adaptors_sliced__ [link range.reference.adaptors.reference.sliced sliced]]
|
||||
[def __range_adaptors_strided__ [link range.reference.adaptors.reference.strided strided]]
|
||||
[def __range_adaptors_type_erased__ [link range.reference.adaptors.reference.type_erased type_erased]]
|
||||
[def __range_adaptors_tokenized__ [link range.reference.adaptors.reference.tokenized tokenized]]
|
||||
[def __range_adaptors_transformed__ [link range.reference.adaptors.reference.transformed transformed]]
|
||||
[def __range_adaptors_uniqued__ [link range.reference.adaptors.reference.uniqued uniqued]]
|
||||
|
||||
|
||||
[def __range_algorithms__ [link range.reference.algorithms Range algorithms]]
|
||||
[def __range_algorithms_adjacent_find__ [link range.reference.algorithms.non_mutating.adjacent_find adjacent_find]]
|
||||
[def __range_algorithms_binary_search__ [link range.reference.algorithms.non_mutating.binary_search binary_search]]
|
||||
[def __range_algorithms_count__ [link range.reference.algorithms.non_mutating.count count]]
|
||||
[def __range_algorithms_count_if__ [link range.reference.algorithms.non_mutating.count_if count_if]]
|
||||
[def __range_algorithms_equal__ [link range.reference.algorithms.non_mutating.equal equal]]
|
||||
[def __range_algorithms_equal_range__ [link range.reference.algorithms.non_mutating.equal_range equal_range]]
|
||||
[def __range_algorithms_for_each__ [link range.reference.algorithms.non_mutating.for_each for_each]]
|
||||
[def __range_algorithms_find__ [link range.reference.algorithms.non_mutating.find find]]
|
||||
[def __range_algorithms_find_end__ [link range.reference.algorithms.non_mutating.find_end find_end]]
|
||||
[def __range_algorithms_find_first_of__ [link range.reference.algorithms.non_mutating.find_first_of find_first_of]]
|
||||
[def __range_algorithms_find_if__ [link range.reference.algorithms.non_mutating.find_if find_if]]
|
||||
[def __range_algorithms_lexicographical_compare__ [link range.reference.algorithms.non_mutating.lexicographical_compare lexicographical_compare]]
|
||||
[def __range_algorithms_lower_bound__ [link range.reference.algorithms.non_mutating.lower_bound lower_bound]]
|
||||
[def __range_algorithms_max_element__ [link range.reference.algorithms.non_mutating.max_element max_element]]
|
||||
[def __range_algorithms_min_element__ [link range.reference.algorithms.non_mutating.min_element min_element]]
|
||||
[def __range_algorithms_mismatch__ [link range.reference.algorithms.non_mutating.mismatch mismatch]]
|
||||
[def __range_algorithms_search__ [link range.reference.algorithms.non_mutating.search search]]
|
||||
[def __range_algorithms_search_n__ [link range.reference.algorithms.non_mutating.search_n search_n]]
|
||||
[def __range_algorithms_upper_bound__ [link range.reference.algorithms.non_mutating.upper_bound upper_bound]]
|
||||
|
||||
[def __range_algorithms_copy__ [link range.reference.algorithms.mutating.copy copy]]
|
||||
[def __range_algorithms_copy_backward__ [link range.reference.algorithms.mutating.copy_backward copy_backward]]
|
||||
[def __range_algorithms_fill__ [link range.reference.algorithms.mutating.fill fill]]
|
||||
[def __range_algorithms_fill_n__ [link range.reference.algorithms.mutating.fill_n fill_n]]
|
||||
[def __range_algorithms_generate__ [link range.reference.algorithms.mutating.generate generate]]
|
||||
[def __range_algorithms_inplace_merge__ [link range.reference.algorithms.mutating.inplace_merge inplace_merge]]
|
||||
[def __range_algorithms_merge__ [link range.reference.algorithms.mutating.merge merge]]
|
||||
[def __range_algorithms_nth_element__ [link range.reference.algorithms.mutating.nth_element nth_element]]
|
||||
[def __range_algorithms_partial_sort__ [link range.reference.algorithms.mutating.partial_sort partial_sort]]
|
||||
[def __range_algorithms_partition__ [link range.reference.algorithms.mutating.partition partition]]
|
||||
[def __range_algorithms_random_shuffle__ [link range.reference.algorithms.mutating.random_shuffle random_shuffle]]
|
||||
[def __range_algorithms_remove__ [link range.reference.algorithms.mutating.remove remove]]
|
||||
[def __range_algorithms_remove_copy__ [link range.reference.algorithms.mutating.remove_copy remove_copy]]
|
||||
[def __range_algorithms_remove_copy_if__ [link range.reference.algorithms.mutating.remove_copy_if remove_copy_if]]
|
||||
[def __range_algorithms_remove_if__ [link range.reference.algorithms.mutating.remove_if remove_if]]
|
||||
[def __range_algorithms_replace__ [link range.reference.algorithms.mutating.replace replace]]
|
||||
[def __range_algorithms_replace_copy__ [link range.reference.algorithms.mutating.replace_copy replace_copy]]
|
||||
[def __range_algorithms_replace_copy_if__ [link range.reference.algorithms.mutating.replace_copy_if replace_copy_if]]
|
||||
[def __range_algorithms_replace_if__ [link range.reference.algorithms.mutating.replace_if replace_if]]
|
||||
[def __range_algorithms_reverse__ [link range.reference.algorithms.mutating.reverse reverse]]
|
||||
[def __range_algorithms_reverse_copy__ [link range.reference.algorithms.mutating.reverse_copy reverse_copy]]
|
||||
[def __range_algorithms_rotate__ [link range.reference.algorithms.mutating.rotate rotate]]
|
||||
[def __range_algorithms_rotate_copy__ [link range.reference.algorithms.mutating.rotate_copy rotate_copy]]
|
||||
[def __range_algorithms_sort__ [link range.reference.algorithms.mutating.sort sort]]
|
||||
[def __range_algorithms_stable_partition__ [link range.reference.algorithms.mutating.stable_partition stable_partition]]
|
||||
[def __range_algorithms_stable_sort__ [link range.reference.algorithms.mutating.stable_sort stable_sort]]
|
||||
[def __range_algorithms_swap_ranges__ [link range.reference.algorithms.mutating.swap_ranges swap_ranges]]
|
||||
[def __range_algorithms_transform__ [link range.reference.algorithms.mutating.transform transform]]
|
||||
[def __range_algorithms_unique__ [link range.reference.algorithms.mutating.unique unique]]
|
||||
[def __range_algorithms_unique_copy__ [link range.reference.algorithms.mutating.unique_copy unique_copy]]
|
||||
|
||||
[def __range_algorithms_includes__ [link range.reference.algorithms.set.includes includes]]
|
||||
[def __range_algorithms_set_union__ [link range.reference.algorithms.set.set_union set_union]]
|
||||
[def __range_algorithms_set_intersection__ [link range.reference.algorithms.set.set_intersection set_intersection]]
|
||||
[def __range_algorithms_set_difference__ [link range.reference.algorithms.set.set_difference set_difference]]
|
||||
[def __range_algorithms_set_symmetric_difference__ [link range.reference.algorithms.set.set_symmetric_difference set_symmetric_difference]]
|
||||
|
||||
[def __range_algorithms_push_heap__ [link range.reference.algorithms.heap.push_heap push_heap]]
|
||||
[def __range_algorithms_pop_heap__ [link range.reference.algorithms.heap.pop_heap pop_heap]]
|
||||
[def __range_algorithms_make_heap__ [link range.reference.algorithms.heap.make_heap make_heap]]
|
||||
[def __range_algorithms_sort_heap__ [link range.reference.algorithms.heap.sort_heap sort_heap]]
|
||||
|
||||
[def __range_algorithms_next_permutation__ [link range.reference.algorithms.permutation.next_permutation next_permutation]]
|
||||
[def __range_algorithms_prev_permutation__ [link range.reference.algorithms.permutation.prev_permutation prev_permutation]]
|
||||
|
||||
[def __range_algorithm_ext_copy_n__ [link range.reference.algorithms.new.copy_n copy_n]]
|
||||
[def __range_algorithm_ext_erase__ [link range.reference.algorithms.new.erase erase]]
|
||||
[def __range_algorithm_ext_for_each__ [link range.reference.algorithms.new.for_each for_each]]
|
||||
[def __range_algorithm_ext_insert__ [link range.reference.algorithms.new.insert insert]]
|
||||
[def __range_algorithm_ext_iota__ [link range.reference.algorithms.new.iota iota]]
|
||||
[def __range_algorithm_ext_is_sorted__ [link range.reference.algorithms.new.is_sorted is_sorted]]
|
||||
[def __range_algorithm_ext_overwrite__ [link range.reference.algorithms.new.overwrite overwrite]]
|
||||
[def __range_algorithm_ext_push_back__ [link range.reference.algorithms.new.push_back push_back]]
|
||||
[def __range_algorithm_ext_push_front__ [link range.reference.algorithms.new.push_front push_front]]
|
||||
|
||||
[def __single_pass_iterator__ [@boost:/libs/iterator/doc/new-iter-concepts.html#singls-pass-iterators-lib-single-pass-iterators Single Pass Iterator]]
|
||||
[def __forward_traversal_iterator__ [@boost:/libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators Forward Traversal Iterator]]
|
||||
[def __bidirectional_traversal_iterator__ [@boost:/libs/iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators Bidirectional Traversal Iterator]]
|
||||
[def __random_access_traversal_iterator__ [@boost:/libs/iterator/doc/new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators Random Access Traversal Iterator]]
|
||||
[def __new_style_iterators__ [@boost:/libs/iterator/doc/new-iter-concepts.html new style iterators]]
|
||||
[def __iterator_concepts__ [@boost:/libs/iterator/doc/iterator_concepts.html Iterator concepts]]
|
||||
|
||||
[def __container__ [@http://www.sgi.com/Technology/STL/Container.html Container]]
|
||||
[def __metafunctions__ [@boost:/libs/mpl/doc/refmanual/metafunction.html metafunctions]]
|
||||
[def __concept_check__ [@boost:/libs/concept_check/index.html Boost Concept Check library]]
|
||||
[def __boost_array__ [@boost:/libs/array/index.html boost::array]]
|
||||
[def __the_forwarding_problem__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]]
|
||||
|
||||
[def __sgi_inner_product__ [@http://www.sgi.com/tech/stl/inner_product.html inner_product]]
|
||||
[def __sgi_partial_sum__ [@http://www.sgi.com/tech/stl/partial_sum.html partial_sum]]
|
||||
[def __type_erasure_article__ [@http://www.artima.com/cppsource/type_erasure.html type erasure article]]
|
||||
|
||||
Boost.Range is a collection of concepts and utilities, range-based algorithms,
|
||||
as well as range adaptors that allow for efficient and expressive code.
|
||||
|
||||
Using Boost.Range inplace of the standard library alternatives results in more
|
||||
readable code and in many cases greater efficiency.
|
||||
|
||||
[include introduction.qbk]
|
||||
[include concepts.qbk]
|
||||
[include reference.qbk]
|
||||
[include style.qbk]
|
||||
[include headers.qbk]
|
||||
[include examples.qbk]
|
||||
[include mfc_atl.qbk]
|
||||
[include upgrade.qbk]
|
||||
[include portability.qbk]
|
||||
[include faq.qbk]
|
||||
[include history_ack.qbk]
|
||||
|
255
doc/concepts.qbk
Normal file
255
doc/concepts.qbk
Normal file
@ -0,0 +1,255 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:concepts Range Concepts]
|
||||
|
||||
[section Overview]
|
||||
|
||||
A Range is a [*/concept/] similar to the STL [@http://www.sgi.com/tech/stl/Container.html Container] concept. A Range provides iterators for accessing a half-open range `[first,one_past_last)` of elements and provides information about the number of elements in the Range. However, a Range has fewer requirements than a Container.
|
||||
|
||||
The motivation for the Range concept is that there are many useful Container-like types that do not meet the full requirements of Container, and many algorithms that can be written with this reduced set of requirements. In particular, a Range does not necessarily
|
||||
|
||||
* own the elements that can be accessed through it,
|
||||
* have copy semantics,
|
||||
|
||||
Because of the second requirement, a Range object must be passed by (const or non-const) reference in generic code.
|
||||
|
||||
The operations that can be performed on a Range is dependent on the [@boost:/libs/iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal traversal category] of the underlying iterator type. Therefore the range concepts are named to reflect which traversal category its iterators support. See also terminology and style guidelines. for more information about naming of ranges.
|
||||
|
||||
The concepts described below specifies associated types as [@boost:/libs/mpl/doc/refmanual/metafunction.html metafunctions] and all functions as free-standing functions to allow for a layer of indirection.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section Single Pass Range]
|
||||
|
||||
[heading Notation]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[`X`] [A type that is a model of __single_pass_range__.]]
|
||||
[[`a`] [Object of type X.]]
|
||||
]
|
||||
|
||||
[heading Description]
|
||||
|
||||
A range `X` where `boost::range_iterator<X>::type` is a model of __single_pass_iterator__.
|
||||
|
||||
[heading Associated types]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[Iterator type ] [`boost::range_iterator<X>::type` ] [The type of iterator used to iterate through a Range's elements. The iterator's value type is expected to be the Range's value type. A conversion from the iterator type to the `const` iterator type must exist.]]
|
||||
[[Const iterator type] [`boost::range_iterator<const X>::type`] [A type of iterator that may be used to examine, but not to modify, a Range's elements.]]
|
||||
]
|
||||
|
||||
[heading Valid expressions]
|
||||
|
||||
The following expressions must be valid.
|
||||
|
||||
[table
|
||||
[[Name ] [Expression ] [Return type ]]
|
||||
[[Beginning of range] [`boost::begin(a)`] [`boost::range_iterator<X>::type` if `a` is mutable, `boost::range_iterator<const X>::type` otherwise]]
|
||||
[[End of range ] [`boost::end(a)` ] [`boost::range_iterator<X>::type` if `a` is mutable, `boost::range_iterator<const X>::type` otherwise]]
|
||||
]
|
||||
|
||||
[heading Expression semantics]
|
||||
|
||||
[table
|
||||
[[Expression ] [Semantics ] [Postcondition]]
|
||||
[[`boost::begin(a)`] [Returns an iterator pointing to the first element in the Range. ] [`boost::begin(a)` is either dereferenceable or past-the-end. It is past-the-end if and only if `boost::distance(a) == 0`.]]
|
||||
[[`boost::end(a)` ] [Returns an iterator pointing one past the last element in the Range. ] [`boost::end(a)` is past-the-end.]]
|
||||
]
|
||||
|
||||
[heading Complexity guarantees]
|
||||
|
||||
`boost::end(a)` is at most amortized linear time, `boost::begin(a)` is amortized constant time. For most practical purposes, one can expect both to be amortized constant time.
|
||||
|
||||
[heading Invariants]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[Valid range ] [For any Range `a`, `[boost::begin(a),boost::end(a))` is a valid range, that is, `boost::end(a)` is reachable from `boost::begin(a)` in a finite number of increments.]]
|
||||
|
||||
[[Completeness] [An algorithm that iterates through the range `[boost::begin(a),boost::end(a))` will pass through every element of `a`.]]
|
||||
]
|
||||
|
||||
[heading See also]
|
||||
|
||||
__extending_for_udts__
|
||||
|
||||
__implementation_of_metafunctions__
|
||||
|
||||
__implementation_of_functions__
|
||||
|
||||
__container__
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section Forward Range]
|
||||
|
||||
[heading Notation]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[`X`] [A type that is a model of __forward_range__.]]
|
||||
[[`a`] [Object of type X.]]
|
||||
]
|
||||
|
||||
[heading Description]
|
||||
|
||||
A range `X` where `boost::range_iterator<X>::type` is a model of __forward_traversal_iterator__.
|
||||
|
||||
[heading Refinement of]
|
||||
|
||||
__single_pass_range__
|
||||
|
||||
[heading Associated types]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[Distance type] [`boost::range_difference<X>::type`] [A signed integral type used to represent the distance between two of the Range's iterators. This type must be the same as the iterator's distance type.]]
|
||||
[[Size type ] [`boost::range_size<X>::type` ] [An unsigned integral type that can represent any nonnegative value of the Range's distance type.]]
|
||||
]
|
||||
|
||||
[heading See also]
|
||||
|
||||
__implementation_of_metafunctions__
|
||||
|
||||
__implementation_of_functions__
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section Bidirectional Range]
|
||||
|
||||
[heading Notation]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[`X`] [A type that is a model of __bidirectional_range__.]]
|
||||
[[`a`] [Object of type X.]]
|
||||
]
|
||||
|
||||
[heading Description]
|
||||
|
||||
This concept provides access to iterators that traverse in both directions (forward and reverse). The `boost::range_iterator<X>::type` iterator must meet all of the requirements of __bidirectional_traversal_iterator__.
|
||||
|
||||
[heading Refinement of]
|
||||
|
||||
__forward_range__
|
||||
|
||||
[heading Associated types]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[Reverse Iterator type ] [`boost::range_reverse_iterator<X>::type` ] [The type of iterator used to iterate through a Range's elements in reverse order. The iterator's value type is expected to be the Range's value type. A conversion from the reverse iterator type to the const reverse iterator type must exist.]]
|
||||
|
||||
[[Const reverse iterator type] [`boost::range_reverse_iterator<const X>::type`] [A type of reverse iterator that may be used to examine, but not to modify, a Range's elements.]]
|
||||
]
|
||||
|
||||
[heading Valid expressions]
|
||||
|
||||
[table
|
||||
[[Name ] [Expression ] [Return type] [Semantics]]
|
||||
[[Beginning of range] [`boost::rbegin(a)`] [`boost::range_reverse_iterator<X>::type` if `a` is mutable `boost::range_reverse_iterator<const X>::type` otherwise.] [Equivalent to `boost::range_reverse_iterator<X>::type(boost::end(a))`.]]
|
||||
|
||||
[[End of range ] [`boost::rend(a)` ] [`boost::range_reverse_iterator<X>::type` if `a` is mutable, `boost::range_reverse_iterator<const X>::type` otherwise.] [Equivalent to `boost::range_reverse_iterator<X>::type(boost::begin(a))`.]]
|
||||
]
|
||||
|
||||
[heading Complexity guarantees]
|
||||
|
||||
`boost::rbegin(a)` has the same complexity as `boost::end(a)` and `boost::rend(a)` has the same complexity as `boost::begin(a)` from __forward_range__.
|
||||
|
||||
[heading Invariants]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[Valid reverse range] [For any Bidirectional Range a, `[boost::rbegin(a),boost::rend(a))` is a valid range, that is, `boost::rend(a)` is reachable from `boost::rbegin(a)` in a finite number of increments.]]
|
||||
|
||||
[[Completeness ] [An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.]]
|
||||
]
|
||||
|
||||
[heading See also]
|
||||
|
||||
__implementation_of_metafunctions__
|
||||
|
||||
__implementation_of_functions__
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section Random Access Range]
|
||||
|
||||
[heading Description]
|
||||
|
||||
A range `X` where `boost::range_iterator<X>::type` is a model of __random_access_traversal_iterator__.
|
||||
|
||||
[heading Refinement of]
|
||||
|
||||
__bidirectional_range__
|
||||
|
||||
[heading Valid expressions]
|
||||
|
||||
[table
|
||||
[[Name ] [Expression ] [Return type ]]
|
||||
[[Size of range] [`boost::size(a)`] [`boost::range_size<X>::type`]]
|
||||
]
|
||||
|
||||
[heading Expression semantics]
|
||||
|
||||
[table
|
||||
[[Expression ] [Semantics] [Postcondition]]
|
||||
[[`boost::size(a)`] [Returns the size of the Range, that is, its number of elements. Note `boost::size(a) == 0u` is equivalent to `boost::empty(a)`.] [`boost::size(a) >= 0`]]
|
||||
]
|
||||
|
||||
[heading Complexity guarantees]
|
||||
|
||||
`boost::size(a)` completes in amortized constant time.
|
||||
|
||||
[heading Invariants]
|
||||
|
||||
[table
|
||||
[]
|
||||
[[Range size] [`boost::size(a)` is equal to the `boost::end(a)` - `boost::begin(a)`.]]
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section Concept Checking]
|
||||
|
||||
Each of the range concepts has a corresponding concept checking class in the file [@boost:/boost/range/concepts.hpp `<boost/range/concepts.hpp>`]. These classes may be used in conjunction with the __concept_check__ to ensure that the type of a template parameter is compatible with a range concept. If not, a meaningful compile time error is generated. Checks are provided for the range concepts related to iterator traversal categories. For example, the following line checks that the type `T` models the __forward_range__ concept.
|
||||
|
||||
``
|
||||
BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<T> ));
|
||||
``
|
||||
|
||||
An additional concept check is required for the value access property of the range based on the range's iterator type. For example to check for a ForwardReadableRange, the following code is required.
|
||||
|
||||
``
|
||||
BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<T> ));
|
||||
BOOST_CONCEPT_ASSERT(( ReadableIteratorConcept<typename range_iterator<T>::type> ));
|
||||
``
|
||||
|
||||
The following range concept checking classes are provided.
|
||||
|
||||
* Class SinglePassRangeConcept checks for __single_pass_range__
|
||||
* Class ForwardRangeConcept checks for __forward_range__
|
||||
* Class BidirectionalRangeConcept checks for __bidirectional_range__
|
||||
* Class RandomAccessRangeConcept checks for __random_access_range__
|
||||
|
||||
[heading See also]
|
||||
|
||||
[link range.style_guide Range Terminology and style guidelines]
|
||||
|
||||
__iterator_concepts__
|
||||
|
||||
__concept_check__
|
||||
|
||||
[endsect]
|
||||
[endsect]
|
||||
|
151
doc/example.cpp
Normal file
151
doc/example.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2008. 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/range/
|
||||
//
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <iterator> // for std::iterator_traits, std::distance()
|
||||
|
||||
namespace Foo
|
||||
{
|
||||
//
|
||||
// Our sample UDT. A 'Pair'
|
||||
// will work as a range when the stored
|
||||
// elements are iterators.
|
||||
//
|
||||
template< class T >
|
||||
struct Pair
|
||||
{
|
||||
T first, last;
|
||||
};
|
||||
|
||||
} // namespace 'Foo'
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//
|
||||
// Specialize metafunctions. We must include the range.hpp header.
|
||||
// We must open the 'boost' namespace.
|
||||
//
|
||||
/*
|
||||
template< class T >
|
||||
struct range_value< Foo::Pair<T> >
|
||||
{
|
||||
typedef typename std::iterator_traits<T>::value_type type;
|
||||
};
|
||||
*/
|
||||
|
||||
template< class T >
|
||||
struct range_iterator< Foo::Pair<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct range_const_iterator< Foo::Pair<T> >
|
||||
{
|
||||
//
|
||||
// Remark: this is defined similar to 'range_iterator'
|
||||
// because the 'Pair' type does not distinguish
|
||||
// between an iterator and a const_iterator.
|
||||
//
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
/*
|
||||
template< class T >
|
||||
struct range_difference< Foo::Pair<T> >
|
||||
{
|
||||
typedef typename std::iterator_traits<T>::difference_type type;
|
||||
};
|
||||
*/
|
||||
|
||||
template< class T >
|
||||
struct range_size< Foo::Pair<T> >
|
||||
{
|
||||
int static_assertion[ sizeof( std::size_t ) >=
|
||||
sizeof( typename range_difference< Foo::Pair<T> >::type ) ];
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
namespace Foo
|
||||
{
|
||||
//
|
||||
// The required functions. These should be defined in
|
||||
// the same namespace as 'Pair', in this case
|
||||
// in namespace 'Foo'.
|
||||
//
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_begin( Pair<T>& x )
|
||||
{
|
||||
return x.first;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_begin( const Pair<T>& x )
|
||||
{
|
||||
return x.first;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_end( Pair<T>& x )
|
||||
{
|
||||
return x.last;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_end( const Pair<T>& x )
|
||||
{
|
||||
return x.last;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline typename boost::range_size< Pair<T> >::type
|
||||
boost_range_size( const Pair<T>& x )
|
||||
{
|
||||
return std::distance(x.first,x.last);
|
||||
}
|
||||
|
||||
} // namespace 'Foo'
|
||||
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::vector<int>::iterator iter;
|
||||
std::vector<int> vec;
|
||||
vec.push_back( 42 );
|
||||
Foo::Pair<iter> pair = { vec.begin(), vec.end() };
|
||||
const Foo::Pair<iter>& cpair = pair;
|
||||
//
|
||||
// Notice that we call 'begin' etc with qualification.
|
||||
//
|
||||
iter i = boost::begin( pair );
|
||||
iter e = boost::end( pair );
|
||||
i = boost::begin( cpair );
|
||||
e = boost::end( cpair );
|
||||
boost::range_size< Foo::Pair<iter> >::type s = boost::size( pair );
|
||||
s = boost::size( cpair );
|
||||
boost::range_const_reverse_iterator< Foo::Pair<iter> >::type
|
||||
ri = boost::rbegin( cpair ),
|
||||
re = boost::rend( cpair );
|
||||
|
||||
//
|
||||
// Test metafunctions
|
||||
//
|
||||
|
||||
boost::range_value< Foo::Pair<iter> >::type
|
||||
v = *boost::begin(pair);
|
||||
|
||||
boost::range_difference< Foo::Pair<iter> >::type
|
||||
d = boost::end(pair) - boost::begin(pair);
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Examples </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" ></td>
|
||||
<td ><h1 align="center">Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 >Examples</h2><a name="Examples" ></a>
|
||||
<p >
|
||||
Some examples are given in the accompanying test files:
|
||||
</p>
|
||||
<ul >
|
||||
<li >
|
||||
<a href="../test/string.cpp" target="_self" ><code >string.cpp</code></a>
|
||||
</li>
|
||||
shows how to implement a container version of <code >std::find()</code> that
|
||||
works with <code >char[],wchar_t[],char*,wchar_t*.</code>
|
||||
<li >
|
||||
<a href="../test/algorithm_example.cpp" target="_self" ><code >algorithm_example.cpp</code></a>
|
||||
|
||||
</li>
|
||||
shows the replace example from the introduction.
|
||||
|
||||
<li> <a href="../test/iterator_range.cpp">iterator_range.cpp</a>
|
||||
<li> <a href="../test/sub_range.cpp">sub_range.cpp</a>
|
||||
<li> <a href="../test/iterator_pair.cpp">iterator_pair.cpp</a>
|
||||
<li> <a href="../test/reversible_range.cpp">reversible_range.cpp</a>
|
||||
<li> <a href="../test/std_container.cpp">std_container.cpp</a>
|
||||
<li> <a href="../test/array.cpp">array.cpp</a>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
28
doc/examples.qbk
Normal file
28
doc/examples.qbk
Normal file
@ -0,0 +1,28 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
[section:examples Examples]
|
||||
|
||||
Some examples are given in the accompanying test files:
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/string.cpp string.cpp] shows how to implement a container version of `std::find()` that works with `char[]`,`wchar_t[]`,`char*`,`wchar_t*`.
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/algorithm_example.cpp algorithm_example.cpp] shows the replace example from the introduction.
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/iterator_range.cpp iterator_range.cpp]
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/sub_range.cpp sub_range.cpp]
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/iterator_pair.cpp iterator_pair.cpp]
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/reversible_range.cpp reversible_range.cpp]
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/std_container.cpp std_container.cpp]
|
||||
|
||||
* [@http://www.boost.org/libs/range/test/array.cpp array.cpp]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
138
doc/faq.html
138
doc/faq.html
@ -1,138 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range FAQ </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" ></td>
|
||||
<td ><h1 align="center">Boost.Range</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2 >FAQ</h2> <a name="FAQ" ></a>
|
||||
<ol >
|
||||
<li >
|
||||
<i>Why is there no difference between <code >range_iterator<C>::type</code>
|
||||
and <code >range_const_iterator<C>::type</code> for <code>std::pair<iterator, iterator></code></i>.
|
||||
</li>
|
||||
<p >
|
||||
In general it is not possible nor desirable to find a corresponding <code >const_iterator</code>.
|
||||
When it is possible to come up with one, the client might choose to construct a <code >std::pair<const_iterator,const_iterator></code>
|
||||
object.
|
||||
</p>
|
||||
<p>
|
||||
Note that an <a href="utility_class.html#iter_range">iterator_range</a>
|
||||
is somewhat more convenient than a <code>pair</code> and that a <a
|
||||
href="utility_class.html#sub_range"><code>sub_range</code></a> do
|
||||
propagate const-ness. </p>
|
||||
|
||||
<li >
|
||||
<i>Why is there not supplied more types or more functions?</i>
|
||||
<p >
|
||||
The library has been kept small because its current interface will
|
||||
serve most
|
||||
purposes. If and when a genuine need arises for more functionality, it can be
|
||||
implemented.
|
||||
</p>
|
||||
</li>
|
||||
<li >
|
||||
<i>How should I implement generic algorithms for ranges?</i>
|
||||
<p >
|
||||
One should always start with a generic algorithm that takes two iterators (or
|
||||
more) as input. Then use Boost.Range to build handier versions on top of the
|
||||
iterator based algorithm. Please notice that once the range version of the
|
||||
algorithm is done, it makes sense <i>not</i> to expose the iterator version in
|
||||
the public interface.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<i>Why is there no Incrementable Range concept?</i>
|
||||
<p>
|
||||
Even though we speak of incrementable iterators, it would not make
|
||||
much sense for ranges; for example, we cannot determine the size and
|
||||
emptiness of a range since we cannot even compare
|
||||
its iterators.
|
||||
</p>
|
||||
<p>
|
||||
Note also that incrementable iterators are derived from output
|
||||
iterators and so there exist no output range.
|
||||
</p>
|
||||
</li>
|
||||
<!--
|
||||
<li>
|
||||
<i>Should I use qualified syntax, for example
|
||||
<blockquote><pre>
|
||||
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>); </span>
|
||||
</pre></blockquote>
|
||||
instead of
|
||||
<blockquote>
|
||||
<pre><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>;</span>
|
||||
<span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>)</span></pre></blockquote>
|
||||
when calling functions in this library? If so, can I still rely on argument
|
||||
dependent lookup (ADL) to kick in?</i>
|
||||
<p>
|
||||
The answer to the first question is that "it's up to you". The
|
||||
answer to the second question is Yes. Normally qualified syntax
|
||||
disables ADL, but the functions are implemented in a special
|
||||
manner that preserves ADL properties. The trick was explained by
|
||||
Daniel Frey on comp.lang.std.c++ in the thread "Whence Swap" and
|
||||
it is best explained by some code: <blockquote>
|
||||
<pre>
|
||||
<span class=keyword>namespace </span><span class=identifier>boost</span>
|
||||
<span class=special>{
|
||||
</span><span class=keyword>namespace </span><span class=identifier>range_detail
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>:</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
||||
</span><span class=special>{ </span><span class=comment>/* normal implementation */ </span><span class=special>}
|
||||
</span><span class=special>}
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
||||
</span><span class=special>{
|
||||
</span><span class=comment>//
|
||||
// Create ADL hook
|
||||
//
|
||||
</span><span class=keyword>using </span><span class=identifier>range_detail</span><span class=special>::</span><span class=identifier>begin</span><span class=special>;
|
||||
</span><span class=keyword>return </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
|
||||
</span><span class=special>}</span>
|
||||
<span class=special>} </span>
|
||||
</pre>
|
||||
</blockquote>
|
||||
Cool indeed!
|
||||
</p>
|
||||
-->
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
30
doc/faq.qbk
Normal file
30
doc/faq.qbk
Normal file
@ -0,0 +1,30 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
[section:faq FAQ]
|
||||
|
||||
1. ['[*Why is there no difference between `range_iterator<C>::type` and `range_const_iterator<C>::type` for `std::pair<iterator, iterator>`?]]
|
||||
|
||||
[:In general it is not possible nor desirable to find a corresponding `const_iterator`. When it is possible to come up with one, the client might choose to construct a `std::pair<const_iterator,const_iterator>` object.]
|
||||
|
||||
[:Note that an __iterator_range__ is somewhat more convenient than a `pair` and that a __sub_range__ does propagate const-ness.]
|
||||
|
||||
2. ['[*Why is there not supplied more types or more functions?]]
|
||||
|
||||
[:The library has been kept small because its current interface will serve most purposes. If and when a genuine need arises for more functionality, it can be implemented.]
|
||||
|
||||
3. ['[*How should I implement generic algorithms for ranges?]]
|
||||
|
||||
[:One should always start with a generic algorithm that takes two iterators (or more) as input. Then use Boost.Range to build handier versions on top of the iterator based algorithm. Please notice that once the range version of the algorithm is done, it makes sense not to expose the iterator version in the public interface.]
|
||||
|
||||
4. ['[*Why is there no Incrementable Range concept?]]
|
||||
|
||||
[:Even though we speak of incrementable iterators, it would not make much sense for ranges; for example, we cannot determine the size and emptiness of a range since we cannot even compare its iterators.]
|
||||
|
||||
[:Note also that incrementable iterators are derived from output iterators and so there exist no output range.]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
171
doc/headers.html
171
doc/headers.html
@ -1,171 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Headers </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" ></td>
|
||||
<td ><h1 align="center">Boost.Range</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2 >Library headers</h2><a name="Library headers" ></a>
|
||||
<table cellpadding="5" border="1" >
|
||||
<tr >
|
||||
<th >Header</th>
|
||||
<th >Includes</th>
|
||||
<th>Related concept </th>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range.hpp></code></td>
|
||||
<td >everything</td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/metafunctions.hpp></code></td>
|
||||
<td >every metafunction</td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/functions.hpp></code></td>
|
||||
<td >every function</td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/value_type.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_value" >range_value</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_iterator"
|
||||
>range_iterator</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/const_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_const_iterator"
|
||||
>range_const_iterator</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/difference_type.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_difference"
|
||||
>range_difference</a></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/size_type.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_size" >range_size</a></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/result_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_result_iterator"
|
||||
>range_result_iterator</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/reverse_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_reverse_iterator" >range_reverse_iterator</a></td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/const_reverse_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_const_reverse_iterator" >range_const_reverse_iterator</a></td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/reverse_result_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_reverse_result_iterator">range_reverse_result_iterator</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/begin.hpp></code></td>
|
||||
<td >
|
||||
<a href="boost_range.html#begin" >begin</a> and
|
||||
<a href="boost_range.html#const_begin" >const_begin</a>
|
||||
</td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/end.hpp></code></td>
|
||||
<td >
|
||||
<a href="boost_range.html#end" >end</a> and
|
||||
<a href="boost_range.html#const_end" >const_end</a>
|
||||
</td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/empty.hpp></code></td>
|
||||
<td ><a href="boost_range.html#empty" >empty</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/size.hpp></code></td>
|
||||
<td ><a href="boost_range.html#size" >size</a></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/rbegin.hpp></code></td>
|
||||
<td >
|
||||
<a href="boost_range.html#rbegin" >rbegin</a> and
|
||||
<a href="boost_range.html#const_rbegin" >const_rbegin</a>
|
||||
</td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/rend.hpp></code></td>
|
||||
<td >
|
||||
<a href="boost_range.html#rend" >rend</a> and
|
||||
<a href="boost_range.html#const_rend" >const_rend</a>
|
||||
</td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/iterator_range.hpp></code></td>
|
||||
<td ><a href="utility_class.html#iter_range"
|
||||
>iterator_range</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/sub_range.hpp></code></td>
|
||||
<td ><a href="utility_class.html#sub_range" >sub_range</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<br
|
||||
</p>
|
||||
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
143
doc/headers.qbk
Normal file
143
doc/headers.qbk
Normal file
@ -0,0 +1,143 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:headers Library Headers]
|
||||
|
||||
[section:general General]
|
||||
[table
|
||||
[[Header ] [Includes ] [Related Concept ]]
|
||||
[[`<boost/range.hpp>` ] [everything from Boost.Range version 1 (Boost versions 1.42 and below). Includes the core range functions and metafunctions, but excludes Range Adaptors and Range Algorithms. ] [- ]]
|
||||
[[`<boost/range/metafunctions.hpp>` ] [every metafunction ] [- ]]
|
||||
[[`<boost/range/functions.hpp>` ] [every function ] [- ]]
|
||||
[[`<boost/range/value_type.hpp>` ] [__range_value__ ] [__single_pass_range__ ]]
|
||||
[[`<boost/range/iterator.hpp>` ] [__range_iterator__ ] [__single_pass_range__ ]]
|
||||
[[`<boost/range/difference_type.hpp>` ] [__range_difference__ ] [__forward_range__ ]]
|
||||
[[`<boost/range/pointer.hpp>` ] [__range_pointer__ ] [-]]
|
||||
[[`<boost/range/category.hpp>` ] [__range_category__ ] [-]]
|
||||
[[`<boost/range/reverse_iterator.hpp>`] [__range_reverse_iterator__ ] [__bidirectional_range__ ]]
|
||||
[[`<boost/range/begin.hpp>` ] [__begin__ and __const_begin__ ] [__single_pass_range__ ]]
|
||||
[[`<boost/range/end.hpp>` ] [__end__ and __const_end__ ] [__single_pass_range__ ]]
|
||||
[[`<boost/range/empty.hpp>` ] [__empty__ ] [__single_pass_range__ ]]
|
||||
[[`<boost/range/distance.hpp>` ] [__distance__ ] [__forward_range__ ]]
|
||||
[[`<boost/range/size.hpp>` ] [__size__ ] [__random_access_range__ ]]
|
||||
[[`<boost/range/rbegin.hpp>` ] [__rbegin__ and __const_rbegin__] [__bidirectional_range__ ]]
|
||||
[[`<boost/range/rend.hpp>` ] [__rend__ and __const_rend__ ] [__bidirectional_range__ ]]
|
||||
[[`<boost/range/as_array.hpp>` ] [__as_array__ ] [- ]]
|
||||
[[`<boost/range/as_literal.hpp>` ] [__as_literal__ ] [- ]]
|
||||
[[`<boost/range/iterator_range.hpp>` ] [__iterator_range__ ] [- ]]
|
||||
[[`<boost/range/sub_range.hpp>` ] [__sub_range__ ] [- ]]
|
||||
[[`<boost/range/concepts.hpp>` ] [__range_concepts__ ] [- ]]
|
||||
[[`<boost/range/adaptors.hpp>` ] [every range adaptor ] [- ]]
|
||||
[[`<boost/range/algorithm.hpp>` ] [every range equivalent of an STL algorithm ] [- ]]
|
||||
[[`<boost/range/algorithm_ext.hpp>` ] [every range algorithm that is an extension of the STL algorithms ] [- ]]
|
||||
[[`<boost/range/counting_range.hpp>` ] [ __counting_range__ ] [-]]
|
||||
[[`<boost/range/istream_range.hpp>` ] [ __istream_range__ ] [-]]
|
||||
[[`<boost/range/irange.hpp>` ] [ __irange__ ] [-]]
|
||||
[[`<boost/range/join.hpp>` ] [ __join__ ] [-]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section:adaptors Adaptors]
|
||||
[table
|
||||
[[Header ][Includes ]]
|
||||
[[`<boost/range/adaptor/adjacent_filtered.hpp>`] [__range_adaptors_adjacent_filtered__ ]]
|
||||
[[`<boost/range/adaptor/copied.hpp>`] [__range_adaptors_copied__]]
|
||||
[[`<boost/range/adaptor/filtered.hpp>`] [__range_adaptors_filtered__]]
|
||||
[[`<boost/range/adaptor/indexed.hpp>`] [__range_adaptors_indexed__]]
|
||||
[[`<boost/range/adaptor/indirected.hpp>`] [__range_adaptors_indirected__]]
|
||||
[[`<boost/range/adaptor/map.hpp>`] [__range_adaptors_map_keys__ __range_adaptors_map_values__]]
|
||||
[[`<boost/range/adaptor/replaced.hpp>`] [__range_adaptors_replaced__]]
|
||||
[[`<boost/range/adaptor/replaced_if.hpp>`] [__range_adaptors_replaced_if__]]
|
||||
[[`<boost/range/adaptor/reversed.hpp>`] [__range_adaptors_reversed__]]
|
||||
[[`<boost/range/adaptor/sliced.hpp>`] [__range_adaptors_sliced__]]
|
||||
[[`<boost/range/adaptor/strided.hpp>`] [__range_adaptors_strided__]]
|
||||
[[`<boost/range/adaptor/tokenized.hpp>`] [__range_adaptors_tokenized__]]
|
||||
[[`<boost/range/adaptor/transformed.hpp>`] [__range_adaptors_transformed__]]
|
||||
[[`<boost/range/adaptor/uniqued.hpp>`] [__range_adaptors_uniqued__]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section:algorithm Algorithm]
|
||||
[table
|
||||
[[Header ][Includes ]]
|
||||
[[`<boost/range/algorithm/adjacent_find.hpp>`] [__range_algorithms_adjacent_find__]]
|
||||
[[`<boost/range/algorithm/binary_search.hpp>`] [__range_algorithms_binary_search__]]
|
||||
[[`<boost/range/algorithm/copy.hpp>`] [__range_algorithms_copy__]]
|
||||
[[`<boost/range/algorithm/copy_backward.hpp>`] [__range_algorithms_copy_backward__]]
|
||||
[[`<boost/range/algorithm/count.hpp>`] [__range_algorithms_count__]]
|
||||
[[`<boost/range/algorithm/count_if.hpp>`] [__range_algorithms_count_if__]]
|
||||
[[`<boost/range/algorithm/equal.hpp>`] [__range_algorithms_equal__]]
|
||||
[[`<boost/range/algorithm/equal_range.hpp>`] [__range_algorithms_equal_range__]]
|
||||
[[`<boost/range/algorithm/fill.hpp>`] [__range_algorithms_fill__]]
|
||||
[[`<boost/range/algorithm/fill_n.hpp>`] [__range_algorithms_fill_n__]]
|
||||
[[`<boost/range/algorithm/find.hpp>`] [__range_algorithms_find__]]
|
||||
[[`<boost/range/algorithm/find_end.hpp>`] [__range_algorithms_find_end__]]
|
||||
[[`<boost/range/algorithm/find_first_of.hpp>`] [__range_algorithms_find_first_of__]]
|
||||
[[`<boost/range/algorithm/find_if.hpp>`] [__range_algorithms_find_if__]]
|
||||
[[`<boost/range/algorithm/for_each.hpp>`] [__range_algorithms_for_each__]]
|
||||
[[`<boost/range/algorithm/generate.hpp>`] [__range_algorithms_generate__]]
|
||||
[[`<boost/range/algorithm/heap_algorithm.hpp>`] [__range_algorithms_push_heap__
|
||||
__range_algorithms_pop_heap__
|
||||
__range_algorithms_make_heap__
|
||||
__range_algorithms_sort_heap__]]
|
||||
[[`<boost/range/algorithm/inplace_merge.hpp>`] [__range_algorithms_inplace_merge__]]
|
||||
[[`<boost/range/algorithm/lexicographical_compare.hpp>`] [__range_algorithms_lexicographical_compare__]]
|
||||
[[`<boost/range/algorithm/lower_bound.hpp>`] [__range_algorithms_lower_bound__]]
|
||||
[[`<boost/range/algorithm/max_element.hpp>`] [__range_algorithms_max_element__]]
|
||||
[[`<boost/range/algorithm/merge.hpp>`] [__range_algorithms_merge__]]
|
||||
[[`<boost/range/algorithm/min_element.hpp>`] [__range_algorithms_min_element__]]
|
||||
[[`<boost/range/algorithm/mismatch.hpp>`] [__range_algorithms_mismatch__]]
|
||||
[[`<boost/range/algorithm/nth_element.hpp>`] [__range_algorithms_nth_element__]]
|
||||
[[`<boost/range/algorithm/partial_sort.hpp>`] [__range_algorithms_partial_sort__]]
|
||||
[[`<boost/range/algorithm/partition.hpp>`] [__range_algorithms_partition__]]
|
||||
[[`<boost/range/algorithm/permutation.hpp>`] [__range_algorithms_next_permutation__
|
||||
__range_algorithms_prev_permutation__]]
|
||||
[[`<boost/range/algorithm/random_shuffle.hpp>`] [__range_algorithms_random_shuffle__]]
|
||||
[[`<boost/range/algorithm/remove.hpp>`] [__range_algorithms_remove__]]
|
||||
[[`<boost/range/algorithm/remove_copy.hpp>`] [__range_algorithms_remove_copy__]]
|
||||
[[`<boost/range/algorithm/remove_copy_if.hpp>`] [__range_algorithms_remove_copy_if__]]
|
||||
[[`<boost/range/algorithm/remove_if.hpp>`] [__range_algorithms_remove_if__]]
|
||||
[[`<boost/range/algorithm/replace.hpp>`] [__range_algorithms_replace__]]
|
||||
[[`<boost/range/algorithm/replace_copy.hpp>`] [__range_algorithms_replace_copy__]]
|
||||
[[`<boost/range/algorithm/replace_copy_if.hpp>`] [__range_algorithms_replace_copy_if__]]
|
||||
[[`<boost/range/algorithm/replace_if.hpp>`] [__range_algorithms_replace_if__]]
|
||||
[[`<boost/range/algorithm/reverse.hpp>`] [__range_algorithms_reverse__]]
|
||||
[[`<boost/range/algorithm/reverse_copy.hpp>`] [__range_algorithms_reverse_copy__]]
|
||||
[[`<boost/range/algorithm/rotate.hpp>`] [__range_algorithms_rotate__]]
|
||||
[[`<boost/range/algorithm/rotate_copy.hpp>`] [__range_algorithms_rotate_copy__]]
|
||||
[[`<boost/range/algorithm/search.hpp>`] [__range_algorithms_search__]]
|
||||
[[`<boost/range/algorithm/search_n.hpp>`] [__range_algorithms_search_n__]]
|
||||
[[`<boost/range/algorithm/set_algorithm.hpp>`] [__range_algorithms_includes__
|
||||
__range_algorithms_set_union__
|
||||
__range_algorithms_set_intersection__
|
||||
__range_algorithms_set_difference__
|
||||
__range_algorithms_set_symmetric_difference__]]
|
||||
[[`<boost/range/algorithm/sort.hpp>`] [__range_algorithms_sort__]]
|
||||
[[`<boost/range/algorithm/stable_partition.hpp>`] [__range_algorithms_stable_partition__]]
|
||||
[[`<boost/range/algorithm/swap_ranges.hpp>`] [__range_algorithms_swap_ranges__]]
|
||||
[[`<boost/range/algorithm/transform.hpp>`] [__range_algorithms_transform__]]
|
||||
[[`<boost/range/algorithm/unique.hpp>`] [__range_algorithms_unique__]]
|
||||
[[`<boost/range/algorithm/unique_copy.hpp>`] [__range_algorithms_unique_copy__]]
|
||||
[[`<boost/range/algorithm/upper_bound.hpp>`] [__range_algorithms_upper_bound__]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section:algorithm_ext Algorithm Extensions]
|
||||
[table
|
||||
[[Header ][Includes ]]
|
||||
[[`<boost/range/algorithm_ext/copy_n.hpp>`] [__range_algorithm_ext_copy_n__]]
|
||||
[[`<boost/range/algorithm_ext/erase.hpp>`] [__range_algorithm_ext_erase__]]
|
||||
[[`<boost/range/algorithm_ext/for_each.hpp>`] [__range_algorithm_ext_for_each__]]
|
||||
[[`<boost/range/algorithm_ext/insert.hpp>`] [__range_algorithm_ext_insert__]]
|
||||
[[`<boost/range/algorithm_ext/iota.hpp>`] [__range_algorithm_ext_iota__]]
|
||||
[[`<boost/range/algorithm_ext/is_sorted.hpp>`] [__range_algorithm_ext_is_sorted__]]
|
||||
[[`<boost/range/algorithm_ext/overwrite.hpp>`] [__range_algorithm_ext_overwrite__]]
|
||||
[[`<boost/range/algorithm_ext/push_back.hpp>`] [__range_algorithm_ext_push_back__]]
|
||||
[[`<boost/range/algorithm_ext/push_front.hpp>`] [__range_algorithm_ext_push_front__]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
@ -1,80 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range History and Acknowledgement </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td><img src="../../../boost.png" border="0" ></td>
|
||||
<td><h1 align="center">Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 >History and Acknowledgement</h2><a name="History" ></a>
|
||||
<p >
|
||||
The library have been under way for a long time. Dietmar K<>hl originally
|
||||
intended to submit an <code >array_traits</code> class template which
|
||||
had most of the functionality present now, but only for arrays and standard
|
||||
containers.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Meanwhile work on algorithms for containers in various contexts showed the
|
||||
need for handling pairs of iterators, and string libraries needed special
|
||||
treatment of character arrays. In the end it made sense to formalize the
|
||||
minimal requirements of these similar concepts. And the results are the
|
||||
Range concepts found in this library. </p>
|
||||
|
||||
<p>
|
||||
The term Range was adopted because of paragraph <code>24.1/7</code> from the
|
||||
C++ standard: <blockquote>
|
||||
Most of the library's algorithmic templates that operate on data
|
||||
structures have interfaces that use ranges. A <i>range</i> is a pair of
|
||||
iterators that designate the beginning and end of the computation. A
|
||||
range [i, i) is an empty range; in general, a range [i, j) refers to
|
||||
the elements in the data structure starting with the one pointed to
|
||||
by i and up to but not including the one pointed to by j. Range [i,
|
||||
j) is valid if and only if j is reachable from i. The result of the
|
||||
application of functions in the library to invalid ranges is
|
||||
undefined.
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
Special thanks goes to
|
||||
<ul>
|
||||
<li> Pavol Droba for help with documentation and implementation
|
||||
<li> Pavel Vozenilek for help with porting the library
|
||||
<li> Jonathan Turkanis and John Torjo for help with documentation
|
||||
<li> Hartmut Kaiser for being review manager
|
||||
<li> Jonathan Turkanis for porting the lib (as far sa possible) to
|
||||
vc6 and vc7.
|
||||
</ul>
|
||||
</p>
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2005
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
58
doc/history_ack.qbk
Normal file
58
doc/history_ack.qbk
Normal file
@ -0,0 +1,58 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:history_ack History and Acknowledgement]
|
||||
|
||||
[heading Version 1 - before Boost 1.43]
|
||||
The library have been under way for a long time. Dietmar Kühl originally intended to submit an `array_traits` class template which had most of the functionality present now, but only for arrays and standard containers.
|
||||
|
||||
Meanwhile work on algorithms for containers in various contexts showed the need for handling pairs of iterators, and string libraries needed special treatment of character arrays. In the end it made sense to formalize the minimal requirements of these similar concepts. And the results are the Range concepts found in this library.
|
||||
|
||||
The term Range was adopted because of paragraph 24.1/7 from the C++ standard:
|
||||
|
||||
Most of the library's algorithmic templates that operate on data structures have interfaces that use ranges. A range is a pair of iterators that designate the beginning and end of the computation. A range [i, i) is an empty range; in general, a range [i, j) refers to the elements in the data structure starting with the one pointed to by i and up to but not including the one pointed to by j. Range [i, j) is valid if and only if j is reachable from i. The result of the application of functions in the library to invalid ranges is undefined.
|
||||
|
||||
Special thanks goes to
|
||||
|
||||
* Pavol Droba for help with documentation and implementation
|
||||
* Pavel Vozenilek for help with porting the library
|
||||
* Jonathan Turkanis and John Torjo for help with documentation
|
||||
* Hartmut Kaiser for being review manager
|
||||
* Jonathan Turkanis for porting the lib (as far as possible) to vc6 and vc7.
|
||||
|
||||
The concept checks and their documentation was provided by Daniel Walker.
|
||||
|
||||
[heading Version 2 - Boost 1.43 and beyond]
|
||||
This version introduced Range Adaptors and Range Algorithms. This version 2 is
|
||||
the result of a merge of all of the RangeEx features into Boost.Range.
|
||||
|
||||
There were an enormous number of very significant contributors through all
|
||||
stages of this library.
|
||||
|
||||
Prior to Boost.RangeEx there had been a number of Range library implementations,
|
||||
these include library implementations by Eric Niebler, Adobe,
|
||||
Shunsuke Sogame etc. Eric Niebler contributed the Range Adaptor idea which is
|
||||
arguably the single biggest innovation in this library. Inevitably a great deal
|
||||
of commonality evolved in each of these libraries, but a considerable amount
|
||||
of effort was expended to learn from all of the divergent techniques.
|
||||
|
||||
The people in the following list all made contributions in the form of reviews,
|
||||
user feedback, design suggestions, or defect detection:
|
||||
|
||||
* Thorsten Ottosen: review management, design advice, documentation feedback
|
||||
* Eric Niebler: early implementation, and review feedback
|
||||
* Joel de Guzman: review
|
||||
* Mathias Gaunard: review
|
||||
* David Abrahams: implementation advice
|
||||
* Robert Jones: defect reports, usage feedback
|
||||
* Sean Parent: contributed experience from the Adobe range library
|
||||
* Arno Schoedl: implementations, and review
|
||||
* Rogier van Dalen: review
|
||||
* Vincente Botet: review, documentation feedback
|
||||
|
||||
Regardless of how I write this section it will never truly fairly capture the
|
||||
gratitude that I feel to all who have contributed. Thank you everyone.
|
||||
|
||||
[endsect]
|
164
doc/intro.html
164
doc/intro.html
@ -1,164 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Introduction </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" ></td>
|
||||
<td ><h1 align="center">Boost.Range</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
<p>
|
||||
Generic algorithms have so far been specified in terms of two or more
|
||||
iterators. Two iterators would together form a range of values that the
|
||||
algorithm could work on. This leads to a very general interface, but also
|
||||
to a somewhat clumsy use of the algorithms with redundant specification
|
||||
of container names. Therefore we would like to raise the abstraction level
|
||||
for algorithms so they specify their interface in terms of <a
|
||||
href=range.html>Ranges</a> as much as possible.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The most common form of ranges we are used to work with is standard library
|
||||
containers. However, one
|
||||
often finds it desirable to extend that code to work with other types that
|
||||
offer
|
||||
enough functionality to satisfy the needs of the generic code
|
||||
<i>if a suitable layer of indirection is applied </i>. For
|
||||
example, raw arrays are often suitable for use with generic code that
|
||||
works with containers, provided a suitable adapter is used. Likewise, null
|
||||
terminated strings can be treated as containers of characters, if suitably
|
||||
adapted.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This library therefore provides the means to adapt standard-like
|
||||
containers,
|
||||
null terminated strings, <code>std::pairs</code> of iterators, and raw
|
||||
arrays (and more), such that the same generic code can work with them all.
|
||||
The basic idea is to add another layer of indirection using <a
|
||||
href="../../mpl/doc/index.html#metafunctions">metafunctions</a> and
|
||||
free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
</p>
|
||||
|
||||
<p >
|
||||
The main advantages are
|
||||
<ul >
|
||||
<li >
|
||||
simpler implementation and specification of generic range algorithms
|
||||
</li>
|
||||
<li >
|
||||
more flexible, compact and maintainable client code
|
||||
</li>
|
||||
<li >
|
||||
correct handling of null-terminated strings
|
||||
</li>
|
||||
<li >
|
||||
safe use of built-in arrays (for legacy code; why else would you use
|
||||
built-in arrays?) </li>
|
||||
|
||||
</ul>
|
||||
</p>
|
||||
<p >
|
||||
Below are given a small example (the complete example can be found <a href="../test/algorithm_example.cpp" target="_self" >here</a>
|
||||
):
|
||||
<blockquote>
|
||||
<pre >
|
||||
<span class=comment>
|
||||
//
|
||||
// example: extracting bounds in a generic algorithm
|
||||
//
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardReadableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_iterator</span><span class=special>< </span><span class=identifier>ForwardReadableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>ForwardReadableRange</span><span class=special>& </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>value </span><span class=special>)
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>value </span><span class=special>);
|
||||
</span><span class=special>}
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardReadableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_const_iterator</span><span class=special>< </span><span
|
||||
class=identifier>ForwardReadableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
</span><span class=identifier>find</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardReadableRange</span><span class=special>& </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>value </span><span class=special>)
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>value </span><span class=special>);
|
||||
</span><span class=special>}
|
||||
|
||||
</span><span class=comment>//
|
||||
// replace first value and return its index
|
||||
//
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardReadableWriteableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_size</span><span class=special>< </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
</span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>ForwardReadableWriteableRange</span><span class=special>& </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>value</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>replacement </span><span class=special>)
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_iterator</span><span class=special>< </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>found </span><span class=special>= </span><span class=identifier>find</span><span class=special>( </span><span class=identifier>c</span><span class=special>, </span><span class=identifier>value </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>if</span><span class=special>( </span><span class=identifier>found </span><span class=special>!= </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>) </span><span class=special>)
|
||||
</span><span class=special>*</span><span class=identifier>found </span><span class=special>= </span><span class=identifier>replacement</span><span class=special>;
|
||||
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>distance</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>found </span><span class=special>);
|
||||
</span><span class=special>}
|
||||
|
||||
</span><span class=comment>//
|
||||
// usage
|
||||
//
|
||||
</span><span class=keyword>const </span><span class=keyword>int </span><span class=identifier>N </span><span class=special>= </span><span class=number>5</span><span class=special>;
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=keyword>int</span><span class=special>> </span><span class=identifier>my_vector</span><span class=special>;
|
||||
</span><span class=keyword>int </span><span class=identifier>values</span><span class=special>[] </span><span class=special>= </span><span class=special>{ </span><span class=number>1</span><span class=special>,</span><span class=number>2</span><span class=special>,</span><span class=number>3</span><span class=special>,</span><span class=number>4</span><span class=special>,</span><span class=number>5</span><span class=special>,</span><span class=number>6</span><span class=special>,</span><span class=number>7</span><span class=special>,</span><span class=number>8</span><span class=special>,</span><span class=number>9 </span><span class=special>};
|
||||
</span>
|
||||
<span class=identifier>my_vector</span><span class=special>.</span><span
|
||||
class=identifier>assign</span><span class=special>( </span><span class=identifier>values</span><span class=special>, </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>values </span><span class=special>) </span><span class=special>);</span>
|
||||
</span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=keyword>int</span><span class=special>>::</span><span class=identifier>iterator </span><span class=identifier>iterator</span><span class=special>;
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special><</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>iterator</span><span class=special>> </span><span class=identifier>my_view</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>my_vector </span><span class=special>),
|
||||
</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>my_vector </span><span class=special>) </span><span class=special>+ </span><span class=identifier>N </span><span class=special>);
|
||||
</span><span class=keyword>char </span><span class=identifier>str_val</span><span class=special>[] </span><span class=special>= </span><span class=string>"a string"</span><span class=special>;
|
||||
</span><span class=keyword>char</span><span class=special>* </span><span class=identifier>str </span><span class=special>= </span><span class=identifier>str_val</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>my_generic_replace</span><span class=special>( </span><span class=identifier>my_vector</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>)
|
||||
</span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_view</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>)
|
||||
</span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>str</span><span class=special>, </span><span class=literal>'a'</span><span class=special>, </span><span class=literal>'b' </span><span class=special>);
|
||||
</span>
|
||||
<span class=comment>// prints '3', '5' and '0' </span>
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
By using the free-standing functions and <a
|
||||
href="../../mpl/doc/index.html#metafunctions">metafunctions</a>, the code automatically
|
||||
works for all the types supported by this library; now and in the future.
|
||||
Notice that we have to
|
||||
provide two version of <code >find()</code> since we cannot forward a non-const
|
||||
rvalue with reference arguments (see this article about <a href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_self" >The
|
||||
Forwarding Problem</a> ).
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
43
doc/introduction.qbk
Normal file
43
doc/introduction.qbk
Normal file
@ -0,0 +1,43 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:introduction Introduction]
|
||||
|
||||
Generic algorithms have so far been specified in terms of two or more iterators. Two iterators would together form a range of values that the algorithm could work on. This leads to a very general interface, but also to a somewhat clumsy use of the algorithms with redundant specification of container names. Therefore we would like to raise the abstraction level for algorithms so they specify their interface in terms of __ranges__ as much as possible.
|
||||
|
||||
The most common form of ranges used throughout the C++ community are standard library containers. When writing algorithms however, one often finds it desirable for the algorithm to accept other types that offer enough functionality to satisfy the needs of the generic code [*/if a suitable layer of indirection is applied/] . For example, raw arrays are often suitable for use with generic code that works with containers, provided a suitable adapter is used. Likewise, null terminated strings can be treated as containers of characters, if suitably adapted.
|
||||
|
||||
This library therefore provides the means to adapt standard-like containers, null terminated strings, `std::pairs` of iterators, and raw arrays (and more), such that the same generic code can work with them all. The basic idea is to add another layer of indirection using __metafunctions__ and free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
|
||||
The main advantages are
|
||||
|
||||
* simpler implementation and specification of generic range algorithms
|
||||
* more flexible, compact and maintainable client code
|
||||
* safe use of built-in arrays (for legacy code; why else would you use built-in arrays?)
|
||||
|
||||
[heading Example - Iterate over the values in a map]
|
||||
``
|
||||
using namespace boost;
|
||||
using namespace boost::adaptors;
|
||||
for_each( my_map | map_values, fn );
|
||||
``
|
||||
|
||||
[heading Example - Iterate over the keys in a map]
|
||||
``
|
||||
using namespace boost;
|
||||
using namespace boost::adaptors;
|
||||
for_each( my_map | map_keys, fn );
|
||||
``
|
||||
|
||||
[heading Example - Push the even values from a map in reverse order into the container `target`]
|
||||
``
|
||||
using namespace boost;
|
||||
using namespace boost::adaptors;
|
||||
// Assume that is_even is a predicate that has been implemented elsewhere...
|
||||
push_back(target, my_map | map_values | filtered(is_even()) | reversed);
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
148
doc/mfc_atl.qbk
Normal file
148
doc/mfc_atl.qbk
Normal file
@ -0,0 +1,148 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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)
|
||||
/]
|
||||
[def __mfc_collections__ [@http://msdn.microsoft.com/en-us/library/942860sh.aspx MFC Collection Classes]]
|
||||
[def __atl_collections__ [@http://msdn.microsoft.com/en-us/library/15e672bd.aspx ATL Collection Classes]]
|
||||
|
||||
[section:mfc_atl MFC/ATL (courtesy of Shunsuke Sogame)]
|
||||
|
||||
[h4 Introduction]
|
||||
This implementation was kindly donated by Shunsuke Sogame. This header adapts MFC and ATL containers to the appropriate Range concepts.
|
||||
|
||||
[table
|
||||
[]
|
||||
[[[*Author:]] [Shunsuke Sogame]]
|
||||
[[[*Contact:]] [mb2act@yahoo.co.jp]]
|
||||
[[[*Date:]] [26th of May 2006]]
|
||||
[[[*Copyright:]] [Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0]]
|
||||
]
|
||||
|
||||
[h4 Overview]
|
||||
|
||||
Boost.Range MFC/ATL Extension provides Boost.Range support for MFC/ATL collection and string types.
|
||||
|
||||
``
|
||||
CTypedPtrArray<CPtrArray, CList<CString> *> myArray;
|
||||
...
|
||||
BOOST_FOREACH (CList<CString> *theList, myArray)
|
||||
{
|
||||
BOOST_FOREACH (CString& str, *theList)
|
||||
{
|
||||
boost::to_upper(str);
|
||||
std::sort(boost::begin(str), boost::end(str));
|
||||
...
|
||||
}
|
||||
}
|
||||
``
|
||||
|
||||
[section:requirements Requirements]
|
||||
|
||||
* Boost C++ Libraries Version 1.34.0 or later (no compilation required)
|
||||
* Visual C++ 7.1 or later (for MFC and ATL)
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:mfc_ranges MFC Ranges]
|
||||
If the `<boost/range/mfc.hpp>` is included before or after Boost.Range headers, the MFC collections and strings become models of Range. The table below lists the Traversal Category and `range_reference` of MFC ranges.
|
||||
|
||||
[table
|
||||
[[Range] [Traversal Category] [`range_reference<Range>::type`]]
|
||||
[[`CArray<T,A>`] [__random_access_range__] [`T&`]]
|
||||
[[`CList<T,A>`] [__bidirectional_range__] [`T&`]]
|
||||
[[`CMap<K,AK,M,AM>`] [__forward_range__] [`Range::CPair&`]]
|
||||
[[`CTypedPtrArray<B,T*>`] [__random_access_range__] [`T* const`]]
|
||||
[[`CTypedPtrList<B,T*>`] [__bidirectional_range__] [`T* const`]]
|
||||
[[`CTypedPtrMap<B,T*,V*>`] [__forward_range__] [`std::pair<T*,V*> const`]]
|
||||
[[`CByteArray`] [__random_access_range__] [`BYTE&`]]
|
||||
[[`CDWordArray`] [__random_access_range__] [`DWORD&`]]
|
||||
[[`CObArray`] [__random_access_range__] [`CObject*&`]]
|
||||
[[`CPtrArray`] [__random_access_range__] [`void*&`]]
|
||||
[[`CStringArray`] [__random_access_range__] [`CString&`]]
|
||||
[[`CUIntArray`] [__random_access_range__] [`UINT&`]]
|
||||
[[`CWordArray`] [__random_access_range__] [`WORD&`]]
|
||||
[[`CObList`] [__bidirectional_range__] [`CObject*&`]]
|
||||
[[`CPtrList`] [__bidirectional_range__] [`void*&`]]
|
||||
[[`CStringList`] [__bidirectional_range__] [`CString&`]]
|
||||
[[`CMapPtrToWord`] [__forward_range__] [`std::pair<void*,WORD> const`]]
|
||||
[[`CMapPtrToPtr`] [__forward_range__] [`std::pair<void*,void*> const`]]
|
||||
[[`CMapStringToOb`] [__forward_range__] [`std::pair<String,CObject*> const`]]
|
||||
[[`CMapStringToString`] [__forward_range__] [`Range::CPair&`]]
|
||||
[[`CMapWordToOb`] [__forward_range__] [`std::pair<WORD,CObject*> const`]]
|
||||
[[`CMapWordToPtr`] [__forward_range__] [`std::pair<WORD,void*> const`]]
|
||||
]
|
||||
|
||||
Other Boost.Range metafunctions are defined by the following. Let `Range` be any type listed above and `Ref` be the same as `range_reference<Range>::type`. `range_value<Range>::type` is the same as `remove_reference<remove_const<Ref>::type>::type`, `range_difference<Range>::type` is the same as `std::ptrdiff_t`, and `range_pointer<Range>::type` is the same as `add_pointer<remove_reference<Ref>::type>::type`. As for `const Range`, see below.
|
||||
|
||||
Adam Walling has provided the header `<boost/range/mfc_map.hpp>` to add support
|
||||
for the map adaptor with MFC map types.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:atl_ranges ATL Ranges]
|
||||
|
||||
If the `<boost/range/atl.hpp>` is included before or after Boost.Range headers, the ATL collections and strings become models of Range. The table below lists the Traversal Category and `range_reference` of ATL ranges.
|
||||
|
||||
[table
|
||||
[[Range] [Traversal Category] [`range_reference<Range>::type`]]
|
||||
[[`CAtlArray<E,ET>`] [__random_access_range__] [`E&`]]
|
||||
[[`CAutoPtrArray<E>`] [__random_access_range__] [`E&`]]
|
||||
[[`CInterfaceArray<I,pi>`] [__random_access_range__] [`CComQIPtr<I,pi>&`]]
|
||||
[[`CAtlList<E,ET>`] [__bidirectional_range__] [`E&`]]
|
||||
[[`CAutoPtrList<E>`] [__bidirectional_range__] [`E&`]]
|
||||
[[`CHeapPtrList<E,A>`] [__bidirectional_range__] [`E&`]]
|
||||
[[`CInterfaceList<I,pi>`] [__bidirectional_range__] [`CComQIPtr<I,pi>&`]]
|
||||
[[`CAtlMap<K,V,KT,VT>`] [__forward_range__] [`Range::CPair&`]]
|
||||
[[`CRBTree<K,V,KT,VT>`] [__bidirectional_range__] [`Range::CPair&`]]
|
||||
[[`CRBMap<K,V,KT,VT>`] [__bidirectional_range__] [`Range::CPair&`]]
|
||||
[[`CRBMultiMap<K,V,KT,VT>`] [__bidirectional_range__] [`Range::CPair&`]]
|
||||
[[`CSimpleStringT<B,b>`] [__random_access_range__] [`B&`]]
|
||||
[[`CStringT<B,ST>`] [__random_access_range__] [`B&`]]
|
||||
[[`CFixedStringT<S,n>`] [__random_access_range__] [`range_reference<S>::type`]]
|
||||
[[`CComBSTR`] [__random_access_range__] [`OLECHAR&`]]
|
||||
[[`CSimpleArray<T,TE>`] [__random_access_range__] [`T&`]]
|
||||
]
|
||||
|
||||
Other __boost_range_home__ metafunctions are defined by the following. Let `Range` be any type listed above and `Ref` be the same as `range_reference<Range>::type`. `range_value<Range>::type` is the same as `remove_reference<Ref>::type`, `range_difference<Range>::type` is the same as `std::ptrdiff_t`, and `range_pointer<Range>::type` is the same as `add_pointer<remove_reference<Ref>::type>::type`. As for `const Range`, see below.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:const_ranges const Ranges]
|
||||
|
||||
`range_reference<const Range>::type` is defined by the following algorithm. Let `Range` be any type listed above and `Ref` be the same as `range_reference<Range>::type`.
|
||||
|
||||
``
|
||||
if (Range is CObArray || Range is CObList)
|
||||
return CObject const * &
|
||||
else if (Range is CPtrArray || Range is CPtrList)
|
||||
return void const * &
|
||||
else if (there is a type X such that X& is the same as Ref)
|
||||
return X const &
|
||||
else if (there is a type X such that X* const is the same as Ref)
|
||||
return X const * const
|
||||
else
|
||||
return Ref
|
||||
``
|
||||
|
||||
|
||||
Other Boost.Range metafunctions are defined by the following.
|
||||
|
||||
[table
|
||||
[[Range metafunction] [Result]]
|
||||
[[`range_value<const Range>::type`] [`range_value<Range>::type`]]
|
||||
[[`range_difference<const Range>::type`] [`std::ptrdiff_t`]]
|
||||
[[`range_pointer<const Range>::type`] [`add_pointer<remove_reference<range_reference<const Range>::type>::type>::type`]]
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:references References]
|
||||
|
||||
# __boost_range_home__
|
||||
# __mfc_collections__
|
||||
# __atl_collections__
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
232
doc/mfc_atl.rst
Normal file
232
doc/mfc_atl.rst
Normal file
@ -0,0 +1,232 @@
|
||||
|
||||
++++++++++++++++++++++++++++++++
|
||||
|Boost| Range MFC/ATL Extension
|
||||
++++++++++++++++++++++++++++++++
|
||||
|
||||
.. |Boost| image:: http://www.boost.org/libs/ptr_container/doc/boost.png
|
||||
|
||||
|
||||
|
||||
:Author: Shunsuke Sogame
|
||||
:Contact: mb2act@yahoo.co.jp
|
||||
:date: 26th of May 2006
|
||||
:copyright: Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
|
||||
|
||||
__ http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
|
||||
========
|
||||
Overview
|
||||
========
|
||||
|
||||
Boost.Range MFC/ATL Extension provides `Boost.Range`_ support for MFC/ATL collection and string types.
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
CTypedPtrArray<CPtrArray, CList<CString> \*> myArray;
|
||||
...
|
||||
BOOST_FOREACH (CList<CString> \*theList, myArray)
|
||||
{
|
||||
BOOST_FOREACH (CString& str, \*theList)
|
||||
{
|
||||
boost::to_upper(str);
|
||||
std::sort(boost::begin(str), boost::end(str));
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
* `Requirements`_
|
||||
* `MFC Ranges`_
|
||||
* `ATL Ranges`_
|
||||
* `const Ranges`_
|
||||
* `References`_
|
||||
|
||||
|
||||
|
||||
============
|
||||
Requirements
|
||||
============
|
||||
|
||||
- `Boost C++ Libraries Version 1.34.0`__ or later (no compilation required)
|
||||
- Visual C++ 7.1 or Visual C++ 8.0
|
||||
|
||||
__ Boost_
|
||||
|
||||
|
||||
|
||||
==========
|
||||
MFC Ranges
|
||||
==========
|
||||
|
||||
If the ``<boost/range/mfc.hpp>`` is included before or after `Boost.Range`_ headers,
|
||||
the MFC collections and strings become models of Range.
|
||||
The table below lists the Traversal Category and ``range_reference`` of MFC ranges.
|
||||
|
||||
|
||||
============================= ================== =======================================
|
||||
``Range`` Traversal Category ``range_reference<Range>::type``
|
||||
============================= ================== =======================================
|
||||
``CArray<T,A>`` Random Access ``T&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CList<T,A>`` Bidirectional ``T&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMap<K,AK,M,AM>`` Forward ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CTypedPtrArray<B,T*>`` Random Access ``T* const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CTypedPtrList<B,T*>`` Bidirectional ``T* const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CTypedPtrMap<B,T*,V*>`` Forward ``std::pair<T*,V*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CByteArray`` Random Access ``BYTE&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CDWordArray`` Random Access ``DWORD&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CObArray`` Random Access ``CObject* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CPtrArray`` Random Access ``void* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringArray`` Random Access ``CString&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CUIntArray`` Random Access ``UINT&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CWordArray`` Random Access ``WORD&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CObList`` Bidirectional ``CObject* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CPtrList`` Bidirectional ``void* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringList`` Bidirectional ``CString&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapPtrToWord`` Forward ``std::pair<void*,WORD> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapPtrToPtr`` Forward ``std::pair<void*,void*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapStringToOb`` Forward ``std::pair<String,CObject*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapStringToString`` Forward ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapWordToOb`` Forward ``std::pair<WORD,CObject*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapWordToPtr`` Forward ``std::pair<WORD,void*> const``
|
||||
============================= ================== =======================================
|
||||
|
||||
|
||||
Other `Boost.Range`_ metafunctions are defined by the following.
|
||||
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
|
||||
``range_value<Range>::type`` is the same as ``remove_reference<remove_const<Ref>::type>::type``,
|
||||
``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
|
||||
``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
|
||||
As for ``const Range``, see `const Ranges`_.
|
||||
|
||||
|
||||
|
||||
==========
|
||||
ATL Ranges
|
||||
==========
|
||||
|
||||
If the ``<boost/range/atl.hpp>`` is included before or after `Boost.Range`_ headers,
|
||||
the ATL collections and strings become models of Range.
|
||||
The table below lists the Traversal Category and ``range_reference`` of ATL ranges.
|
||||
|
||||
|
||||
============================= ================== =======================================
|
||||
``Range`` Traversal Category ``range_reference<Range>::type``
|
||||
============================= ================== =======================================
|
||||
``CAtlArray<E,ET>`` Random Access ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAutoPtrArray<E>`` Random Access ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CInterfaceArray<I,pi>`` Random Access ``CComQIPtr<I,pi>&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAtlList<E,ET>`` Bidirectional ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAutoPtrList<E>`` Bidirectional ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CHeapPtrList<E,A>`` Bidirectional ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CInterfaceList<I,pi>`` Bidirectional ``CComQIPtr<I,pi>&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAtlMap<K,V,KT,VT>`` Forward ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CRBTree<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CRBMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CRBMultiMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CSimpleStringT<B,b>`` Random Access ``B&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringT<B,ST>`` Random Access ``B&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CFixedStringT<S,n>`` Random Access ``range_reference<S>::type``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringT<B,ST>`` Random Access ``B&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CComBSTR`` Random Access ``OLECHAR&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CSimpleArray<T,TE>`` Random Access ``T&``
|
||||
============================= ================== =======================================
|
||||
|
||||
|
||||
Other `Boost.Range`_ metafunctions are defined by the following.
|
||||
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
|
||||
``range_value<Range>::type`` is the same as ``remove_reference<Ref>::type``,
|
||||
``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
|
||||
``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
|
||||
As for ``const Range``, see `const Ranges`_.
|
||||
|
||||
|
||||
|
||||
============
|
||||
const Ranges
|
||||
============
|
||||
|
||||
``range_reference<const Range>::type`` is defined by the following algorithm.
|
||||
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
if (Range is CObArray || Range is CObList)
|
||||
return CObject const \* &
|
||||
else if (Range is CPtrArray || Range is CPtrList)
|
||||
return void const \* &
|
||||
else if (there is a type X such that X& is the same as ReF)
|
||||
return X const &
|
||||
else if (there is a type X such that X* const is the same as ReF)
|
||||
return X const \* const
|
||||
else
|
||||
return ReF
|
||||
|
||||
|
||||
Other `Boost.Range`_ metafunctions are defined by the following.
|
||||
``range_value<const Range>::type`` is the same as ``range_value<Range>::type``,
|
||||
``range_difference<const Range>::type`` is the same as ``std::ptrdiff_t``, and
|
||||
``range_pointer<const Range>::type`` is the same as ``add_pointer<remove_reference<range_reference<const Range>::type>::type>::type``.
|
||||
|
||||
|
||||
|
||||
==========
|
||||
References
|
||||
==========
|
||||
- `Boost.Range`_
|
||||
- `MFC Collections`__
|
||||
- `ATL Collection Classes`__
|
||||
|
||||
__ http://msdn2.microsoft.com/en-us/library/942860sh.aspx
|
||||
__ http://msdn2.microsoft.com/en-US/library/15e672bd.aspx
|
||||
|
||||
|
||||
|
||||
.. _Boost C++ Libraries: http://www.boost.org/
|
||||
.. _Boost: `Boost C++ Libraries`_
|
||||
.. _Boost.Range: ../index.html
|
||||
.. _forward: range.html#forward_range
|
||||
.. _bidirectional: range.html#forward_range
|
||||
.. _random access: range.html#random_access_range
|
||||
|
@ -1,97 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Portability </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" ></td>
|
||||
<td ><h1 align="center">Boost.Range</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Portability</h2><a name="Portability" ></a>
|
||||
|
||||
<p>
|
||||
A huge effort has been made to port the library to as many compilers as possible.
|
||||
<!-- The results of the test-suites can be found <a
|
||||
href="http://boost.sourceforge.net/regression-logs/developer/range.html">here</a
|
||||
>.--> </p>
|
||||
|
||||
<p>
|
||||
Full support for built-in arrays require that the compiler supports class
|
||||
template partial specialization. For non-conforming compilers there might be a
|
||||
chance that it works anyway thanks to workarounds in the type traits library.
|
||||
</p>
|
||||
<pp>
|
||||
Visual C++ 6/7.0 has a limited support for arrays: as long as the arrays are
|
||||
of built-in type it should work.
|
||||
</p>
|
||||
<p >
|
||||
Notice also that some compilers cannot do function template ordering properly.
|
||||
In that case one must rely of <a
|
||||
href="boost_range.html#range_result_iterator"><code >range_result_iterator</code></a>
|
||||
and a single function definition instead of overloaded versions for const and
|
||||
non-const arguments.
|
||||
|
||||
So if one cares about old compilers, one should not pass rvalues to the
|
||||
functions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For maximum portability you should follow these guidelines:
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
do not use built-in arrays,
|
||||
<li>
|
||||
do not pass rvalues to <a
|
||||
href="boost_range.html#begin"><code>begin()</code></a>, <a
|
||||
href="boost_range.html#end"><code>end()</code></a> and <a href="utility_class.html#iter_range">
|
||||
<code>iterator_range</code></a> Range constructors and assignment operators,
|
||||
<li>
|
||||
use <a href="boost_range.html#const_begin"><code>const_begin()</code></a>
|
||||
and <a href="boost_range.html#const_begin"><code>const_end()</code></a>
|
||||
whenever your code by intention is read-only; this will also solve
|
||||
most rvalue problems,
|
||||
<li>
|
||||
do not rely on ADL:
|
||||
<ul>
|
||||
<li>
|
||||
if you overload functions, include that header <i>before</i> the headers in this
|
||||
library,
|
||||
<li>
|
||||
put all overloads in namespace <code>boost</code>.
|
||||
</ul>
|
||||
|
||||
</ol>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
27
doc/portability.qbk
Normal file
27
doc/portability.qbk
Normal file
@ -0,0 +1,27 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:portability Portability]
|
||||
|
||||
A huge effort has been made to port the library to as many compilers as possible.
|
||||
|
||||
Full support for built-in arrays require that the compiler supports class template partial specialization. For non-conforming compilers there might be a chance that it works anyway thanks to workarounds in the type traits library.
|
||||
Visual C++ 6/7.0 has a limited support for arrays: as long as the arrays are of built-in type it should work.
|
||||
|
||||
Notice also that some compilers cannot do function template ordering properly. In that case one must rely of __range_iterator__ and a single function definition instead of overloaded versions for const and non-const arguments. So if one cares about old compilers, one should not pass rvalues to the functions.
|
||||
|
||||
For maximum portability you should follow these guidelines:
|
||||
|
||||
# do not use built-in arrays,
|
||||
# do not pass rvalues to __begin__`()`, __end__`()` and __iterator_range__ Range constructors and assignment operators,
|
||||
# use __const_begin__`()` and __const_end__`()` whenever your code by intention is read-only; this will also solve most rvalue problems,
|
||||
# do not rely on ADL:
|
||||
* if you overload functions, include that header before the headers in this library,
|
||||
* put all overloads in namespace boost.
|
||||
|
||||
|
||||
|
||||
[endsect]
|
||||
|
493
doc/range.html
493
doc/range.html
@ -1,493 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<Title>Range Concepts</Title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</HEAD>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" ></td>
|
||||
<td ><h1 align="center">Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Range concepts </h2>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#overview">Overview</a>
|
||||
<li>
|
||||
<a href="#single_pass_range">Single Pass Range</a>
|
||||
<li>
|
||||
<a href="#forward_range">Forward Range</a>
|
||||
<li>
|
||||
<a href="#bidirectional_range">Bidirectional Range</a>
|
||||
<li>
|
||||
<a href="#random_access_range">Random Access Range</a>
|
||||
</ul>
|
||||
|
||||
<a name="overview"></a>
|
||||
<hr>
|
||||
<h3>Overview</h3>
|
||||
|
||||
<p>
|
||||
A Range is a <i>concept</i> similar to the STL <a
|
||||
href="http://www.sgi.com/Technology/STL/Container.html">Container</a> concept. A
|
||||
Range provides iterators for accessing a half-open range
|
||||
<code>[first,one_past_last)</code> of elements and provides
|
||||
information about the number of elements in the Range. However, a Range has
|
||||
fewer requirements than a Container.
|
||||
</p>
|
||||
<p>
|
||||
The motivation for the Range concept is
|
||||
that there are many useful Container-like types that do not meet the full
|
||||
requirements of Container, and many algorithms that can be written with this
|
||||
reduced set of requirements. In particular, a Range does not necessarily
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
own the elements that can be accessed through it,
|
||||
<li>
|
||||
have copy semantics,
|
||||
<!--
|
||||
<li>
|
||||
require that the associated reference type is a real C++ reference.
|
||||
-->
|
||||
</ul>
|
||||
|
||||
|
||||
Because of the second requirement, a Range object must be passed by
|
||||
(const or non-const) reference in generic code.
|
||||
|
||||
</p>
|
||||
<p>
|
||||
The operations that can be performed on a Range is dependent on the
|
||||
<a href="../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal">traversal
|
||||
category</a> of the underlying iterator type. Therefore
|
||||
the range concepts are named to reflect which traversal category its
|
||||
iterators support. See also <a href="style.html">terminology and style guidelines.</a>
|
||||
for more information about naming of ranges.</p>
|
||||
|
||||
<p> The concepts described below specifies associated types as
|
||||
<a href="../../mpl/doc/index.html#metafunctions">metafunctions</a> and all
|
||||
functions as free-standing functions to allow for a layer of indirection. </p>
|
||||
|
||||
<p><i>Notice that these metafunctions must be defined in namespace </i>
|
||||
<code>boost</code></p>
|
||||
|
||||
<hr>
|
||||
<a name="single_pass_range">
|
||||
<H2>Single Pass Range</H2>
|
||||
|
||||
<h3>Notation</h3>
|
||||
<Table>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>X</code></TD>
|
||||
<TD VAlign="top">A type that is a model of Single Pass Range.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>a</code></TD>
|
||||
<TD VAlign="top">Object of type <code>X</code>.</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Description</h3>
|
||||
<p>
|
||||
A range X where <code>range_iterator<X>::type</code> is a model of <a
|
||||
href="../../iterator/doc/new-iter-concepts.html#single-pass-iterators-lib-single-pass-iterators">
|
||||
Single Pass Iterator</a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h3>Associated types</h3>
|
||||
|
||||
<table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TD VAlign="top">Value type</TD>
|
||||
<TD VAlign="top"><code>range_value<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of the object stored in a Range.
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Iterator type</TD>
|
||||
<TD VAlign="top"><code>range_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of iterator used to iterate through a Range's elements.
|
||||
The iterator's value type is expected to be the Range's value type. A
|
||||
conversion from the iterator type to the const iterator type must exist.
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Const iterator type</TD>
|
||||
<TD VAlign="top"><code>range_const_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">A type of iterator that may be used to examine, but not to
|
||||
modify, a Range's elements.</TD>
|
||||
</TR>
|
||||
<!--
|
||||
<TR>
|
||||
<TD VAlign="top">Reference type</TD>
|
||||
<TD VAlign="top"><code>reference_of<X>::type</code></TD>
|
||||
<TD VAlign="top">A type that behaves like a reference to the Range's value type. <a href="#1">[1]</a></TD>
|
||||
</TR>
|
||||
-->
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
The following expressions must be valid.
|
||||
<p>
|
||||
|
||||
<Table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TH>Name</TH>
|
||||
<TH>Expression</TH>
|
||||
<TH>Return type</TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Beginning of range</TD>
|
||||
<TD VAlign="top"><code>begin(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_iterator<X>::type</code>
|
||||
otherwise</TD> </TR>
|
||||
<TR>
|
||||
<TD VAlign="top">End of range</TD>
|
||||
<TD VAlign="top"><code>end(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_iterator<X>::type</code>
|
||||
otherwise</TD>
|
||||
</TR>
|
||||
<tr>
|
||||
<TD VAlign="top">Is range empty?</TD>
|
||||
<TD VAlign="top"><code>empty(a)</code></TD>
|
||||
<TD VAlign="top">Convertible to <code>bool</code></TD>
|
||||
</TR>
|
||||
</table>
|
||||
<h3>Expression semantics</h3>
|
||||
|
||||
<Table border>
|
||||
<TR>
|
||||
<TH>Expression</TH>
|
||||
<TH>Semantics</TH>
|
||||
<TH>Postcondition</TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>begin(a)</code></TD>
|
||||
<TD VAlign="top">Returns an iterator pointing to the first element in the Range.</TD>
|
||||
<TD VAlign="top"><code>begin(a)</code> is either dereferenceable or past-the-end.
|
||||
It is past-the-end if and only if <code>size(a) == 0</code>.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>end(a)</code></TD>
|
||||
<TD VAlign="top">Returns an iterator pointing one past the last element in the
|
||||
Range.</TD>
|
||||
<TD VAlign="top"><code>end(a)</code> is past-the-end.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>empty(a)</code></TD>
|
||||
<TD VAlign="top">Equivalent to <code>begin(a) == end(a)</code>. (But possibly
|
||||
faster.)</TD>
|
||||
<TD VAlign="top"> - </TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<h3>Complexity guarantees</h3>
|
||||
|
||||
All three functions are at most amortized linear time. For most practical
|
||||
purposes, one can expect <code>begin(a)</code>, <code>end(a)</code> and <code>empty(a)</code>
|
||||
to be amortized constant time.
|
||||
|
||||
<h3>Invariants</h3>
|
||||
<Table border>
|
||||
<TR>
|
||||
<TD VAlign="top">Valid range</TD>
|
||||
<TD VAlign="top">For any Range <code>a</code>, <code>[begin(a),end(a))</code> is
|
||||
a valid range, that is, <code>end(a)</code> is reachable from <code>begin(a)</code>
|
||||
in a finite number of increments.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Completeness</TD>
|
||||
<TD VAlign="top">An algorithm that iterates through the range <code>[begin(a),end(a))</code>
|
||||
will pass through every element of <code>a</code>.</TD>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h3>See also</h3>
|
||||
<p>
|
||||
<A href="http://www.sgi.com/Technology/STL/Container.html">Container</A>
|
||||
</p>
|
||||
<p> <a href="boost_range.html#range_value">implementation of
|
||||
metafunctions </a></p>
|
||||
|
||||
<p> <a href="boost_range.html#begin">implementation of
|
||||
functions </a></p>
|
||||
|
||||
<hr>
|
||||
<a name=forward_range><h2>Forward Range</h2>
|
||||
|
||||
<h3>Notation</h3>
|
||||
<Table>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>X</code></TD>
|
||||
<TD VAlign="top">A type that is a model of Forward Range.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>a</code></TD>
|
||||
<TD VAlign="top">Object of type <code>X</code>.</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<h3>Description</h3>
|
||||
<p>
|
||||
A range <code>X</code> where <code>range_iterator<X>::type</code> is a model
|
||||
of <a
|
||||
href="../../iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">Forward Traversal Iterator</a>
|
||||
</p>
|
||||
|
||||
<h3>Refinement of</h3> <a href="#single_pass_range">Single Pass
|
||||
Range</a>
|
||||
|
||||
<h3>Associated types</h3>
|
||||
|
||||
<table cellpadding="5" border="1">
|
||||
<TR>
|
||||
<TD VAlign="top">Distance type</TD>
|
||||
<TD VAlign="top"><code>range_difference<X>::type</code></TD>
|
||||
<TD VAlign="top">A signed integral type used to represent the distance between
|
||||
two of the Range's iterators. This type must be the same as the iterator's
|
||||
distance type.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Size type</TD>
|
||||
<TD VAlign="top"><code>range_size<X>::type</code></TD>
|
||||
<TD VAlign="top">An unsigned integral type that can represent any nonnegative
|
||||
value of the Range's distance type.</TD>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<table border="1" cellpadding="5">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Expression</th>
|
||||
<th>Return type</th>
|
||||
</tr>
|
||||
<TR>
|
||||
<TD VAlign="top">Size of range</TD>
|
||||
<TD VAlign="top"><code>size(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_size<X>::type</code></TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<h3>Expression semantics </h3>
|
||||
|
||||
<table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TH>Expression</TH>
|
||||
<TH>Semantics</TH>
|
||||
<TH>Postcondition</TH>
|
||||
</TR>
|
||||
<tr>
|
||||
<TD VAlign="top"><code>size(a)</code></TD>
|
||||
<TD VAlign="top">Returns the size of the Range, that is, its number
|
||||
of elements. Note <code>size(a) == 0u</code> is equivalent to
|
||||
<code>empty(a).</code></TD>
|
||||
<TD VAlign="top"><code>size(a) >= 0</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<h3>Complexity guarantees</h3>
|
||||
|
||||
<p><code>size(a)</code> is at most amortized linear time.</p>
|
||||
|
||||
<h3>Invariants</h3>
|
||||
<p>
|
||||
<Table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TD VAlign="top">Range size</TD>
|
||||
<TD VAlign="top"><code>size(a)</code> is equal to the distance from <code>begin(a)</code>
|
||||
to <code>end(a)</code>.</TD> </table>
|
||||
</p>
|
||||
|
||||
<h3>See also</h3>
|
||||
<p> <a href="boost_range.html#range_difference">implementation of
|
||||
metafunctions </a></p>
|
||||
|
||||
<p> <a href="boost_range.html#size">implementation of
|
||||
functions </a></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<a name="bidirectional_range"><h2>Bidirectional Range</h2>
|
||||
|
||||
<h3>Notation</h3>
|
||||
<Table>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>X</code></TD>
|
||||
<TD VAlign="top">A type that is a model of Bidirectional Range.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>a</code></TD>
|
||||
<TD VAlign="top">Object of type <code>X</code>.</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<h3>Description</h3> This concept provides access to iterators that traverse in
|
||||
both directions (forward and reverse). The
|
||||
<code>range_iterator<X>::type</code> iterator must meet all of the requirements
|
||||
of <a
|
||||
href="../../iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterator
|
||||
s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.</a>
|
||||
|
||||
<h3>Refinement of</h3> <a href="#forward_range">Forward Range</a>
|
||||
|
||||
<h3>Associated types</h3>
|
||||
|
||||
<Table border>
|
||||
<TR>
|
||||
<TD VAlign="top">Reverse Iterator type</TD>
|
||||
<TD VAlign="top"><code>range_reverse_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of iterator used to iterate through a Range's elements
|
||||
in reverse order. The iterator's value type is expected to be the Range's value
|
||||
type. A conversion from the reverse iterator type to the const reverse iterator
|
||||
type must exist. </TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Const reverse iterator type</TD>
|
||||
<TD
|
||||
VAlign="top"><code>range_const_reverse_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">A type of reverse iterator that may be used to examine, but not
|
||||
to modify, a Range's elements.</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<TR>
|
||||
<TH>Name</TH>
|
||||
<TH>Expression</TH>
|
||||
<TH>Return type</TH>
|
||||
<TH>Semantics</TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Beginning of range</TD>
|
||||
<TD VAlign="top"><code>rbegin(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_reverse_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_reverse_iterator<X>::type</code>
|
||||
otherwise.</TD>
|
||||
<TD VAlign="top">Equivalent to
|
||||
<code>range_reverse_iterator<X>::type(end(a))</code>.</TD> </TR>
|
||||
<TR>
|
||||
<TD VAlign="top">End of range</TD>
|
||||
<TD VAlign="top"><code>rend(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_reverse_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_reverse_iterator<X>::type</code>
|
||||
otherwise.</TD>
|
||||
<TD VAlign="top">Equivalent to
|
||||
<code>range_reverse_iterator<X>::type(begin(a))</code>.</TD> </tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Complexity guarantees</h3>
|
||||
|
||||
<code>rbegin(a)</code> has the same complexity as <code>end(a)</code> and <code>rend(a)</code>
|
||||
has the same complexity as <code>begin(a)</code> from <a
|
||||
href="#forward_range">Forward Range</a>.
|
||||
|
||||
<h3>Invariants</h3>
|
||||
<p>
|
||||
<Table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TD VAlign="top">Valid reverse range</TD>
|
||||
<TD VAlign="top">For any Bidirectional Range <code>a</code>, <code>[rbegin(a),rend(a))</code>
|
||||
is a valid range, that is, <code>rend(a)</code> is reachable from <code>rbegin(a)</code>
|
||||
in a finite number of increments.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Completeness</TD>
|
||||
<TD VAlign="top">An algorithm that iterates through the range <code>[rbegin(a),rend(a))</code>
|
||||
will pass through every element of <code>a</code>.</TD>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<h3>See also</h3>
|
||||
<p> <a href="boost_range.html#range_reverse_iterator">implementation of metafunctions </a></p>
|
||||
|
||||
<p> <a href="boost_range.html#rbegin">implementation of
|
||||
functions </a></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<a name=random_access_range><h2>Random Access Range</h2> <h3>Description</h3>
|
||||
<p>
|
||||
A range <code>X</code> where <code>range_iterator<X>::type</code> is a model
|
||||
of <a
|
||||
|
||||
href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterators
|
||||
-lib-random-access-traversal-iterators">Random Access Traversal Iterator</a>
|
||||
</p>
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
<p>
|
||||
<a href="#bidirectional_range">Bidirectional Range</a>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
<!--
|
||||
<h3>Notes</h3>
|
||||
|
||||
|
||||
<P>
|
||||
<A name="1">[1]</A>
|
||||
|
||||
The reference type does not have to be a real C++ reference. The requirements of
|
||||
the reference type is that it <i>behaves</i> like a real reference. Hence the
|
||||
reference type must be convertible to the value_type and assignment through
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<HR>
|
||||
<br>
|
||||
-->
|
||||
|
||||
<TABLE>
|
||||
<TR valign="top">
|
||||
<TD nowrap>Copyright © 2000</TD>
|
||||
<TD><A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>
|
||||
</TR>
|
||||
<tr >
|
||||
<TD nowrap>Copyright © 2004</TD>
|
||||
<TD>Thorsten Ottosen.
|
||||
</TABLE>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
21
doc/reference.qbk
Normal file
21
doc/reference.qbk
Normal file
@ -0,0 +1,21 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:reference Reference]
|
||||
|
||||
[include reference/overview.qbk]
|
||||
|
||||
[section:concept_implementation Range concept implementation]
|
||||
[include reference/synopsis.qbk]
|
||||
[include reference/semantics.qbk]
|
||||
[endsect]
|
||||
|
||||
[include reference/adaptors.qbk]
|
||||
[include reference/algorithms.qbk]
|
||||
[include reference/ranges.qbk]
|
||||
[include reference/utilities.qbk]
|
||||
[include reference/extending.qbk]
|
||||
|
||||
[endsect]
|
188
doc/reference/adaptors.qbk
Normal file
188
doc/reference/adaptors.qbk
Normal file
@ -0,0 +1,188 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:adaptors Range Adaptors]
|
||||
|
||||
[section:introduction Introduction and motivation]
|
||||
|
||||
A [*Range Adaptor] is a class that wraps an existing Range to provide a new Range with different behaviour. Since the behaviour of Ranges is determined by their associated iterators, a Range Adaptor simply wraps the underlying iterators with new special iterators. In this example
|
||||
|
||||
``
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include <boost/range/algorithm.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
std::vector<int> vec;
|
||||
boost::copy( vec | boost::adaptors::reversed,
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
the iterators from `vec` are wrapped `reverse_iterator`s. The type of the underlying Range Adapter is not documented because you do not need to know it. All that is relevant is that the expression
|
||||
|
||||
``
|
||||
vec | boost::adaptors::reversed
|
||||
``
|
||||
|
||||
returns a Range Adaptor where the iterator type is now the iterator type of the range `vec` wrapped in `reverse_iterator`. The expression `boost::adaptors::reversed` is called an *Adaptor Generator*.
|
||||
|
||||
There are two ways of constructing a range adaptor. The first is by using `operator|()`. This is my preferred technique, however while discussing range adaptors with others it became clear that some users of the library strongly prefer a more familiar function syntax, so equivalent functions of the present tense form have been added as an alternative syntax. The equivalent to `rng | reversed` is `adaptors::reverse(rng)` for example.
|
||||
|
||||
Why do I prefer the `operator|` syntax? The answer is readability:
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::copy( boost::adaptors::reverse(vec),
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
This might not look so bad, but when we apply several adaptors, it becomes much worse. Just compare
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::copy( boost::adaptors::unique( boost::adaptors::reverse( vec ) ),
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
to
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::copy( vec | boost::adaptors::reversed
|
||||
| boost::adaptors::uniqued,
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
Furthermore, some of the adaptor generators take arguments themselves and these arguments are expressed with function call notation too. In those situations, you will really appreciate the succinctness of `operator|()`.
|
||||
|
||||
[heading Composition of Adaptors]
|
||||
|
||||
Range Adaptors are a powerful complement to Range algorithms. The reason is that adaptors are ['*orthogonal*] to algorithms. For example, consider these Range algorithms:
|
||||
|
||||
* `boost::copy( rng, out )`
|
||||
* `boost::count( rng, pred )`
|
||||
|
||||
What should we do if we only want to copy an element `a` if it satisfies some predicate, say `pred(a)`? And what if we only want to count the elements that satisfy the same predicate? The naive answer would be to use these algorithms:
|
||||
|
||||
* `boost::copy_if( rng, pred, out )`
|
||||
* `boost::count_if( rng, pred )`
|
||||
|
||||
These algorithms are only defined to maintain a one to one relationship with the standard library algorithms. This approach of adding algorithm suffers a combinatorial explosion. Inevitably many algorithms are missing `_if` variants and there is redundant development overhead for each new algorithm. The Adaptor Generator is the design solution to this problem. It is conceivable that some algorithms are capable of optimization by tightly coupling the filter with the algorithm. The adaptors provide a more general solution with superior separation of orthogonal concerns.
|
||||
|
||||
[heading Range Adaptor alternative to copy_if algorithm]
|
||||
``
|
||||
boost::copy_if( rng, pred, out );
|
||||
``
|
||||
can be expressed as
|
||||
``
|
||||
boost::copy( rng | boost::adaptors::filtered(pred), out );
|
||||
``
|
||||
|
||||
[heading Range Adaptor alternative to count_if algorithm]
|
||||
``
|
||||
boost::count_if( rng, pred );
|
||||
``
|
||||
can be expressed as
|
||||
``
|
||||
boost::size( rng | boost::adaptors::filtered(pred) );
|
||||
``
|
||||
|
||||
What this means is that many algorithms no longer require nor benefit from an optimized implementation with an `_if` suffix. Furthermore, it turns out that algorithms with the `_copy` suffix are often not needed either. Consider `replace_copy_if()` which may be used as
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::replace_copy_if( rng, std::back_inserter(vec), pred, new_value );
|
||||
``
|
||||
|
||||
With adaptors and algorithms we can express this as
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value));
|
||||
``
|
||||
|
||||
The latter code has several benefits:
|
||||
|
||||
1. it is more ['*efficient*] because we avoid extra allocations as might happen with `std::back_inserter`
|
||||
|
||||
2. it is ['*flexible*] as we can subsequently apply even more adaptors, for example: ``
|
||||
boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value)
|
||||
| boost::adaptors::reversed);
|
||||
``
|
||||
|
||||
3. it is ['*safer*] because there is no use of an unbounded output iterator.
|
||||
|
||||
In this manner, the ['*composition*] of Range Adaptors has the following consequences:
|
||||
|
||||
1. we no longer need many of the `_if`, `_copy`, `_copy_if` and `_n` variants of algorithms.
|
||||
|
||||
2. we can generate a multitude of new algorithms on the fly, for example, above we generated `reverse_replace_copy_if()`
|
||||
|
||||
In other words:
|
||||
|
||||
[*Range Adaptors are to algorithms what algorithms are to containers]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:general_requirements General Requirements]
|
||||
|
||||
In the description of generator expressions, the following notation is used:
|
||||
|
||||
* `fwdRng` is an expression of a type `R` that models `ForwardRange`
|
||||
* `biRng` is an expression of a type `R` that models `BidirectionalRange`
|
||||
* `rndRng` is an expression of a type `R` that models `RandomAccessRange`
|
||||
* `pred` is an expression of a type that models `UnaryPredicate`
|
||||
* `bi_pred` is an expression of a type that models `BinaryPredicate`
|
||||
* `fun` is an expression of a type that models `UnaryFunction`
|
||||
* `value`, `new_value` and `old_value` are objects convertible to `boost::range_value<R>::type`
|
||||
* `n,m` are integer expressions convertible to `range_difference<R>::type`
|
||||
|
||||
Also note that `boost::range_value<R>::type` must be implicitly convertible to the type arguments to `pred`, `bi_pred` and `fun`.
|
||||
|
||||
Range Category in the following adaptor descriptions refers to the minimum range concept required by the range passed to the adaptor. The resultant range is a model of the same range concept as the input range unless specified otherwise.
|
||||
|
||||
Returned Range Category is the concept of the returned range. In some cases the returned range is of a lesser category than the range passed to the adaptor. For example, the `filtered` adaptor returns only a `ForwardRange` regardless of the input.
|
||||
|
||||
Furthermore, the following rules apply to any expression of the form
|
||||
``
|
||||
rng | boost::adaptors::adaptor_generator
|
||||
``
|
||||
|
||||
1. Applying `operator|()` to a range `R` (always left argument) and a range adapter `RA` (always right argument) yields a new range type which may not conform to the same range concept as `R`.
|
||||
|
||||
2. The return-type of `operator|()` is otherwise unspecified.
|
||||
|
||||
3. `operator|()` is found by Argument Dependent Lookup (ADL) because a range adaptor is implemented in namespace `boost::adaptors`.
|
||||
|
||||
4. `operator|()` is used to add new behaviour ['*lazily*] and never modifies its left argument.
|
||||
|
||||
5. All iterators extracted from the left argument are extracted using qualified calls to `boost::begin()` and `boost::end()`.
|
||||
|
||||
6. In addition to the `throw`-clauses below, `operator|()` may throw exceptions as a result of copying iterators. If such copying cannot throw an exception, then neither can the whole expression.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:reference Reference]
|
||||
[include adaptors/adjacent_filtered.qbk]
|
||||
[include adaptors/copied.qbk]
|
||||
[include adaptors/filtered.qbk]
|
||||
[include adaptors/indexed.qbk]
|
||||
[include adaptors/indirected.qbk]
|
||||
[include adaptors/map_keys.qbk]
|
||||
[include adaptors/map_values.qbk]
|
||||
[include adaptors/ref_unwrapped.qbk]
|
||||
[include adaptors/replaced.qbk]
|
||||
[include adaptors/replaced_if.qbk]
|
||||
[include adaptors/reversed.qbk]
|
||||
[include adaptors/sliced.qbk]
|
||||
[include adaptors/strided.qbk]
|
||||
[include adaptors/type_erased.qbk]
|
||||
[include adaptors/tokenized.qbk]
|
||||
[include adaptors/transformed.qbk]
|
||||
[include adaptors/uniqued.qbk]
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
32
doc/reference/adaptors/adjacent_filtered.qbk
Normal file
32
doc/reference/adaptors/adjacent_filtered.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:adjacent_filtered adjacent_filtered]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::adjacent_filtered(bi_pred)`]]
|
||||
[[Function] [`boost::adaptors::adjacent_filter(rng, bi_pred)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is convertible to both argument types of `bi_pred`.
|
||||
* [*Postcondition:] For all adjacent elements `[x,y]` in the returned range, `bi_pred(x,y)` is `true`.
|
||||
* [*Throws:] Whatever the copy constructor of `bi_pred` might throw.
|
||||
* [*Range Category:] __forward_range__
|
||||
* [*Return Type:] `boost::adjacent_filtered_range<decltype(rng), decltype(bi_pred)>`
|
||||
* [*Returned Range Category:] The minimum of the range category of `rng` and __forward_range__
|
||||
|
||||
[section:adjacent_filtered_example adjacent_filtered example]
|
||||
[import ../../../test/adaptor_test/adjacent_filtered_example.cpp]
|
||||
[adjacent_filtered_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,2,3,4,5,6,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
30
doc/reference/adaptors/copied.qbk
Normal file
30
doc/reference/adaptors/copied.qbk
Normal file
@ -0,0 +1,30 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:copied copied]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::copied(n, m)`]]
|
||||
[[Function] [`boost::adaptors::copy(rng, n, m)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] `0 <= n && n <= m && m < distance(rng)`
|
||||
* [*Returns:] A new `iterator_range` that holds the sliced range `[n,m)` of the original range.
|
||||
* [*Range Category:] __random_access_range__
|
||||
* [*Returned Range Category:] __random_access_range__
|
||||
|
||||
[section:copied_example copied example]
|
||||
[import ../../../test/adaptor_test/copied_example.cpp]
|
||||
[copied_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
2,3,4,5,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
32
doc/reference/adaptors/examples/indirected.cpp
Normal file
32
doc/reference/adaptors/examples/indirected.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. 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/range/
|
||||
//
|
||||
#include <boost/range/adaptor/indirected.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<boost::shared_ptr<int> > input;
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.push_back(boost::shared_ptr<int>(new int(i)));
|
||||
|
||||
boost::copy(
|
||||
input | indirected,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
32
doc/reference/adaptors/filtered.qbk
Normal file
32
doc/reference/adaptors/filtered.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:filtered filtered]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::filtered(pred)`]]
|
||||
[[Function] [`boost::adaptors::filter(rng, pred)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is convertible to the argument type of `pred`.
|
||||
* [*Postcondition:] For all elements `[x]` in the returned range, `pred(x)` is `true`.
|
||||
* [*Throws:] Whatever the copy constructor of `pred` might throw.
|
||||
* [*Range Category:] __singlepass_range__
|
||||
* [*Range Return Type:] `boost::filtered_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__
|
||||
|
||||
[section:filtered_example filtered example]
|
||||
[import ../../../test/adaptor_test/filtered_example.cpp]
|
||||
[filtered_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
2,4,6,8,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
51
doc/reference/adaptors/formatted.qbk
Normal file
51
doc/reference/adaptors/formatted.qbk
Normal file
@ -0,0 +1,51 @@
|
||||
[/
|
||||
Copyright 2014 Neil Groves
|
||||
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:formatted formatted]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::formatted()`]]
|
||||
[[Pipe] [`rng | boost::adaptors::formatted(sep)`]]
|
||||
[[Pipe] [`rng | boost::adaptors::formatted(sep, prefix)`]]
|
||||
[[Pipe] [`rng | boost::adaptors::formatted(sep, prefix, postfix)`]]
|
||||
[[Function] [`boost::adaptors::format(rng)`]]
|
||||
[[Function] [`boost::adaptors::format(rng, sep)`]]
|
||||
[[Function] [`boost::adaptors::format(rng, sep, prefix)`]]
|
||||
[[Function] [`boost::adaptors::format(rng, sep, prefix, postfix)`]]
|
||||
]
|
||||
|
||||
This adaptor produces a range that can be output streamed to a
|
||||
`std::basic_ostream` to produce the output string formatted output. With the
|
||||
default paramters given numbers 1 to 5 inclusively in a range the output when
|
||||
streamed would be "{0,1,2,3,4,5}". The prefix, separator and postfix may be
|
||||
passed as parameters.
|
||||
|
||||
The general format of the output is thus:
|
||||
<prefix><element_1><sep><element_2><sep>...<element_n><postfix>
|
||||
|
||||
* [*Precondition:]
|
||||
* `0 <= n`.
|
||||
* `sep` has a type that is CopyConstructible and able to be streamed to `std::basic_ostream<Char,Traits>`
|
||||
* `prefix` has a type that is CopyConstructible and able to be streamed to `std::basic_ostream<Char,Traits>`
|
||||
* `postfix` has a type that is CopyConstructible and able to be streamed to `std::basic_ostream<Char,Traits>`
|
||||
* [*Returns:] `boost::range::formatted_range<Iter, Sep, Prefix, Postfix>` where
|
||||
`Iter` is `typename boost::range_iterator<Rng>::type`, `Sep` is the separator
|
||||
type, `Prefix` is the prefix type and `Postfix` is the postfix type.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:formatted_example formatted example]
|
||||
[import ../../../test/adaptor_test/formatted_example.cpp]
|
||||
[separated_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
{1,2,3,4,5}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
84
doc/reference/adaptors/indexed.qbk
Normal file
84
doc/reference/adaptors/indexed.qbk
Normal file
@ -0,0 +1,84 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:indexed indexed]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::indexed()`]]
|
||||
[[Pipe] [`rng | boost::adaptors::indexed(start_index)`]]
|
||||
[[Function] [`boost::adaptors::index(rng)`]]
|
||||
[[Function] [`boost::adaptors::index(rng, start_index)`]]
|
||||
]
|
||||
|
||||
[heading Description]
|
||||
The index within each returned `boost::range::index_value` is equal to
|
||||
`start_index` + the offset of the element from the beginning of the range. In
|
||||
the versions of the functions that omit `start_index` the starting index is
|
||||
taken to be `0`.
|
||||
|
||||
* [*Purpose:] Adapt `rng` to return elements that have the corresponding value
|
||||
from `rng` and a numeric index.
|
||||
* [*Returns:] A range adapted to return both the element and the associated
|
||||
index. The returned range has elements of type:
|
||||
|
||||
``
|
||||
boost::range::index_value<
|
||||
typename boost::range_reference<decltype(rng)>::type,
|
||||
typename boost::range_difference<decltype(rng)>::type
|
||||
>
|
||||
``
|
||||
|
||||
The synopsis of index_value is as follows:
|
||||
``
|
||||
template<class T, class Indexable=std::ptrdiff_t>
|
||||
class index_value : public boost::tuple<Indexable, T>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef ...unspecified... index_type;
|
||||
typedef ...unspecified... const_index_type;
|
||||
|
||||
typedef ...unspecified... value_type;
|
||||
typedef ...unspecified... const_value_type;
|
||||
|
||||
// ...unspecified... constructors
|
||||
|
||||
index_type index();
|
||||
const_index_type index() const;
|
||||
|
||||
value_type value();
|
||||
const_value_type value() const;
|
||||
};
|
||||
``
|
||||
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::indexed_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng` if and only if `rng`
|
||||
is not a __bidirectional_range__. If `rng` is a __bidirectional_range__ then the
|
||||
returned range category is __forward_range__. The rationale for the demotion of
|
||||
__bidirectional_range__ inputs to __forward_range__ is to avoid slow calculation
|
||||
of indices for `boost::end(rng)`.
|
||||
|
||||
[section:indexed_example indexed example]
|
||||
[import ../../../test/adaptor_test/indexed_example.cpp]
|
||||
[indexed_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
Element = 10 Index = 0
|
||||
Element = 20 Index = 1
|
||||
Element = 30 Index = 2
|
||||
Element = 40 Index = 3
|
||||
Element = 50 Index = 4
|
||||
Element = 60 Index = 5
|
||||
Element = 70 Index = 6
|
||||
Element = 80 Index = 7
|
||||
Element = 90 Index = 8
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
31
doc/reference/adaptors/indirected.qbk
Normal file
31
doc/reference/adaptors/indirected.qbk
Normal file
@ -0,0 +1,31 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:indirected indirected]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::indirected`]]
|
||||
[[Function] [`boost::adaptors::indirect(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range defines unary `operator*()`
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `*y` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::indirected_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`
|
||||
|
||||
[section:indirected_example indirected example]
|
||||
[import ../../../test/adaptor_test/indirected_example.cpp]
|
||||
[indirected_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
0,1,2,3,4,5,6,7,8,9,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
31
doc/reference/adaptors/map_keys.qbk
Normal file
31
doc/reference/adaptors/map_keys.qbk
Normal file
@ -0,0 +1,31 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:map_keys map_keys]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::map_keys`]]
|
||||
[[Function] [`boost::adaptors::keys(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is an instantiation of `std::pair`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.first` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::select_first_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:map_keys_example map_keys example]
|
||||
[import ../../../test/adaptor_test/map_keys_example.cpp]
|
||||
[map_keys_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
0,1,2,3,4,5,6,7,8,9,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
31
doc/reference/adaptors/map_values.qbk
Normal file
31
doc/reference/adaptors/map_values.qbk
Normal file
@ -0,0 +1,31 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:map_values map_values]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::map_values`]]
|
||||
[[Function] [`boost::adaptors::values(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is an instantiation of `std::pair`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.second` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] for constant ranges, `boost::select_second_const<decltype(rng)>` otherwise `boost::select_second_mutable<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:map_values_example map_values example]
|
||||
[import ../../../test/adaptor_test/map_values_example.cpp]
|
||||
[map_values_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
0,10,20,30,40,50,60,70,80,90,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
32
doc/reference/adaptors/ref_unwrapped.qbk
Normal file
32
doc/reference/adaptors/ref_unwrapped.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[/
|
||||
Copyright 2015 Robin Eckert
|
||||
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:ref_unwrapped ref_unwrapped]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::ref_unwrapped`]]
|
||||
[[Function] [`boost::adaptors::ref_unwrap(rng)`]]
|
||||
]
|
||||
|
||||
This adaptor produces a range than applies `.get()` on all values in
|
||||
the range. It is useful for iterating ranges of
|
||||
`std::reference_wrapper` values or values using similar semantics.
|
||||
|
||||
The adaptor is C++11 (and above) only.
|
||||
|
||||
* [*Precondition:] The `value_type` of the range has a `.get() const`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.get()` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::unwrap_ref_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:ref_unwrapped_example ref_unwrapped example]
|
||||
[import ../../../test/adaptor_test/ref_unwrapped_example.cpp]
|
||||
[ref_unwrapped_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output `123`.
|
||||
[endsect]
|
33
doc/reference/adaptors/replaced.qbk
Normal file
33
doc/reference/adaptors/replaced.qbk
Normal file
@ -0,0 +1,33 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:replaced replaced]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::replaced(old_value, new_value)`]]
|
||||
[[Function] [`boost::adaptors::replace(rng, old_value, new_value)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
* `new_value` is convertible to the `value_type` of the range.
|
||||
* `old_value` is convertible to the `value_type` of the range.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, the value `x` is equal to the value of `(y == old_value) ? new_value : y` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::replaced_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:replaced_example replaced example]
|
||||
[import ../../../test/adaptor_test/replaced_example.cpp]
|
||||
[replaced_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,10,3,10,5,10,7,10,9,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
33
doc/reference/adaptors/replaced_if.qbk
Normal file
33
doc/reference/adaptors/replaced_if.qbk
Normal file
@ -0,0 +1,33 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:replaced_if replaced_if]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::replaced_if(pred, new_value)`]]
|
||||
[[Function] [`boost::adaptors::replace_if(rng, pred, new_value)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
* The range `value_type` is convertible to the argument type of `pred`.
|
||||
* `new_value` is convertible to the `value_type` of the range.
|
||||
* [*Postconditions:] For all elements `x` in the returned range, the value `x` is equal to the value of `pred(y) ? new_value : y` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::replaced_if_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:replaced_if_example replaced_if example]
|
||||
[import ../../../test/adaptor_test/replaced_if_example.cpp]
|
||||
[replaced_if_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,10,3,10,5,10,7,10,9,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
30
doc/reference/adaptors/reversed.qbk
Normal file
30
doc/reference/adaptors/reversed.qbk
Normal file
@ -0,0 +1,30 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:reversed reversed]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::reversed`]]
|
||||
[[Function] [`boost::adaptors::reverse(rng)`]]
|
||||
]
|
||||
|
||||
* [*Returns:] A range whose iterators behave as if they were the original iterators wrapped in `reverse_iterator`.
|
||||
* [*Range Category:] __bidirectional_range__
|
||||
* [*Range Return Type:] `boost::reversed_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:reversed_example reversed example]
|
||||
[import ../../../test/adaptor_test/reversed_example.cpp]
|
||||
[reversed_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
9,8,7,6,5,4,3,2,1,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
31
doc/reference/adaptors/sliced.qbk
Normal file
31
doc/reference/adaptors/sliced.qbk
Normal file
@ -0,0 +1,31 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:sliced sliced]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::sliced(n, m)`]]
|
||||
[[Function] [`boost::adaptors::slice(rng, n, m)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] `0 <= n && n <= m && m < distance(rng)`
|
||||
* [*Returns:] `make_range(rng, n, m)`
|
||||
* [*Range Category:] __random_access_range__
|
||||
* [*Range Return Type:] `boost::sliced_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] __random_access_range__
|
||||
|
||||
[section:sliced_example sliced example]
|
||||
[import ../../../test/adaptor_test/sliced_example.cpp]
|
||||
[sliced_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
3,4,5,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
30
doc/reference/adaptors/strided.qbk
Normal file
30
doc/reference/adaptors/strided.qbk
Normal file
@ -0,0 +1,30 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:strided strided]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::strided(n)`]]
|
||||
[[Function] [`boost::adaptors::stride(rng, n)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] `0 <= n`.
|
||||
* [*Returns:] A new range based on `rng` where traversal is performed in steps of `n`.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:strided_example strided example]
|
||||
[import ../../../test/adaptor_test/strided_example.cpp]
|
||||
[strided_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,3,5,7,9,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
67
doc/reference/adaptors/tokenized.qbk
Normal file
67
doc/reference/adaptors/tokenized.qbk
Normal file
@ -0,0 +1,67 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:tokenized tokenized]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[
|
||||
[Pipe]
|
||||
[
|
||||
``
|
||||
rng | boost::adaptors::tokenized(regex)
|
||||
rng | boost::adaptors::tokenized(regex, i)
|
||||
rng | boost::adaptors::tokenized(regex, rndRng)
|
||||
rng | boost::adaptors::tokenized(regex, i, flags)
|
||||
rng | boost::adaptors::tokenized(regex, rndRng, flags)
|
||||
``
|
||||
]
|
||||
]
|
||||
[
|
||||
[Function]
|
||||
[
|
||||
``
|
||||
boost::adaptors::tokenize(rng, regex)
|
||||
boost::adaptors::tokenize(rng, regex, i)
|
||||
boost::adaptors::tokenize(rng, regex, rndRng)
|
||||
boost::adaptors::tokenize(rng, regex, i, flags)
|
||||
boost::adaptors::tokenize(rng, regex, rndRng, flags)
|
||||
``
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
* Let `T` denote `typename range_value<decltype(rng)>::type`, then `regex` has the type `basic_regex<T>` or is implicitly convertible to one of these types.
|
||||
* `i` has the type `int`.
|
||||
* the `value_type` of `rndRng` is `int`.
|
||||
* `flags` has the type `regex_constants::syntax_option_type`.
|
||||
* [*Returns:] A range whose iterators behave as if they were the original iterators wrapped in `regex_token_iterator`. The first iterator in the range would be constructed by forwarding all the arguments of `tokenized()` to the `regex_token_iterator` constructor.
|
||||
* [*Throws:] Whatever constructing and copying equivalent `regex_token_iterator`s might throw.
|
||||
* [*Range Category:] __random_access_range__
|
||||
* [*Range Return Type:] `boost::tokenized_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] __random_access_range__
|
||||
|
||||
[section:tokenized_example tokenized_example]
|
||||
[import ../../../test/adaptor_test/tokenized_example.cpp]
|
||||
[tokenized_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
e
|
||||
f
|
||||
g
|
||||
hijklmnopqrstuvwxyz
|
||||
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
|
32
doc/reference/adaptors/transformed.qbk
Normal file
32
doc/reference/adaptors/transformed.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:transformed transformed]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::transformed(fun)`]]
|
||||
[[Function] [`boost::adaptors::transform(rng, fun)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is convertible to the argument type of `fun`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `fun(y)` where `y` is the corresponding element in the original range.
|
||||
* [*Throws:] Whatever the copy-constructor of `fun` might throw.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::transformed_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:transformed_example transformed example]
|
||||
[import ../../../test/adaptor_test/transformed_example.cpp]
|
||||
[transformed_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
2,4,6,8,10,12,14,16,18,20,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
65
doc/reference/adaptors/type_erased.qbk
Normal file
65
doc/reference/adaptors/type_erased.qbk
Normal file
@ -0,0 +1,65 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:type_erased type_erased]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::type_erased<Value, Traversal, Reference, Difference, Buffer>()`]]
|
||||
[[Function] [`boost::adaptors::type_erase(rng, boost::adaptors::type_erased<Value, Traversal, Reference, Difference, Buffer>)`]]
|
||||
]
|
||||
|
||||
Please note that it is frequently unnecessary to use the `type_erased` adaptor. It is often better to use the implicit conversion to `any_range`.
|
||||
|
||||
Let `Rng` be the type of `rng`.
|
||||
|
||||
* [*Template parameters:]
|
||||
* `Value` is the `value_type` for the `any_range`. If this is set to boost::use_default, `Value` will be calculated from the
|
||||
range type when the adaptor is applied.
|
||||
* `Traversal` is the tag used to identify the traversal of the resultant range. Frequently it is desirable to set a traversal category lower than the source container or range to maximize the number of ranges that can convert to the `any_range`. If this is left as boost::use_default then `Traversal` will be `typename boost::iterator_traversal<boost::range_iterator<Rng>::type>::type`
|
||||
* `Reference` is the `reference` for the `any_range`. `boost::use_default` will equate to `typename range_reference<Rng>::type`.
|
||||
* `Difference` is the `difference_type` for the any_range. `boost::use_default` will equate to `typename boost::range_difference<Rng>::type`
|
||||
* `Buffer` is the storage used to allocate the underlying iterator wrappers. This can typically be ignored, but is available as a template parameter for customization. Buffer must be a model of the `AnyIteratorBufferConcept`.
|
||||
* [*Precondition:] `Traversal` is one of `{ boost::use_default, boost::single_pass_traversal_tag, boost::forward_traversal_tag, boost::bidirectional_traversal_tag, boost::random_access_traversal_tag }`
|
||||
* [*Returns:] The returned value is the same as `typename any_range_type_generator< Rng, Value, Traversal, Reference, Difference, Buffer >` that represents `rng` in a type-erased manner.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Returned Range Category:] if `Traversal` was specified as `boost::use_default` then `typename boost::iterator_traversal<boost::range_iterator<Rng>::type>::type`, otherwise `Traversal`.
|
||||
|
||||
[heading AnyIteratorBufferConcept]
|
||||
``
|
||||
class AnyIteratorBufferConcept
|
||||
{
|
||||
public:
|
||||
AnyIteratorBufferConcept();
|
||||
~AnyIteratorBufferConcept();
|
||||
|
||||
// bytes is the requested size to allocate. This function
|
||||
// must return a pointer to an adequate area of memory.
|
||||
// throws: bad_alloc
|
||||
//
|
||||
// The buffer will only ever have zero or one
|
||||
// outstanding memory allocations.
|
||||
void* allocate(std::size_t bytes);
|
||||
|
||||
// deallocate this buffer
|
||||
void deallocate();
|
||||
};
|
||||
``
|
||||
|
||||
[section:type_erased_example type-erased example]
|
||||
[import ../../../test/adaptor_test/type_erased_example.cpp]
|
||||
[type_erased_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,2,3,4,5,
|
||||
6,7,8,9,10,
|
||||
11,12,13,14,15,
|
||||
11,12,13,14,15,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
31
doc/reference/adaptors/uniqued.qbk
Normal file
31
doc/reference/adaptors/uniqued.qbk
Normal file
@ -0,0 +1,31 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:uniqued uniqued]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::uniqued`]]
|
||||
[[Function] [`boost::adaptors::unique(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is comparable with `operator==()`.
|
||||
* [*Postcondition:] For all adjacent elements `[x,y]` in the returned range, `x==y` is false.
|
||||
* [*Range Category:] __forward_range__
|
||||
* [*Range Return Type:] `boost::uniqued_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The minimum of the range concept of `rng` and __forward_range__.
|
||||
|
||||
[section:uniqued_example uniqued example]
|
||||
[import ../../../test/adaptor_test/uniqued_example.cpp]
|
||||
[uniqued_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,2,3,4,5,6,
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
85
doc/reference/algorithm/adjacent_find.qbk
Normal file
85
doc/reference/algorithm/adjacent_find.qbk
Normal file
@ -0,0 +1,85 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:adjacent_find adjacent_find]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
adjacent_find(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
adjacent_find(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
adjacent_find(ForwardRange& rng, BinaryPred pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
adjacent_find(const ForwardRange& rng, BinaryPred pred);
|
||||
|
||||
template<range_return_value_re, class ForwardRange>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
adjacent_find(ForwardRange& rng);
|
||||
|
||||
template<range_return_value_re, class ForwardRange>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
adjacent_find(const ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
adjacent_find(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
adjacent_find(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
[*Non-predicate versions:]
|
||||
|
||||
`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `x == y`
|
||||
|
||||
[*Predicate versions:]
|
||||
|
||||
`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `pred(x,y)` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/adjacent_find.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of adjacent_find:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
|
||||
[*For the predicate versions of adjacent_find:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. If `empty(rng)` then no comparisons are performed; otherwise, at most `distance(rng) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
60
doc/reference/algorithm/binary_search.qbk
Normal file
60
doc/reference/algorithm/binary_search.qbk
Normal file
@ -0,0 +1,60 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:binary_search binary_search]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
bool binary_search(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<class ForwardRange, class Value, class BinaryPredicate>
|
||||
bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`binary_search` returns `true` if and only if the value `val` exists in the range `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/binary_search.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of binary_search:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions of binary_search:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
`rng` is ordered in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
`rng` is ordered in ascending order according to the function object `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For non-random-access ranges, the complexity is `O(N)` where `N` is `distance(rng)`.
|
||||
|
||||
For random-access ranges, the complexity is `O(log N)` where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
41
doc/reference/algorithm/copy.qbk
Normal file
41
doc/reference/algorithm/copy.qbk
Normal file
@ -0,0 +1,41 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:copy copy]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class OutputIterator>
|
||||
OutputIterator copy(const SinglePassRange& source_rng, OutputIterator out_it);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`copy` copies all elements from `source_rng` to the range `[out_it, out_it + distance(source_rng))`.
|
||||
The return value is `out_it + distance(source_rng)`
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/copy.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* The `value_type` of __single_pass_range__ Concept is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `out_it` is not an iterator within the `source_rng`.
|
||||
* `[out_it, out_it + distance(source_rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(source_rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
46
doc/reference/algorithm/copy_backward.qbk
Normal file
46
doc/reference/algorithm/copy_backward.qbk
Normal file
@ -0,0 +1,46 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:copy_backward copy_backward]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange, class BidirectionalOutputIterator>
|
||||
BidirectionalOutputIterator
|
||||
copy_backward(const BidirectionalRange& source_rng,
|
||||
BidirectionalOutputIterator out_it);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`copy_backward` copies all elements from `source_rng` to the range `[out_it - distance(source_rng), out_it)`.
|
||||
|
||||
The values are copied in reverse order. The return value is `out_it - distance(source_rng)`.
|
||||
|
||||
Note well that unlike all other standard algorithms `out_it` denotes the *end* of the output sequence.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/copy_backward.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `BidirectionalRange` is a model of __bidirectional_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* The `value_type` of __bidirectional_range__ Concept is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `out_it` is not an iterator within the `source_rng`.
|
||||
* `[out_it, out_it + distance(source_rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(source_rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
41
doc/reference/algorithm/count.qbk
Normal file
41
doc/reference/algorithm/count.qbk
Normal file
@ -0,0 +1,41 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:count count]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_difference<SinglePassRange>::type
|
||||
count(SinglePassRange& rng, const Value& val);
|
||||
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_difference<const SinglePassRange>::type
|
||||
count(const SinglePassRange& rng, const Value& val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`count` returns the number of elements `x` in `rng` where `x == val` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/count.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* An object of `SinglePassRange`'s value type can be compared for equality with an object of type `Value`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
37
doc/reference/algorithm/count_if.qbk
Normal file
37
doc/reference/algorithm/count_if.qbk
Normal file
@ -0,0 +1,37 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:count_if count_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class UnaryPredicate>
|
||||
typename range_difference<const SinglePassRange>::type
|
||||
count_if(const SinglePassRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`count_if` returns the number of elements `x` in `rng` where `pred(x)` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/count_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `UnaryPredicate` is a model of the `UnaryPredicateConcept`.
|
||||
* `SinglePassRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` invocations of `pred`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
64
doc/reference/algorithm/equal.qbk
Normal file
64
doc/reference/algorithm/equal.qbk
Normal file
@ -0,0 +1,64 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:equal equal]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2
|
||||
>
|
||||
bool equal(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
bool equal(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`equal` returns `true` if `distance(rng1)` is equal to the `distance(rng2)` and for each element `x` in `rng1`, the corresponding element `y` in `rng2` is equal. Otherwise `false` is returned.
|
||||
|
||||
In this range version of `equal` it is perfectly acceptable to pass in two ranges of unequal lengths.
|
||||
|
||||
Elements are considered equal in the non-predicate version if `operator==` returns `true`. Elements are considered equal in the predicate version if `pred(x,y)` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/equal.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange1`'s value type can be compared for equality with `SinglePassRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `min(distance(rng1), distance(rng2))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
83
doc/reference/algorithm/equal_range.qbk
Normal file
83
doc/reference/algorithm/equal_range.qbk
Normal file
@ -0,0 +1,83 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:equal_range equal_range]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
std::pair<typename range_iterator<ForwardRange>::type,
|
||||
typename range_iterator<ForwardRange>::type>
|
||||
equal_range(ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
std::pair<typename range_iterator<const ForwardRange>::type,
|
||||
typename range_iterator<const ForwardRange>::type>
|
||||
equal_range(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value,
|
||||
class SortPredicate
|
||||
>
|
||||
std::pair<typename range_iterator<ForwardRange>::type,
|
||||
typename range_iterator<ForwardRange>::type>
|
||||
equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value,
|
||||
class SortPredicate
|
||||
>
|
||||
std::pair<typename range_iterator<const ForwardRange>::type,
|
||||
typename range_iterator<const ForwardRange>::type>
|
||||
equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`equal_range` returns a range in the form of a pair of iterators where all of the elements are equal to `val`. If no values are found that are equal to `val`, then an empty range is returned, hence `result.first == result.second`. For the non-predicate versions of `equal_range` the equality of elements is determined by `operator<`.
|
||||
For the predicate versions of `equal_range` the equality of elements is determined by `pred`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/equal_range.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `SortPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to both of `SortPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
For the non-predicate versions: `rng` is ordered in ascending order according to `operator<`.
|
||||
|
||||
For the predicate versions: `rng` is ordered in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For random-access ranges, the complexity is `O(log N)`, otherwise the complexity is `O(N)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
36
doc/reference/algorithm/fill.qbk
Normal file
36
doc/reference/algorithm/fill.qbk
Normal file
@ -0,0 +1,36 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:fill fill]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
ForwardRange& fill( ForwardRange& rng, const Value& val );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`fill` assigns the value `val` to every element in the range `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/fill.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
36
doc/reference/algorithm/fill_n.qbk
Normal file
36
doc/reference/algorithm/fill_n.qbk
Normal file
@ -0,0 +1,36 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:fill_n fill_n]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Size, class Value>
|
||||
ForwardRange& fill( ForwardRange& rng, Size n, const Value& val );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`fill_n` assigns the value `val` to `n` elements in the range `rng` beginning with `boost::begin(rng)`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/fill_n.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `n` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
45
doc/reference/algorithm/find.qbk
Normal file
45
doc/reference/algorithm/find.qbk
Normal file
@ -0,0 +1,45 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:find find]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_iterator<SinglePassRange>::type
|
||||
find(SinglePassRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<SinglePassRange, re>::type
|
||||
find(SinglePassRange& rng, Value val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find` that return an iterator, returns the first iterator in the range `rng` such that `*i == value`. `end(rng)` is returned if no such iterator exists.
|
||||
The versions of find that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* The `operator==` is defined for type `Value` to be compared with the `SinglePassRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng)` comparisons for equality.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
74
doc/reference/algorithm/find_end.qbk
Normal file
74
doc/reference/algorithm/find_end.qbk
Normal file
@ -0,0 +1,74 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:find_end find_end]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<ForwardRange1>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange1>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find_end` that return an iterator, return an iterator to the beginning of the last sub-sequence equal to `rng2` within `rng1`.
|
||||
Equality is determined by `operator==` for non-predicate versions of `find_end`, and by satisfying `pred` in the predicate versions. The versions of `find_end` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find_end.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* Objects of `ForwardRange1`'s value type can be compared for equality with objects of `ForwardRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
The number of comparisons is proportional to `distance(rng1) * distance(rng2)`. If both `ForwardRange1` and `ForwardRange2` are models of `BidirectionalRangeConcept` then the average complexity is linear and the worst case is `distance(rng1) * distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
74
doc/reference/algorithm/find_first_of.qbk
Normal file
74
doc/reference/algorithm/find_first_of.qbk
Normal file
@ -0,0 +1,74 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:find_first_of find_first_of]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class ForwardRange2>
|
||||
typename range_iterator<SinglePassRange1>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<SinglePassRange1>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<SinglePassRange1, re>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<SinglePassRange1, re>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find_first_of` that return an iterator, return an iterator to the first occurrence in `rng1` of any of the elements in `rng2`.
|
||||
Equality is determined by `operator==` for non-predicate versions of `find_first_of`, and by satisfying `pred` in the predicate versions.
|
||||
|
||||
The versions of `find_first_of` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find_first_of.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`, and can be compared for equality with `ForwardRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
At most `distance(rng1) * distance(rng2)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
50
doc/reference/algorithm/find_if.qbk
Normal file
50
doc/reference/algorithm/find_if.qbk
Normal file
@ -0,0 +1,50 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:find_if find_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class UnaryPredicate>
|
||||
typename range_iterator<SinglePassRange>::type
|
||||
find_if(SinglePassRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<SinglePassRange, re>::type
|
||||
find_if(SinglePassRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find_if` that return an iterator, returns the first iterator in the range `rng` such that `pred(*i)` is `true`. `end(rng)` is returned if no such iterator exists.
|
||||
|
||||
The versions of `find_if` that return a `range_return`, defines found in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
* The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
For each iterator `i` in `rng`, `*i` is in the domain of `UnaryPredicate`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng)` invocations of `pred`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
45
doc/reference/algorithm/for_each.qbk
Normal file
45
doc/reference/algorithm/for_each.qbk
Normal file
@ -0,0 +1,45 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:for_each for_each]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange,
|
||||
class UnaryFunction
|
||||
>
|
||||
UnaryFunction for_each(SinglePassRange& rng, UnaryFunction fun);
|
||||
|
||||
template<
|
||||
class SinglePassRange,
|
||||
class UnaryFunction
|
||||
>
|
||||
UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`for_each` traverses forward through `rng` and for each element `x` it invokes `fun(x)`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/for_each.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `UnaryFunction` is a model of the `UnaryFunctionConcept`.
|
||||
* `UnaryFunction` does not apply any non-constant operation through its argument.
|
||||
* `SinglePassRange`'s value type is convertible to `UnaryFunction`'s argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` applications of `UnaryFunction`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
44
doc/reference/algorithm/generate.qbk
Normal file
44
doc/reference/algorithm/generate.qbk
Normal file
@ -0,0 +1,44 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:generate generate]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Generator>
|
||||
ForwardRange& generate( ForwardRange& rng, Generator gen );
|
||||
|
||||
template<class ForwardRange, class Generator>
|
||||
const ForwardRange& generate( const ForwardRange& rng, Generator gen );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`generate` assigns the result of `gen()` to each element in range `rng`. Returns the resultant range.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/generate.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Generator` is a model of the `GeneratorConcept`.
|
||||
* The `value_type` of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `out_it` is not an iterator within `rng`.
|
||||
* `[out_it, out_it + distance(rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
69
doc/reference/algorithm/includes.qbk
Normal file
69
doc/reference/algorithm/includes.qbk
Normal file
@ -0,0 +1,69 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:includes includes]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`includes` returns `true` if and only if, for every element in `rng2`, an equivalent element is also present in `rng1`.
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
77
doc/reference/algorithm/inplace_merge.qbk
Normal file
77
doc/reference/algorithm/inplace_merge.qbk
Normal file
@ -0,0 +1,77 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:inplace_merge inplace_merge]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
BidirectionalRange&
|
||||
inplace_merge( BidirectionalRange& rng,
|
||||
typename range_iterator<BidirectionalRange>::type middle );
|
||||
|
||||
template<class BidirectionalRange>
|
||||
const BidirectionalRange&
|
||||
inplace_merge( const BidirectionalRange& rng,
|
||||
typename range_iterator<const BidirectionalRange>::type middle );
|
||||
|
||||
template<class BidirectionalRange, class BinaryPredicate>
|
||||
BidirectionalRange&
|
||||
inplace_merge( BidirectionalRange& rng,
|
||||
typename range_iterator<BidirectionalRange>::type middle,
|
||||
BinaryPredicate pred );
|
||||
|
||||
template<class BidirectionalRange, class BinaryPredicate>
|
||||
const BidirectionalRange&
|
||||
inplace_merge( const BidirectionalRange& rng,
|
||||
typename range_iterator<const BidirectionalRange>::type middle,
|
||||
BinaryPredicate pred );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`inplace_merge` combines two consecutive sorted ranges `[begin(rng), middle)` and `[middle, end(rng))` into a single sorted range `[begin(rng), end(rng))`. That is, it starts with a range `[begin(rng), end(rng))` that consists of two pieces each of which is in ascending order, and rearranges it so that the entire range is in ascending order. `inplace_merge` is stable, meaning both that the relative order of elements within each input range is preserved.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/inplace_merge.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `range_value<BidirectionalRange>::type` is a model of `LessThanComparableConcept`
|
||||
* The ordering on objects of `range_type<BidirectionalRange>::type` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate version:]
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `BidirectionalRange`'s value type is convertible to both `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[heading For the non-predicate version:]
|
||||
|
||||
* `middle` is in the range `rng`.
|
||||
* `[begin(rng), middle)` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `y < x` is `false`.
|
||||
* `[middle, end(rng))` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `y < x` is `false`.
|
||||
|
||||
[heading For the predicate version:]
|
||||
|
||||
* `middle` is in the range `rng`.
|
||||
* `[begin(rng), middle)` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `pred(y,x) == false`.
|
||||
* `[middle, end(rng))` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `pred(y,x) == false`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Worst case: `O(N log(N))`
|
||||
|
||||
[endsect]
|
||||
|
||||
|
60
doc/reference/algorithm/lexicographical_compare.qbk
Normal file
60
doc/reference/algorithm/lexicographical_compare.qbk
Normal file
@ -0,0 +1,60 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:lexicographical_compare lexicographical_compare]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2
|
||||
>
|
||||
bool lexicographical_compare(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
bool lexicographical_compare(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`lexicographical_compare` compares element by element `rng1` against `rng2`. If the element from `rng1` is less than the element from `rng2` then `true` is returned. If the end of `rng1` without reaching the end of `rng2` this also causes the return value to be `true`. The return value is `false` in all other circumstances. The elements are compared using `operator<` in the non-predicate versions of `lexicographical_compare` and using `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/lexicographical_compare.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of lexicographical_compare:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* Let `x` be an object of `SinglePassRange1`'s value type. Let `y` be an object of `SinglePassRange2`'s value type. `x < y` must be valid. `y < x` must be valid.
|
||||
|
||||
[*For the predicate versions of lexicographical_compare:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `2 * min(distance(rng1), distance(rng2))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
93
doc/reference/algorithm/lower_bound.qbk
Normal file
93
doc/reference/algorithm/lower_bound.qbk
Normal file
@ -0,0 +1,93 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:lower_bound lower_bound]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
lower_bound(ForwardRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
lower_bound(ForwardRange& rng, Value val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value,
|
||||
class SortPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
lower_bound(ForwardRange& rng, Value val, SortPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value,
|
||||
class SortPredicate
|
||||
>
|
||||
typename range_return<ForwardRange,re>::type
|
||||
lower_bound(ForwardRange& rng, Value val, SortPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `lower_bound` that return an iterator, returns the first iterator in the range `rng` such that:
|
||||
without predicate - `*i < value` is `false`,
|
||||
with predicate - `pred(*i, value)` is `false`.
|
||||
|
||||
`end(rng)` is returned if no such iterator exists.
|
||||
|
||||
The versions of `lower_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/lower_bound.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng` is sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng` is sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For ranges that model the __random_access_range__ concept the complexity is `O(log N)`, where `N` is `distance(rng)`.
|
||||
|
||||
For all other range types the complexity is `O(N)`.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
|
56
doc/reference/algorithm/make_heap.qbk
Normal file
56
doc/reference/algorithm/make_heap.qbk
Normal file
@ -0,0 +1,56 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:make_heap make_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& make_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& make_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
RandomAccessRange& make_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
const RandomAccessRange& make_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`make_heap` turns `rng` into a heap.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `3 * distance(rng)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
86
doc/reference/algorithm/max_element.qbk
Normal file
86
doc/reference/algorithm/max_element.qbk
Normal file
@ -0,0 +1,86 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:max_element max_element]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
max_element(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
max_element(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
max_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
max_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
max_element(ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value_re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
max_element(const ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
max_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
max_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `max_element` that return an iterator, return the iterator to the maximum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the maximum value. The versions of `max_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/max_element.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
88
doc/reference/algorithm/merge.qbk
Normal file
88
doc/reference/algorithm/merge.qbk
Normal file
@ -0,0 +1,88 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:merge merge]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator merge(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator merge(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`merge` combines two sorted ranges `rng1` and `rng2` into a single sorted range by copying elements. `merge` is stable. The return value is `out + distance(rng1) + distance(rng2)`.
|
||||
|
||||
The two versions of `merge` differ by how they compare the elements.
|
||||
|
||||
The non-predicate version uses the `operator<()` for the range value type. The predicate version uses the predicate instead of `operator<()`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/merge.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `range_value<SinglePassRange1>::type` is the same as `range_value<SinglePassRange2>::type`.
|
||||
* `range_value<SinglePassRange1>::type` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering on objects of `range_value<SinglePassRange1>::type` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `range_value<SinglePassRange1>::type` is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `range_value<SinglePassRange1>::type` is the same as `range_value<SinglePassRange2>::type`.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to both `BinaryPredicate`'s argument types.
|
||||
* `range_value<SinglePassRange1>::type` is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[heading For the non-predicate version:]
|
||||
|
||||
* The elements of `rng1` are in ascending order. That is, for each adjacent element pair `[x,y]` of `rng1`, `y < x == false`.
|
||||
* The elements of `rng2` are in ascending order. That is, for each adjacent element pair `[x,y]` of `rng2`, `y < x == false`.
|
||||
* The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* `[out, out + distance(rng1) + distance(rng2))` is a valid range.
|
||||
|
||||
[heading For the predicate version:]
|
||||
|
||||
* The elements of `rng1` are in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng1`, `pred(y, x) == false`.
|
||||
* The elements of `rng2` are in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng2`, `pred(y, x) == false`.
|
||||
* The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* `[out, out + distance(rng1) + distance(rng2))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. There are no comparisons if both `rng1` and `rng2` are empty, otherwise at most `distance(rng1) + distance(rng2) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
86
doc/reference/algorithm/min_element.qbk
Normal file
86
doc/reference/algorithm/min_element.qbk
Normal file
@ -0,0 +1,86 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:min_element min_element]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
min_element(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
min_element(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
min_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
min_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
min_element(ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value_re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
min_element(const ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
min_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
min_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `min_element` that return an iterator, return the iterator to the minimum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the minimum value. The versions of `min_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/min_element.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
119
doc/reference/algorithm/mismatch.qbk
Normal file
119
doc/reference/algorithm/mismatch.qbk
Normal file
@ -0,0 +1,119 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:mismatch mismatch]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2);
|
||||
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`mismatch` finds the first position where the corresponding elements from the two ranges `rng1` and `rng2` are not equal.
|
||||
|
||||
Equality is determined by `operator==` for non-predicate versions of `mismatch`, and by satisfying `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/mismatch.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange1`s value type can be compared for equality with `SinglePassRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
`distance(rng2) >= distance(rng1)`
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng1)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
56
doc/reference/algorithm/next_permutation.qbk
Normal file
56
doc/reference/algorithm/next_permutation.qbk
Normal file
@ -0,0 +1,56 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:next_permutation next_permutation]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
bool next_permutation(BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange>
|
||||
bool next_permutation(const BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
bool next_permutation(BidirectionalRange& rng, Compare pred);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
bool next_permutation(const BidirectionalRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`next_permutation` transforms the range of elements `rng` into the lexicographically next greater permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically smallest permutation and `false` is returned. `true` is returned when the next greater permutation is successfully generated.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/permutation.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng) / 2` swaps.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
67
doc/reference/algorithm/nth_element.qbk
Normal file
67
doc/reference/algorithm/nth_element.qbk
Normal file
@ -0,0 +1,67 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:nth_element nth_element]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& nth_element(
|
||||
RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type nth);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& nth_element(
|
||||
const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type nth);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& nth_element(
|
||||
RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type nth,
|
||||
BinaryPredicate sort_pred);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& nth_element(
|
||||
const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type nth,
|
||||
BinaryPredicate sort_pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`nth_element` partially orders a range of elements. `nth_element` arranges the range `rng` such that the element corresponding with the iterator `nth` is the same as the element that would be in that position if `rng` has been sorted.
|
||||
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/nth_element.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
On average, linear in `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
69
doc/reference/algorithm/partial_sort.qbk
Normal file
69
doc/reference/algorithm/partial_sort.qbk
Normal file
@ -0,0 +1,69 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:partial_sort partial_sort]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& partial_sort(
|
||||
RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type middle);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& partial_sort(
|
||||
const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type middle);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& partial_sort(
|
||||
RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type middle,
|
||||
BinaryPredicate sort_pred);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& partial_sort(
|
||||
const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type middle,
|
||||
BinaryPredicate sort_pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`partial_sort` rearranges the elements in `rng`. It places the smallest `distance(begin(rng), middle)` elements, sorted in ascending order, into the range `[begin(rng), middle)`. The remaining elements are placed in an unspecified order into `[middle, last)`.
|
||||
|
||||
The non-predicative versions of this function specify that one element is less than another by using `operator<()`. The predicate versions use the predicate instead.
|
||||
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/partial_sort.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Approximately `distance(rng) * log(distance(begin(rng), middle))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
63
doc/reference/algorithm/partition.qbk
Normal file
63
doc/reference/algorithm/partition.qbk
Normal file
@ -0,0 +1,63 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:partition partition]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`partition` orders the elements in `rng` based on `pred`, such that the elements that satisfy `pred` precede the elements that do not. In the versions that return a single iterator, the return value is the middle iterator. In the versions that have a configurable range_return, `found` corresponds to the middle iterator.
|
||||
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/partition.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept. For C++ versions prior to C++11 the underlying std::partition requires Bidirectional Iterators, hence the requirement for older library versions is for a __bidirectional_range__.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` applications of `pred`, and at most `distance(rng) / 2` swaps.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
61
doc/reference/algorithm/pop_heap.qbk
Normal file
61
doc/reference/algorithm/pop_heap.qbk
Normal file
@ -0,0 +1,61 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:pop_heap pop_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& pop_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& pop_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
RandomAccessRange& pop_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap (and therefore the largest element is `*begin(rng)`).
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `!empty(rng)`
|
||||
* `rng` is a heap.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Logarithmic. At most `2 * log(distance(rng))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
56
doc/reference/algorithm/prev_permutation.qbk
Normal file
56
doc/reference/algorithm/prev_permutation.qbk
Normal file
@ -0,0 +1,56 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:prev_permutation prev_permutation]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
bool prev_permutation(BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange>
|
||||
bool prev_permutation(const BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
bool prev_permutation(BidirectionalRange& rng, Compare pred);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
bool prev_permutation(const BidirectionalRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`prev_permutation` transforms the range of elements `rng` into the lexicographically next smaller permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically largest permutation and `false` is returned. `true` is returned when the next smaller permutation is successfully generated.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/permutation.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng) / 2` swaps.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
61
doc/reference/algorithm/push_heap.qbk
Normal file
61
doc/reference/algorithm/push_heap.qbk
Normal file
@ -0,0 +1,61 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:push_heap push_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& push_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& push_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
RandomAccessRange& push_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
const RandomAccessRange& push_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`push_heap` adds an element to a heap. It is assumed that `begin(rng)`, `prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `!empty(rng)`
|
||||
* `[begin(rng), prior(end(rng)))` is a heap.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Logarithmic. At most `log(distance(rng))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
55
doc/reference/algorithm/random_shuffle.qbk
Normal file
55
doc/reference/algorithm/random_shuffle.qbk
Normal file
@ -0,0 +1,55 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:random_shuffle random_shuffle]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& random_shuffle(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& random_shuffle(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Generator>
|
||||
RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen);
|
||||
|
||||
template<class RandomAccessRange, class Generator>
|
||||
const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`random_shuffle` randomly rearranges the elements in `rng`. The versions of `random_shuffle` that do not specify a `Generator` use an internal random number generator. The versions of `random_shuffle` that do specify a `Generator` use this instead. Returns the shuffles range.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/random_shuffle.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the version without a Generator:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
|
||||
[*For the version with a Generator:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `Generator` is a model of the `RandomNumberGeneratorConcept`.
|
||||
* `RandomAccessRange`'s distance type is convertible to `Generator`'s argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `distance(rng)` is less than `gen`'s maximum value.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. If `!empty(rng)`, exactly `distance(rng) - 1` swaps are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
60
doc/reference/algorithm/remove.qbk
Normal file
60
doc/reference/algorithm/remove.qbk
Normal file
@ -0,0 +1,60 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:remove remove]
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
remove(ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
remove(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<ForwardRange,re>::type
|
||||
remove(ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<const ForwardRange,re>::type
|
||||
remove(const ForwardRange& rng, const Value& val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`remove` removes from `rng` all of the elements `x` for which `x == val` is `true`. The versions of `remove` that return an iterator, return an iterator `new_last` such that the range `[begin(rng), new_last)` contains no elements equal to `val`. The `range_return` versions of `remove` defines `found` as the new last element. The iterators in the range `[new_last, end(rng))` are dereferenceable, but the elements are unspecified.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/remove.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* Objects of type `Value` can be compared for equality with objects of `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `remove` performs exactly `distance(rng)` comparisons for equality.
|
||||
|
||||
[endsect]
|
39
doc/reference/algorithm/remove_copy.qbk
Normal file
39
doc/reference/algorithm/remove_copy.qbk
Normal file
@ -0,0 +1,39 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:remove_copy remove_copy]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Outputiterator, class Value>
|
||||
OutputIterator
|
||||
remove_copy(ForwardRange& rng, OutputIterator out, const Value& val);
|
||||
|
||||
template<class ForwardRange, class OutputIterator, class Value>
|
||||
OutputIterator
|
||||
remove_copy(const ForwardRange& rng, OutputIterator out, const Value& val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`remove_copy` copied all of the elements `x` from `rng` for which `x == val` is `false`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/remove_copy.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* Objects of type `Value` can be compared for equality with objects of `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `remove_copy` performs exactly `distance(rng)` comparisons for equality.
|
||||
|
||||
[endsect]
|
38
doc/reference/algorithm/remove_copy_if.qbk
Normal file
38
doc/reference/algorithm/remove_copy_if.qbk
Normal file
@ -0,0 +1,38 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:remove_copy_if remove_copy_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Outputiterator, class UnaryPred>
|
||||
OutputIterator
|
||||
remove_copy_if(ForwardRange& rng, OutputIterator out, UnaryPred pred);
|
||||
|
||||
template<class ForwardRange, class OutputIterator, class UnaryPred>
|
||||
OutputIterator
|
||||
remove_copy_if(const ForwardRange& rng, OutputIterator out, UnaryPred pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`remove_copy_if` copied all of the elements `x` from `rng` for which `pred(x)` is `false`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/remove_copy_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPred` is a model of the `UnaryPredicateConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `remove_copy_if` performs exactly `distance(rng)` comparisons with UnaryPred.
|
||||
|
||||
[endsect]
|
63
doc/reference/algorithm/remove_if.qbk
Normal file
63
doc/reference/algorithm/remove_if.qbk
Normal file
@ -0,0 +1,63 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:remove_if remove_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
remove_if(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
remove_if(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange,re>::type
|
||||
remove_if(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange,re>::type
|
||||
remove_if(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`remove_if` removes from `rng` all of the elements `x` for which `pred(x)` is `true`. The versions of `remove_if` that return an iterator, return an iterator `new_last` such that the range `[begin(rng), new_last)` contains no elements where `pred(x)` is `true`. The iterators in the range `[new_last, end(rng))` are dereferenceable, but the elements are unspecified.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/remove_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `remove_if` performs exactly `distance(rng)` applications of `pred`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
46
doc/reference/algorithm/replace.qbk
Normal file
46
doc/reference/algorithm/replace.qbk
Normal file
@ -0,0 +1,46 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:replace replace]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
ForwardRange& replace(ForwardRange& rng, const Value& what, const Value& with_what);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
const ForwardRange& replace(const ForwardRange& rng, const Value& what, const Value& with_what);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`replace` every element in `rng` equal to `what` with `with_what`. Return a reference to `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/replace.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `Value` is a model of the `EqualityComparableConcept`, and may be compared for equality with objects of `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `replace` performs exactly `distance(rng)` comparisons for equality and at most `distance(rng)` assignments.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
38
doc/reference/algorithm/replace_copy.qbk
Normal file
38
doc/reference/algorithm/replace_copy.qbk
Normal file
@ -0,0 +1,38 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:replace_copy replace_copy]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class OutputIterator, class Value>
|
||||
OutputIterator replace_copy(const ForwardRange& rng, OutputIterator out,
|
||||
const Value& what, const Value& with_what);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`replace_copy` copy every element `x` in `rng` such that the corresponding element in the output range `y` is `x == what ? with_what : x`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/replace_copy.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `replace_copy` performs exactly `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
39
doc/reference/algorithm/replace_copy_if.qbk
Normal file
39
doc/reference/algorithm/replace_copy_if.qbk
Normal file
@ -0,0 +1,39 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:replace_copy_if replace_copy_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class OutputIterator, class UnaryPredicate, class Value>
|
||||
OutputIterator replace_copy_if(const ForwardRange& rng, OutputIterator out,
|
||||
UnaryPredicate pred, const Value& with_what);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`replace_copy_if` copy every element `x` in `rng` such that the corresponding element in the output range `y` is `pred(x) ? with_what : x`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/replace_copy_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `UnaryPredicate` is a model of the `UnaryPredicateConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `replace_copy_if` performs exactly `distance(rng)` evaluations of `pred`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
41
doc/reference/algorithm/replace_if.qbk
Normal file
41
doc/reference/algorithm/replace_if.qbk
Normal file
@ -0,0 +1,41 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:replace_if replace_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class UnaryPredicate, class Value>
|
||||
ForwardRange& replace_if(ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
|
||||
|
||||
template<class ForwardRange, class UnaryPredicate, class Value>
|
||||
const ForwardRange& replace_if(const ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`replace_if` replaces every element `x` in `rng` for which `pred(x) == true` with `with_what`. Returns a reference to `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/replace_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`
|
||||
* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `replace_if` performs exactly `distance(rng)` applications of `pred`, and at most `distance(rng)` assignments.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
37
doc/reference/algorithm/reverse.qbk
Normal file
37
doc/reference/algorithm/reverse.qbk
Normal file
@ -0,0 +1,37 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:reverse reverse]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
BidirectionalRange& reverse(BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange>
|
||||
const BidirectionalRange& reverse(const BidirectionalRange& rng);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`reverse` reverses a range. Returns a reference to the reversed range.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/reverse.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `reverse` makes `distance(rng)/2` calls to `iter_swap`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
36
doc/reference/algorithm/reverse_copy.qbk
Normal file
36
doc/reference/algorithm/reverse_copy.qbk
Normal file
@ -0,0 +1,36 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:reverse_copy reverse_copy]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange, class OutputIterator>
|
||||
OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`reverse_copy` copies the elements from `rng` in reverse order to `out`.
|
||||
Returns the output iterator one passed the last copied element.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/reverse_copy.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `reverse_copy` makes `distance(rng)` copies.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
44
doc/reference/algorithm/rotate.qbk
Normal file
44
doc/reference/algorithm/rotate.qbk
Normal file
@ -0,0 +1,44 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:rotate rotate]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
ForwardRange& rotate(ForwardRange& rng,
|
||||
typename range_iterator<ForwardRange>::type middle);
|
||||
|
||||
template<class ForwardRange>
|
||||
const ForwardRange& rotate(const ForwardRange& rng,
|
||||
typename range_iterator<const ForwardRange>::type middle);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`rotate` rotates the elements in a range. It exchanges the two ranges `[begin(rng), middle)` and `[middle, end(rng))`. Returns a reference to `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/rotate.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `[begin(rng), middle)` is a valid range.
|
||||
* `[middle, end(rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng)` swaps are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
43
doc/reference/algorithm/rotate_copy.qbk
Normal file
43
doc/reference/algorithm/rotate_copy.qbk
Normal file
@ -0,0 +1,43 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:rotate_copy rotate_copy]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class OutputIterator>
|
||||
OutputIterator rotate_copy(
|
||||
const ForwardRange& rng,
|
||||
typename range_iterator<ForwardRange>::type middle,
|
||||
OutputIterator out);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`rotate_copy` rotates the elements in a range. It copies the two ranges `[begin(rng), middle)` and `[middle, end(rng))` to `out`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/rotate_copy.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `[begin(rng), middle)` is a valid range.
|
||||
* `[middle, end(rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` elements are copied.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
106
doc/reference/algorithm/search.qbk
Normal file
106
doc/reference/algorithm/search.qbk
Normal file
@ -0,0 +1,106 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:search search]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<ForwardRange1>::type
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<const ForwardRange1>::type
|
||||
search(const ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange1>::type,
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange1>::type
|
||||
search(const ForwardRange1& rng1, ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<const ForwardRange1, re>::type
|
||||
search(const ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type,
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange1, re>::type
|
||||
search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `search` that return an iterator, return an iterator to the start of the first subsequence in `rng1` that is equal to the subsequence `rng2`. The `end(rng1)` is returned if no such subsequence exists in `rng1`.
|
||||
Equality is determined by `operator==` for non-predicate versions of `search`, and by satisfying `pred` in the predicate versions.
|
||||
|
||||
The versions of `search` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/search.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange1`s value type can be compared for equality with `ForwardRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Average complexity is Linear. Worst-case complexity is quadratic.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
63
doc/reference/algorithm/search_n.qbk
Normal file
63
doc/reference/algorithm/search_n.qbk
Normal file
@ -0,0 +1,63 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:search_n search_n]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Integer, class Value>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
search_n(ForwardRange& rng, Integer n, const Value& value);
|
||||
|
||||
template<class ForwardRange, class Integer, class Value>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
search_n(const ForwardRange& rng, Integer n, const Value& value);
|
||||
|
||||
template<class ForwardRange, class Integer, class Value, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
search_n(ForwardRange& rng, Integer n, const Value& value,
|
||||
BinaryPredicate binary_pred);
|
||||
|
||||
template<class ForwardRange, class Integer, class Value, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
search_n(const ForwardRange& rng, Integer n, const Value& value,
|
||||
BinaryPredicate binary_pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`search_n` searches `rng` for a sequence of length `n` equal to `value` where
|
||||
equality is determined by operator== in the non-predicate case, and by a
|
||||
predicate when one is supplied.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/search_n.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange`s value type can be compared for equality with `Value`.
|
||||
* `Integer` is a model of the `IntegerConcept`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `Value` is convertible to `BinaryPredicate`'s second argument type.
|
||||
* `Integer` is a model of the `IntegerConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Average complexity is Linear. Worst-case complexity is quadratic.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
81
doc/reference/algorithm/set_difference.qbk
Normal file
81
doc/reference/algorithm/set_difference.qbk
Normal file
@ -0,0 +1,81 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:set_difference set_difference]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator set_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator set_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_difference` constructs a sorted range that is the set difference of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
81
doc/reference/algorithm/set_intersection.qbk
Normal file
81
doc/reference/algorithm/set_intersection.qbk
Normal file
@ -0,0 +1,81 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:set_intersection set_intersection]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator set_intersection(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator set_intersection(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_intersection` constructs a sorted range that is the intersection of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
83
doc/reference/algorithm/set_symmetric_difference.qbk
Normal file
83
doc/reference/algorithm/set_symmetric_difference.qbk
Normal file
@ -0,0 +1,83 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:set_symmetric_difference set_symmetric_difference]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator
|
||||
set_symmetric_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator
|
||||
set_symmetric_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_symmetric_difference` constructs a sorted range that is the set symmetric difference of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
80
doc/reference/algorithm/set_union.qbk
Normal file
80
doc/reference/algorithm/set_union.qbk
Normal file
@ -0,0 +1,80 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:set_union set_union]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator set_union(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator set_union(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_union` constructs a sorted range that is the union of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
58
doc/reference/algorithm/sort.qbk
Normal file
58
doc/reference/algorithm/sort.qbk
Normal file
@ -0,0 +1,58 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:sort sort]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& sort(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& sort(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`sort` sorts the elements in `rng` into ascending order. `sort` is not guaranteed to be stable. Returns the sorted range.
|
||||
|
||||
For versions of the `sort` function without a predicate, ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`.
|
||||
|
||||
For versions of the `sort` function with a predicate, ascending order is defined by `pred` such that for all adjacent elements `[x,y]`, `pred(y, x) == false`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/sort.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For versions of sort without a predicate:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For versions of sort with a predicate]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
`O(N log(N))` comparisons (both average and worst-case), where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
60
doc/reference/algorithm/sort_heap.qbk
Normal file
60
doc/reference/algorithm/sort_heap.qbk
Normal file
@ -0,0 +1,60 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:sort_heap sort_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& sort_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& sort_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
RandomAccessRange& sort_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
const RandomAccessRange& sort_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`sort_heap` turns a heap into a sorted range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
`rng` is a heap.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
At most `N * log(N)` comparisons, where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
61
doc/reference/algorithm/stable_partition.qbk
Normal file
61
doc/reference/algorithm/stable_partition.qbk
Normal file
@ -0,0 +1,61 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:stable_partition stable_partition]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class UnaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
stable_partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class UnaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
stable_partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
stable_partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
stable_partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`stable_partition` reorders the elements in the range `rng` base on the function object `pred`. Once this function has completed all of the elements that satisfy `pred` appear before all of the elements that fail to satisfy it. `stable_partition` differs from `partition` because it preserves relative order. It is stable.
|
||||
|
||||
For the versions that return an iterator, the return value is the iterator to the first element that fails to satisfy `pred`.
|
||||
|
||||
For versions that return a `range_return`, the `found` iterator is the iterator to the first element that fails to satisfy `pred`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/stable_partition.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Best case: `O(N)` where `N` is `distance(rng)`.
|
||||
Worst case: `N * log(N)` swaps, where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
59
doc/reference/algorithm/stable_sort.qbk
Normal file
59
doc/reference/algorithm/stable_sort.qbk
Normal file
@ -0,0 +1,59 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:stable_sort stable_sort]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& stable_sort(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& stable_sort(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`stable_sort` sorts the elements in `rng` into ascending order. `stable_sort` is guaranteed to be stable. The order is preserved for equivalent elements.
|
||||
|
||||
For versions of the `stable_sort` function without a predicate ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`.
|
||||
|
||||
For versions of the `stable_sort` function with a predicate, ascending order is designed by `pred` such that for all adjacent elements `[x,y]`, `pred(y,x) == false`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/stable_sort.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For versions of stable_sort without a predicate]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For versions of stable_sort with a predicate:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Best case: `O(N)` where `N` is `distance(rng)`.
|
||||
Worst case: `O(N log(N)^2)` comparisons, where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
37
doc/reference/algorithm/swap_ranges.qbk
Normal file
37
doc/reference/algorithm/swap_ranges.qbk
Normal file
@ -0,0 +1,37 @@
|
||||
[/
|
||||
Copyright 2010 Neil Groves
|
||||
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:swap_ranges swap_ranges]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
SinglePassRange2& swap_ranges(SinglePassRange1& rng1, SinglePassRange& rng2);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`swap_ranges` swaps each element `x` in `rng1` with the corresponding element `y` in `rng2`.
|
||||
Returns a reference to `rng2`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/swap_ranges.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1` is mutable.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is mutable.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng1)` elements are swapped.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user