1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517
|
[/
Copyright 2016-2017 Joaquin M Lopez Munoz.
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 _AllocatorAwareContainer_ [@http://en.cppreference.com/w/cpp/named_req/AllocatorAwareContainer [* `AllocatorAwareContainer`]]]
[def _Callable_ [@http://en.cppreference.com/w/cpp/named_req/Callable [* `Callable`]]]
[def _Container_ [@http://en.cppreference.com/w/cpp/named_req/Container [* `Container`]]]
[def _CopyAssignable_ [@http://en.cppreference.com/w/cpp/named_req/CopyAssignable [* `CopyAssignable`]]]
[def _CopyInsertable_ [@http://en.cppreference.com/w/cpp/named_req/CopyInsertable [* `CopyInsertable`]]]
[def _DefaultConstructible_ [@http://en.cppreference.com/w/cpp/named_req/DefaultConstructible [* `DefaultConstructible`]]]
[def _InputIterator_ [@http://en.cppreference.com/w/cpp/named_req/InputIterator [* `InputIterator`]]]
[def _INVOKE_ [@http://en.cppreference.com/w/cpp/utility/functional/invoke ['[* `INVOKE`]]]]
[def _MoveAssignable_ [@http://en.cppreference.com/w/cpp/named_req/MoveAssignable [* `MoveAssignable`]]]
[def _MoveInsertable_ [@http://en.cppreference.com/w/cpp/named_req/MoveInsertable [* `MoveInsertable`]]]
[section Reference]
[section Polymorphism models]
[def _polymorphism_model_ [link poly_collection.reference.polymorphism_models polymorphism model]]
The key aspect of dynamic polymorphism is the ability for a value of type `T`
to internally use another value of a possibily different type `U` for the
implementation of a given interface. Base/derived polymorphism is the classic
model of dynamic polymorphism in C++, but not the only possible one.
Formally, a /polymorphism model/ is defined by
* A family *Interface* of permissible interface types and, for each
`I` \u2208 *Interface*, the family *Implementation*(`I`) of types satisfying
`I`.
* For a given interface type `I`, an operation *subobject*(`x`) that maps each
value of an implementation type to its internally used value `y` of a possibly
different implementation type
[footnote This is a metalinguistic definition not directly expressible in C++.
There are equivalent formulations that can indeed be realized in C++, but
they add little to the comprehension of the concepts.].
Static polymorphism is the trivial case where *subobject*(`x`) = `x` for all
`x`. Base/derived polymorphism is characterized by:
* *Interface* = { `Base` : `std::is_polymorphic_v<Base>` }.
* *Implementation*(`Base`) = { `Derived` : `std::is_base_of_v<Base,Derived>` }.
* *subobject*(`x`) = `static_cast<Derived&>(x)` with `typeid(x)==typeid(Derived)`.
[endsect]
[section Polymorphic containers]
[def _PolymorphicContainer_ [link poly_collection.reference.polymorphic_containers [* `PolymorphicContainer`]]]
A /polymorphic container/ is an object that stores objects of some type `T`
implementing a given interface `I` under an implicitly associated polymorphism
model. Polymorphic containers satisfy the requirements for _Container_ and
_AllocatorAwareContainer_ with the following modifications:
* Where it occurs, replace the requirement that `T` be _CopyInsertable_,
_CopyAssignable_, _MoveInsertable_, _MoveAssignable_ or
_EqualityComparable_, with the following semantic clause: may throw if
some subobject in the container is not
_CopyConstructible_ (respectively, _CopyAssignable_, _MoveConstructible_,
_MoveAssignable_, _EqualityComparable_).
* Replace [container.requirements.general]/3 with:
`allocator_type` must have the property that for any type `U`
implementing `I` and the associated type `A` =
`std::allocator_traits<allocator_type>::rebind_alloc<U>`, `U` is
_CopyInsertable_ (respectively _MoveInsertable_) with respect to `A` if and
only if `U` is _CopyConstructible_ (respectively _MoveConstructible_);
all subobjects of type `U` stored in these containers shall be constructed
using the `std::allocator_traits<A>::construct` function and
destroyed using the `std::allocator_traits<A>::destroy` function;
these functions (or their equivalents for a rebound allocator) are called
only for the types of the stored subobjects, not for
any other type (internal or public) used by the container.
[section Polymorphic collections]
[def _PolymorphicCollection_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections [* `PolymorphicCollection`]]]
/Polymorphic collections/ store their objects of type `value_type` in
/segments/ dedicated to each of the types of the contained subojects.
Only objects whose subobjects are of an /acceptable/ type are allowed,
where a type `U` is said to be acceptable if
* it implements the interface associated to the container,
* it is _MoveConstructible_,
* it is _MoveAssignable_ or
[@http://en.cppreference.com/w/cpp/types/is_move_constructible
`std::is_nothrow_move_constructible<U>::value`] is `true`.
Polymorphic collections conform
to the requirements of _PolymorphicContainer_ with the following
modfications and extra guarantees:
* The complexity of `empty()` and `size()` is linear on the number of
segments of the collection.
* `max_size()` is not provided.
* `a==b` evaluates to `true` iff for each non-empty segment of subojects
of type `U` in `a` there is a segment of `U` in `b` with the same size
and equal elements in the same order, and vice versa.
* No exceptions are thrown associated to some subobject type not being
_CopyAssignable_, _MoveConstructible_ or _MoveAssignable_.
A type `U` is said to be /registered/ into the collection if a
(possibly empty) segment for `U` has been created. Registered types
continue to stay so for the duration of the container except if it is
moved from, assigned to, or swapped.
Each segment has an associated capacity indicating the maximum size
that it can attain without reallocation. When the limit
is exceeded (or explicitly through `reserve`) new storage space is
allocated with greater capacity and elements are moved.
Collection traversal goes through the elements of the first segment,
then the second, etc. The order in which segments are visited is
unspecified but remains stable until a new segment is created.
Besides `iterator` and `const_iterator`, there are iterator types
`local_base_iterator` and `local_iterator<U>` (and their `const_`
counterparts) whose objects can be used to iterate over the segment
for `U` (in the same order followed by global traversal).
Local base iterators refer to `value_type`, whereas
(`const_`)`local_iterator<U>` refers to `U`. All local iterators model
_RandomAccessIterator_. Local base iterators may not be used
to iterate across segments, and comparing local base iterators
associated to different segments is undefined behavior. A (const)
local base iterator to a segment for `U` can be explicitly converted
to (`const_`)`local_iterator<U>` pointing to the same position,
and vice versa.
Insertion and erasure do not invalidate iterators (global or local)
except those from the insertion/erasure point to the end of the
affected segment, if its capacity is not exceeded, or all
iterators/references to the segment otherwise
[footnote The global `end()` iterator lies outside any segment, hence
it always remain valid.].
For the description of the remaining requirements of polymorphic collections,
we use the following notation:
* `C` is a polymorphic collection type,
* `c` is an object of type `C`, `cc` is a possibly `const` object of type `C`,
* `al` is a value of type `C::allocator_type`,
* `info` is a `const std::type_info&`,
* `U` is an acceptable type, `Us...` is a template parameter pack of
acceptable types,
* `n` is a value of `size_type`,
* `x` is a value of a type `T` implementing the interface associated to the
collection,
* `args...` is a function parameter pack of types `Args&&...`,
* `it` is a possibly const global iterator of `c`,
* `it1` and `it2` are (same-typed) possibly const global iterators of a `C`
collection other than `c` such that \[`it1`, `it2`) is a valid range.
* `lbit` is a possibly const local base iterator of `c`,
* `lbit1` and `lbit2` are (same-typed) possibly const local base iterators of
a `C` collection other than `c` such that \[`lbit1`, `lbit2`) is a valid range.
* `lit` is a (`const_`)`local_iterator<U>` of `c`,
* `lit1` and `lit2` are (same-typed) (`const_`)`local_iterator<U>`s of
a `C` collection other than `c` such that \[`lit1`, `lit2`) is a valid range,
* `i1` and `i2` are iterators external to `c` referring to `T` such that
\[`i1`, `i2`) is a valid range,
* `j1` and `j2` are iterators external to `c` such that
\[`j1`, `j2`) is a valid range,
* `xit1` and `xit2` are (same-typed) possibly const iterators (global or
local) of `c` such that \[`xit1`, `xit2`) is a valid range.
[section Types]
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_base_iterator]
[def _local_base_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_base_iterator `local_base_iterator`]]
`C::local_base_iterator`
_RandomAccessIterator_ with same value type, difference type and pointer and
reference types as `C::iterator`, valid for accessing elements of a given
segment. Implicily convertible to `C::const_local_base_iterator`, explicitly
convertible to `C::local_iterator<U>` if the segment it points to is actually
that for `U`.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_base_iterator]
[def _const_local_base_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_base_iterator `const_local_base_iterator`]]
`C::const_local_base_iterator`
_RandomAccessIterator_ with same value type, difference type and pointer and
reference types as `C::const_iterator`, valid for accessing elements of a given
segment. Explicitly convertible to `C::const_local_iterator<U>` if the segment
it points to is actually that for `U`.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_iterator]
[def _local_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_iterator `local_iterator`]]
`C::local_iterator<U>`
_RandomAccessIterator_ with value type `U`, reference type `U&`, pointer type
`U*` and the same difference type as `C::iterator`, valid for accessing elements
of the segment for `U`. Implicily convertible to `C::const_local_iterator<U>`,
explicitly convertible to `C::local_base_iterator`.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_iterator]
[def _const_local_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_iterator `const_local_iterator`]]
`C::const_local_iterator<U>`
_RandomAccessIterator_ with value type `U`, reference type `const U&`, pointer
type `const U*` and the same difference type as `C::iterator`, valid for
accessing elements of the segment for `U`. Explicitly convertible to
`C::const_local_base_iterator`.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info]
[def _const_base_segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info `const_base_segment_info`]]
`C::const_base_segment_info`
_CopyConstructible_ and _CopyAssignable_ type with information about a given
segment of a collection. If `ci` is a possibly `const` object of type
`C::const_base_segment_info` associated to the segment of `c` for `U`, then
* `ci.begin()==c.cbegin(typeid(U))`
* `ci.cbegin()==c.cbegin(typeid(U))`
* `ci.begin<U>()==c.cbegin<U>()`
* `ci.cbegin<U>()==c.cbegin<U>()`
* `ci.end()==c.cend(typeid(U))`
* `ci.cend()==c.cend(typeid(U))`
* `ci.end<U>()==c.cend<U>()`
* `ci.cend<U>()==c.cend<U>()`
* `ci.type_info()==typeid(U)`
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info]
[def _base_segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info `base_segment_info`]]
`C::base_segment_info`
_CopyConstructible_ and _CopyAssignable_ type publicly derived from
`C::const_base_segment_info` and exposing its public interface. Additionally,
if `i` is an object of type `C::base_segment_info` associated to the
segment of `c` for `U`, then
* `i.begin()==c.begin(typeid(U))`
* `i.begin<U>()==c.begin<U>()`
* `i.end()==c.end(typeid(U))`
* `i.end<U>()==c.end<U>()`
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_info]
[def _const_segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_info `const_segment_info`]]
`C::const_segment_info<U>`
_CopyConstructible_ and _CopyAssignable_ type with information about the segment
for `U`. If `ci` is a possibly `const` object of type `C::const_segment_info<U>`
associated to the collection `c`, then
* `ci.begin()==c.cbegin<U>()`
* `ci.cbegin()==c.cbegin<U>()`
* `ci.end()==c.cend<U>()`
* `ci.cend()==c.cend<U>()`
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_info]
[def _segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_info `segment_info`]]
`C::segment_info<U>`
_CopyConstructible_ and _CopyAssignable_ type publicly derived from
`C::const_segment_info<U>` and exposing its public interface. Additionally,
if `i` is an object of type `C::segment_info<U>` associated to the collection
`c`, then
* `i.begin()==c.begin<U>()`
* `i.end()==c.end<U>()`
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info_iterator]
[def _base_segment_info_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info_iterator `base_segment_info_iterator`]]
`C::base_segment_info_iterator`
_InputIterator_ with value type and reference type `C::base_segment_info`.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info_iterator]
[def _const_base_segment_info_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info_iterator `const_base_segment_info_iterator`]]
`C::const_base_segment_info_iterator`
_InputIterator_ with value type and reference type `C::const_base_segment_info`.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_traversal_info]
[def _const_segment_traversal_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_traversal_info `const_segment_traversal_info`]]
`C::const_segment_traversal_info`
_CopyConstructible_ and _CopyAssignable_ type with `const` member
functions `begin`/`cbegin` and `end`/`cend` returning
`C::const_base_segment_info_iterator` objects that span over a range
of `C::const_base_segment_info` objects.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_traversal_info]
[def _segment_traversal_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_traversal_info `segment_traversal_info`]]
`C::segment_traversal_info`
_CopyConstructible_ and _CopyAssignable_ type publicly derived
from with `C::const_segment_traversal_info` and exposing its
public interface. Additionally, provides non-const member
functions `begin` and `end` returning
`C::base_segment_info_iterator` objects that span over an equivalent range
of `C::base_segment_info` objects.
[endsect]
[section Construct/copy/destroy]
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.construct_copy_destroy.range_construction]
`C(j1,j2)`[br]
`C d(j1,j2)`
[*Requires:] `C::allocator_type` is _DefaultConstructible_. \[`j1`, `j2`) can be
inserted into `C`.[br]
[*Effects:] Copy constructs the internal allocator from `C::allocator_type()`.
Internally calls `this->insert(j1,j2)` on construction.
`C(j1,j2,al)`[br]
`C d(j1,j2,al)`
[*Requires:] \[`j1`, `j2`) can be inserted into `C`.[br]
[*Effects:] Copy constructs the internal allocator from `al`.
Internally calls `this->insert(j1,j2)` on construction.
[endsect]
[section Type registration]
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.register_types]
[def _register_types_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.register_types `register_types`]]
`c.register_types<Us...>()`
[*Effects:] Registers (if needed) each of the indicated types in the
collection.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.is_registered]
[def _is_registered_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.is_registered `is_registered`]]
`cc.is_registered(info)`[br]
`cc.is_registered<U>()`
[*Returns:] `true` iff the indicated type is registered in the collection.
[endsect]
[section Iterators]
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.begin]
[def _begin_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.begin `begin`]]
[def _cbegin_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.begin `cbegin`]]
(1) `c.begin(info)`[br]
(2) `c.begin<U>()`[br]
(3) `const_cast<const C&>(c).begin(info)`[br]
(4) `cc.cbegin(info)`[br]
(5) `const_cast<const C&>(c).begin<U>()`[br]
(6) `cc.cbegin<U>()`
[*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) or
`const_local_base_iterator` (3,4) or `const_local_iterator<U>` (5,6) to the
beginning of the segment for the indicated type.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.end]
[def _end_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.end `end`]]
[def _cend_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.end `cend`]]
(1) `c.end(info)`[br]
(2) `c.end<U>()`[br]
(3) `const_cast<const C&>(c).end(info)`[br]
(4) `cc.cend(info)`[br]
(5) `const_cast<const C&>(c).end<U>()`[br]
(6) `cc.cend<U>()`
[*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) or
`const_local_base_iterator` (3,4) or `const_local_iterator<U>` (5,6) to the
end of the segment for the indicated type.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment]
[def _segment_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment `segment`]]
(1) `c.segment(info)`[br]
(2) `c.segment<U>()`[br]
(3) `const_cast<const C&>(c).segment(info)`[br]
(4) `const_cast<const C&>(c).segment<U>()`[br]
[*Returns:] A `base_segment_info` (1) or `segment_info<U>` (2) or
`const_base_segment_info` (3) or `const_segment_info<U>` (4) object
referring to the segment for the indicated type.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment_traversal]
[def _segment_traversal_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment_traversal `segment_traversal`]]
(1) `c.segment_traversal()`[br]
(2) `const_cast<const C&>(c).segment_traversal()`
[*Returns:] A `segment_traversal_info` (1) or `const_segment_traversal_info`
(2) object spanning over a range of segment descriptors for the collection.
The order in which segments are visited matches that of
\[`c.begin()`, `c.end()`).
[endsect]
[section Capacity]
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.empty]
[def _empty_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.empty `empty`]]
`cc.empty(info)`[br]
`cc.empty<U>()`
[*Returns:] `true` iff the segment for the indicated type exists and
is empty.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.size]
[def _size_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.size `size`]]
`cc.size(info)`[br]
`cc.size<U>()`
[*Returns:] The size of the segment for the indicated type.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.max_size]
[def _max_size_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.max_size `max_size`]]
`cc.max_size(info)`[br]
`cc.max_size<U>()`
[*Returns:] The maximum size attainable by the segment for
the indicated type.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.capacity]
[def _capacity_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.capacity `capacity`]]
`cc.capacity(info)`[br]
`cc.capacity<U>()`[br]
[*Returns:] The maximum size that the segment for the indicated type can
attain without requiring reallocation.[br]
[*Throws:] If the indicated type is not registered.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.reserve]
[def _reserve_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.reserve `reserve`]]
`c.reserve(n)`
[*Effects:] Calls `reserve` with `n` for each of the segments of the
collection.
(1) `c.reserve(info,n)`[br]
(2) `c.reserve<U>(n)`
[*Effects:] Throws if the type indicated by `info` is not registered (1)
or registers `U` if needed (2). If `n` is greater than the current
capacity of the segment for the indicated type, new storage space is allocated
with a capacity of at least `n` and elements are moved there.[br]
[*Complexity:] Linear in the size of the segment if reallocation happens,
constant otherwise.[br]
[*Throws:] `std::length_error` if `n` is greater than the return value of
`max_size` for the segment.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.shrink_to_fit]
[def _shrink_to_fit_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.shrink_to_fit `shrink_to_fit`]]
`c.shrink_to_fit()`
[*Effects:] Calls `shrink_to_fit` for each of the segments of the
collection.
`c.shrink_to_fit(info)`[br]
`c.shrink_to_fit<U>()`
[*Effects:] Non-binding request to reduce memory usage while preserving the
sequence of elements of the segment for the indicated type. May invalidate
all iterators and references to the segment.[br]
[*Throws:] If the indicated type is not registered.
[endsect]
[section Modifiers]
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace]
[def _emplace_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace `emplace`]]
[def _emplace_hint_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace `emplace_hint`]]
(1) `c.emplace<U>(args...)`[br]
(2) `c.emplace_hint<U>(it,args...)`
[*Requires:] `U` is constructible from `std::forward<Args>(args)...`.[br]
[*Effects:] Registers `U` (if needed) and inserts a new element with
a subobject constructed from `std::forward<Args>(args)...`: (1) at the end of
the segment for `U`; (2) just before the
position indicated by `it`, if it points to the segment for `U`, or at the
end of the segment for `U` otherwise.[br]
[*Returns:] An `iterator` to the newly inserted element.[br]
[*Complexity:] Amortized constant time plus linear in the distance from the
insertion position to the end of the segment.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace_pos]
[def _emplace_pos_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace_pos `emplace_pos`]]
(1) `c.emplace_pos<U>(lbit,args...)`[br]
(2) `c.emplace_pos(lit,args...)`
[*Requires:] `U` is constructible from `std::forward<Args>(args)...`.
(1) `lbit` points to the segment for `U`.[br]
[*Effects:] Inserts a new element with
a subobject constructed from `std::forward<Args>(args)...` just before the
position indicated.[br]
[*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) to the
newly inserted element.[br]
[*Complexity:] Amortized constant time plus linear in the distance from
the insertion position to the end of the segment.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert]
[def _insert_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert `insert`]]
[def _insert_hint_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert `insert`]]
(1) `c.insert(x)`[br]
(2) `c.insert(it,x)`
[*Effects:] Let `Q` be the type of the subobject of `x`. If
`Q` = `T` and `T` is acceptable, registers `T` if needed.
If `Q` = `T` and `T` is not acceptable, throws.
If `Q` \u2260 `T` and `Q` is not registered, throws.
If `x` is not a non-const rvalue expression and `Q` is not _CopyConstructible_, throws.
Inserts an element with a subobject move constructed or copy constructed
from the subobject of `x`: (1) at the end of the corresponding segment;
(2) just before the position indicated by `it`, if it points to the
corresponding segment, or at the end of the segment otherwise.[br]
[*Returns:] An `iterator` to the newly inserted element.[br]
[*Complexity:] Amortized constant time plus linear in the distance
from the insertion position to the end of the segment.
(1) `c.insert(lbit,x)`[br]
(2) `c.insert(lit,x)`
[*Requires:] The type of the subobject of `x` corresponds to the indicated
segment.[br]
[*Effects:] Inserts an element with a subobject move constructed or copy
constructed from the subobject of `x` just before the
position indicated.[br]
[*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) to the
newly inserted element.[br]
[*Complexity:] Amortized constant time plus linear in the distance
from the insertion position to the end of the segment.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_range]
[def _insert_range_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_range `insert`]]
`c.insert(i1,i2)`
[*Effects:] Equivalent to `while(i1!=i2)c.insert(*i1++)`.
`c.insert(it1,it2)`[br]
`c.insert(lbit1,lbit2)`[br]
`c.insert(lit1,lit2)`
[*Effects:] For each of the elements of the range in succession, registers the
type of its subobject if needed and inserts it into the collection
[footnote Note that, unlike `c.insert(i1,i2)`, these versions do not throw
due to type registration problems.].
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_hint_range]
[def _insert_hint_range_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_hint_range `insert`]]
`c.insert(it,i1,i2)`
[*Effects:] If `it==c.end()`, equivalent to `while(i1!=i2)c.insert(it,*i1++)`,
otherwise inserts each of the elements in \[`i1`, `i2`) in succession with a hint
pointing to `*it`
[footnote That is, the hint remains stable even if `it` may become invalid due
to reallocations.].
`c.insert(it,it1,it2)`[br]
`c.insert(it,lbit1,lbit2)`[br]
`c.insert(it,lit1,lit2)`
[*Effects:] If `it==c.end()`, equivalent to the corresponding hint-less version,
otherwise for each of the elements in \[`i1`, `i2`) in succession registers the
type of its subobject if needed and inserts it into the collection with a hint
pointing to `*it`
[footnote The two previous notes apply here.].
`c.insert(lbit,i1,i2)`
[*Requires:] The subojects of elements in \[`i1`, `i2`) are all of the type
corresponding to the indicated segment.[br]
[*Effects:] Inserts a range of elements with subobjects copy constructed from
those in \[`i1`, `i2`) just before `lbit`.[br]
[*Returns:] A `local_base_iterator` to the beginning of the inserted range.
`c.insert(lit,j1,j2)`
[*Requires:] For each value `x` in \[`j1`, `j2`) either (a) `x` is of a type
implementing the interface associated to the collection and the subobject of
`x` is of type `U` or (b) `U` is constructible from `x`.[br]
[*Effects:] Inserts a range of elements with subobjects copy
constructed (a) or constructed (b) from the values in \[`j1`, `j2`)
just before `lit`.[br]
[*Returns:] A `local_iterator<U>` to the beginning of the inserted range.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.erase]
[def _erase_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.erase `erase`]]
`c.erase(xit1)`[br]
`c.erase(xit1,xit2)`
[*Effects:] Erases the indicated element(s).[br]
[*Returns:] A non-const iterator of the same category as `xit` pointing
to the position just after the erased element(s).[br]
[*Complexity:] Linear on the number of elements erased plus the distance
from the last one to the end of its segment.
[#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.clear]
[def _clear_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.clear `clear`]]
`c.clear()`
[*Effects:] Erases all the elements of the container.[br]
[*Complexity:] Linear.
`c.clear(info)`[br]
`c.clear<U>()`
[*Effects:] Erases all the elements of the segment for the indicated type.[br]
[*Complexity:] Linear in the size of the segment.[br]
[*Throws:] If the indicated type is not registered.
[endsect]
[endsect]
[endsect]
[import poly_collection_synopsis.qbk] [/ template poly_collection_synopsis]
[section Header `"boost/poly_collection/exception.hpp"` synopsis]
All the collections in Boost.PolyCollection use the following exceptions
(and only these) to signal various run-time problems with contained types:
namespace boost{
namespace poly_collection{
struct ``[link poly_collection.reference.header_boost_poly_collection_exc.class_unregistered_type unregistered_type]``;
struct ``[link poly_collection.reference.header_boost_poly_collection_exc.class_not_copy_constructible not_copy_constructible]``;
struct ``[link poly_collection.reference.header_boost_poly_collection_exc.class_not_equality_comparable not_equality_comparable]``;
} /* namespace poly_collection */
} /* namespace boost */
[section Class `unregistered_type`]
struct unregistered_type:std::logic_error
{
unregistered_type(const std::type_info& info);
const std::type_info* pinfo;
};
`unregistered_type` is thrown when an operation is requested on a type which
does not yet have an associated segment.
`unregistered_type(const std::type_info& info);`
[*Effects:] Constructs an `unregistered_type` object with the specified type
information.
[endsect]
[section Class `not_copy_constructible`]
struct not_copy_constructible:std::logic_error
{
not_copy_constructible(const std::type_info& info);
const std::type_info* pinfo;
};
`not_copy_constructible` is thrown when a copy operation is tried that
involves a non-_CopyConstructible_ type.
`not_copy_constructible(const std::type_info& info);`
[*Effects:] Constructs a `not_copy_constructible` object with the specified
type information.
[endsect]
[section Class `not_equality_comparable`]
struct not_equality_comparable:std::logic_error
{
not_equality_comparable(const std::type_info& info);
const std::type_info* pinfo;
};
`not_equality_comparable` is thrown when comparing two collections
for (in)equality involves a non-_EqualityComparable_ type.
`not_equality_comparable(const std::type_info& info);`
[*Effects:] Constructs a `not_equality_comparable` object with the specified
type information.
[endsect]
[endsect]
[section Header `"boost/poly_collection/base_collection_fwd.hpp"` synopsis]
[def _base_collection_ [link poly_collection.reference.header_boost_poly_collection_ba0.class_template_base_collection `base_collection`]]
#include <memory>
namespace boost{
namespace poly_collection{
template<typename Base,typename Allocator=std::allocator<Base>>
class _base_collection_;
template<typename Base,typename Allocator>
bool operator==(
const base_collection<Base,Allocator>& x,
const base_collection<Base,Allocator>& y);
template<typename Base,typename Allocator>
bool operator!=(
const base_collection<Base,Allocator>& x,
const base_collection<Base,Allocator>& y);
template<typename Base,typename Allocator>
void swap(
base_collection<Base,Allocator>& x,base_collection<Base,Allocator>& y);
} /* namespace poly_collection */
using poly_collection::base_collection;
} /* namespace boost */
Forward declares the class template _base_collection_
and specifies its default template arguments. Forward declares associated free
functions and brings `boost::poly_collection::base_collection` to the `boost`
namespace.
[endsect]
[section Header `"boost/poly_collection/base_collection.hpp"` synopsis]
#include <boost/poly_collection/base_collection_fwd.hpp>
namespace boost{
namespace poly_collection{
template<typename Base,typename Allocator>
class _base_collection_;
template<typename Base,typename Allocator>
bool operator==(
const base_collection<Base,Allocator>& x,
const base_collection<Base,Allocator>& y);
template<typename Base,typename Allocator>
bool operator!=(
const base_collection<Base,Allocator>& x,
const base_collection<Base,Allocator>& y);
template<typename Base,typename Allocator>
void swap(
base_collection<Base,Allocator>& x,base_collection<Base,Allocator>& y);
} /* namespace poly_collection */
} /* namespace boost */
[section Class template `base_collection`]
`base_collection<Base,Allocator>` is a _PolymorphicCollection_ associated to
the classic base/derived _polymorphism_model_:
* *Interface* = { `Base` : `std::is_polymorphic_v<Base>` }.
* *Implementation*(`Base`) = { `Derived` : `std::is_base_of_v<Base,Derived>` }.
* *subobject*(`x`) = `static_cast<Derived&>(x)` with `typeid(x)==typeid(Derived)`.
[poly_collection_synopsis `base_collection`..`template<typename Base,typename Allocator>`..`Base`]
[endsect]
[endsect]
[section Header `"boost/poly_collection/function_collection_fwd.hpp"` synopsis]
[def _function_collection_ [link poly_collection.reference.header_boost_poly_collection_fu0.class_template_function_collecti `function_collection`]]
[def _function_collection_value_type_ [link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti `function_collection_value_type`]]
#include <memory>
namespace boost{
namespace poly_collection{
template<typename Signature>
using _function_collection_value_type_=``/implementation-defined/``;
template<
typename Signature,
typename Allocator=std::allocator<function_collection_value_type<Signature>>
>
class _function_collection_;
template<typename Signature,typename Allocator>
bool operator==(
const function_collection<Signature,Allocator>& x,
const function_collection<Signature,Allocator>& y);
template<typename Signature,typename Allocator>
bool operator!=(
const function_collection<Signature,Allocator>& x,
const function_collection<Signature,Allocator>& y);
template<typename Signature,typename Allocator>
void swap(
function_collection<Signature,Allocator>& x,
function_collection<Signature,Allocator>& y);
} /* namespace poly_collection */
using poly_collection::function_collection;
} /* namespace boost */
Defines the alias template _function_collection_value_type_ (the actual type
it refers to, though, is merely forward declared).
Forward declares the class template _function_collection_
and specifies its default template arguments. Forward declares associated free
functions and brings `boost::poly_collection::function_collection` to the
`boost` namespace.
[endsect]
[section Header `"boost/poly_collection/function_collection.hpp"` synopsis]
#include <boost/poly_collection/function_collection_fwd.hpp>
namespace boost{
namespace poly_collection{
// defines the type ``_function_collection_value_type_`` refers to
template<typename Signature,typename Allocator>
class _function_collection_;
template<typename Signature,typename Allocator>
bool operator==(
const function_collection<Signature,Allocator>& x,
const function_collection<Signature,Allocator>& y);
template<typename Signature,typename Allocator>
bool operator!=(
const function_collection<Signature,Allocator>& x,
const function_collection<Signature,Allocator>& y);
template<typename Signature,typename Allocator>
void swap(
function_collection<Signature,Allocator>& x,
function_collection<Signature,Allocator>& y);
} /* namespace poly_collection */
} /* namespace boost */
[section Alias template `function_collection_value_type`]
`function_collection_value_type<Signature>` is the `value_type` of
`boost::function_collection<Signature,Allocator>`, where `Signature` must be a type
of the form `R(Args...)`. `function_collection_value_type<Signature>` wraps a
reference to an object modeling _Callable_ for the given `Signature`. The
interface provided partially replicates that of _std::function_ and adds some
extra facilities.
In what follows, the name [' `function_collection_value_type_impl`]
is used just for explanatory purposes in place of the actual
class template name, which is implementation defined.
template<typename Signature>
using function_collection_value_type=
``/function_collection_value_type_impl/``<Signature>;
template<typename Signature>
class ``/function_collection_value_type_impl/``;
template<typename R,typename... Args>
class ``/function_collection_value_type_impl/``<R(Args...)>
{
public:
explicit ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_bool operator bool]``()const noexcept;
R ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_call operator()]``(Args... args)const;
const std::type_info& ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target_type target_type]``()const noexcept;
template<typename T> T* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target target]``()noexcept;
template<typename T> const T* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target target]``()const noexcept;
operator ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_std_function std::function<R(Args...)>]``()const noexcept;
void* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.data data]``()noexcept;
const void* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.data data]``()const noexcept;
};
[#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_bool]
`explicit operator bool()const noexcept;`
[*Returns:] `true`.
[#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_call]
`R operator()(Args... args)const;`
[*Effects:] `_INVOKE_(f,std::forward<Args>(args)...,R)`, where f is the wrapped
callable object.[br]
[*Returns:] Nothing if `R` is `void`, otherwise the return value of
`_INVOKE_(f,std::forward<Args>(args)...,R)`.
[#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target_type]
`const std::type_info& target_type()const noexcept;`
[*Returns:] `typeid(T)` where `T` is the type of the wrapped callable object.
[#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target]
`template<typename T> T* target()noexcept;`[br]
`template<typename T> const T* target()const noexcept;`
[*Returns:] If `target_type()==typeid(T)` a pointer to the wrapped callable
object, otherwise `nullptr`.
[#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_std_function]
`operator std::function<R(Args...)>()const noexcept;`
[*Returns:] A `std::function<R(Args...)>` object holding a reference to the
wrapped callable object.
[#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.data]
`void* data()noexcept;`[br]
`const void* data()const noexcept;`
[*Returns:] The address of the wrapped callable object.
[endsect]
[section Class template `function_collection`]
`function_collection<Signature,Allocator>` is a _PolymorphicCollection_ associated to
a dynamic _polymorphism_model_ based on call signature compatibility:
[itemized_list
[*Interface* = { `Signature` : `Signature` = `R(Args...)` }.]
[*Implementation*(`Signature`) = { `Callable` : `std::is_invocable_r_v<R,Callable,Args...>` }.]
[*subobject*(`x`) =[br]
`x.target<T>()` with `typeid(T)==x.target_type()`, if `x` is an instantiation of _function_collection_value_type_,[br]
`x`, otherwise.
]
]
[poly_collection_synopsis `function_collection`..`template<typename Signature,typename Allocator>`..`_function_collection_value_type_<Signature>`]
[endsect]
[endsect]
[section Header `"boost/poly_collection/any_collection_fwd.hpp"` synopsis]
[def _any_collection_ [link poly_collection.reference.header_boost_poly_collection_an0.class_template_any_collection `any_collection`]]
[def _any_collection_value_type_ [link poly_collection.reference.header_boost_poly_collection_an0.alias_template_any_collection_va `any_collection_value_type`]]
#include <memory>
namespace boost{
namespace poly_collection{
template<typename Concept>
using _any_collection_value_type_=``/implementation-defined/``;
template<
typename Concept,
typename Allocator=std::allocator<any_collection_value_type<Concept>>
>
class _any_collection_;
template<typename Concept,typename Allocator>
bool operator==(
const any_collection<Concept,Allocator>& x,
const any_collection<Concept,Allocator>& y);
template<typename Concept,typename Allocator>
bool operator!=(
const any_collection<Concept,Allocator>& x,
const any_collection<Concept,Allocator>& y);
template<typename Concept,typename Allocator>
void swap(
any_collection<Concept,Allocator>& x,any_collection<Concept,Allocator>& y);
} /* namespace poly_collection */
using poly_collection::any_collection;
} /* namespace boost */
Defines the alias template _any_collection_value_type_ (the actual type
it refers to, though, is merely forward declared).
Forward declares the class template _any_collection_
and specifies its default template arguments. Forward declares associated free
functions and brings `boost::poly_collection::any_collection` to the
`boost` namespace.
[endsect]
[section Header `"boost/poly_collection/any_collection.hpp"` synopsis]
#include <boost/poly_collection/any_collection_fwd.hpp>
namespace boost{
namespace poly_collection{
// defines the type ``_any_collection_value_type_`` refers to
template<typename Concept,typename Allocator>
class _any_collection_;
template<typename Concept,typename Allocator>
bool operator==(
const any_collection<Concept,Allocator>& x,
const any_collection<Concept,Allocator>& y);
template<typename Concept,typename Allocator>
bool operator!=(
const any_collection<Concept,Allocator>& x,
const any_collection<Concept,Allocator>& y);
template<typename Concept,typename Allocator>
void swap(
any_collection<Concept,Allocator>& x,any_collection<Concept,Allocator>& y);
} /* namespace poly_collection */
} /* namespace boost */
[section Alias template `any_collection_value_type`]
`any_collection_value_type<Concept>` is the `value_type` of
`boost::any_collection<Concept,Allocator>`, where `Concept` is defined according to
the [@boost:/doc/html/boost_typeerasure/conceptdef.html requisites]
of _Boost.TypeErasure_ using
[@boost:/doc/html/boost/type_erasure/_self.html `_self`]
as its [@boost:/doc/html/boost/type_erasure/placeholder.html placeholder].
The alias template definition has the form
template<typename Concept>
using any_collection_value_type=
boost::type_erasure::``[@boost:/doc/html/boost/type_erasure/any.html any]``<Concept2,boost::type_erasure::_self&>;
with `boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/is_subconcept.html `is_subconcept`]`<Concept,Concept2>::value==true`.
The exact definition of `Concept2` is implementation defined.
[endsect]
[section Class template `any_collection`]
`any_collection<Concept,Allocator>` is a _PolymorphicCollection_ associated to
a dynamic _polymorphism_model_ based on _duck_typing_ as implemented by
_Boost.TypeErasure_:
[itemized_list
[*Interface* = { `Concept` :
as [@boost:/doc/html/boost_typeerasure/conceptdef.html specified] by _Boost.TypeErasure_,
using the [@boost:/doc/html/boost/type_erasure/_self.html `_self`]
[@boost:/doc/html/boost/type_erasure/placeholder.html placeholder] }.]
[*Implementation*(`Concept`) = { `Concrete` : `Concrete` satisfies `Concept` }.]
[*subobject*(`x`) =[br]
`boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/any_cast.html `any_cast`]`<T&>(x)`
with `typeid(T)==boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/typeid_of.html `typeid_of`]`(x)`,
if `x` is an instantiation of `boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/any.html `any`]
including [@boost:/doc/html/boost/type_erasure/typeid_.html `typeid_`]`<>`,[br]
`x`, otherwise.
]
]
[poly_collection_synopsis `any_collection`..`template<typename Concept,typename Allocator>`..`_any_collection_value_type_<Concept>`]
[endsect]
[endsect]
[section Header `"boost/poly_collection/algorithm.hpp"` synopsis]
namespace boost{
namespace poly_collection{
``['`// non-modifying sequence operations:`]``
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
bool all_of(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
bool any_of(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
bool none_of(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<typename... Ts,typename PolyCollectionIterator,typename Function>
Function for_each(
PolyCollectionIterator first,PolyCollectionIterator last,Function f);
template<
typename... Ts,typename PolyCollectionIterator,
typename Size,typename Function
>
Iterator for_each_n(
PolyCollectionIterator first,Size n,Function f);
template<typename... Ts,typename PolyCollectionIterator,typename T>
PolyCollectionIterator find(
PolyCollectionIterator first,PolyCollectionIterator last,const T& x);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
PolyCollectionIterator find_if(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
PolyCollectionIterator find_if_not(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
>
PolyCollectionIterator find_end(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2);
template<
typename... Ts,typename PolyCollectionIterator,
typename ForwardIterator,typename BinaryPredicate
>
PolyCollectionIterator find_end(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
>
PolyCollectionIterator find_first_of(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2);
template<
typename... Ts,typename PolyCollectionIterator,
typename ForwardIterator,typename BinaryPredicate
>
PolyCollectionIterator find_first_of(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
template<typename... Ts,typename PolyCollectionIterator>
PolyCollectionIterator adjacent_find(
PolyCollectionIterator first,PolyCollectionIterator last);
template<
typename... Ts,typename PolyCollectionIterator,typename BinaryPredicate
>
PolyCollectionIterator adjacent_find(
PolyCollectionIterator first,PolyCollectionIterator last,
BinaryPredicate pred);
template<typename... Ts,typename PolyCollectionIterator,typename T>
std::ptrdiff_t count(
PolyCollectionIterator first,PolyCollectionIterator last,const T& x);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
std::ptrdiff_t count_if(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename InputIterator
>
std::pair<PolyCollectionIterator,InputIterator> mismatch(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2);
template<
typename... Ts,typename PolyCollectionIterator,
typename InputIterator,typename BinaryPredicate
>
std::pair<PolyCollectionIterator,InputIterator> mismatch(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename InputIterator
>
std::pair<PolyCollectionIterator,InputIterator> mismatch(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,InputIterator last2);
template<
typename... Ts,typename PolyCollectionIterator,
typename InputIterator,typename BinaryPredicate
>
std::pair<PolyCollectionIterator,InputIterator> mismatch(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,InputIterator last2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename InputIterator
>
bool equal(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2);
template<
typename... Ts,typename PolyCollectionIterator,
typename InputIterator,typename BinaryPredicate
>
bool equal(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename InputIterator
>
bool equal(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,InputIterator last2);
template<
typename... Ts,typename PolyCollectionIterator,
typename InputIterator,typename BinaryPredicate
>
bool equal(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,InputIterator last2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
>
bool is_permutation(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2);
template<
typename... Ts,typename PolyCollectionIterator,
typename ForwardIterator,typename BinaryPredicate
>
bool is_permutation(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
>
bool is_permutation(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2);
template<
typename... Ts,typename PolyCollectionIterator,
typename ForwardIterator,typename BinaryPredicate
>
bool is_permutation(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
>
PolyCollectionIterator search(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2);
template<
typename... Ts,typename PolyCollectionIterator,
typename ForwardIterator,typename BinaryPredicate
>
PolyCollectionIterator search(
PolyCollectionIterator first1,PolyCollectionIterator last1,
ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename Size,typename T
>
PolyCollectionIterator search_n(
PolyCollectionIterator first1,PolyCollectionIterator last1,
Size count,const T& x);
template<
typename... Ts,typename PolyCollectionIterator,
typename Size,typename T,typename BinaryPredicate
>
PolyCollectionIterator search_n(
PolyCollectionIterator first1,PolyCollectionIterator last1,
Size count,const T& x,BinaryPredicate pred);
``['`// modifying sequence operations:`]``
template<
typename... Ts,typename PolyCollectionIterator,typename OutputIterator
>
OutputIterator copy(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res);
template<
typename... Ts,typename PolyCollectionIterator,
typename Size,typename OutputIterator
>
OutputIterator copy_n(
PolyCollectionIterator first,Size count,OutputIterator res);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename Predicate
>
OutputIterator copy_if(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,Predicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename OutputIterator
>
OutputIterator move(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename UnaryOperation
>
OutputIterator transform(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,UnaryOperation op);
template<
typename... Ts,typename PolyCollectionIterator,
typename InputIterator,typename OutputIterator,typename BinaryOperation
>
OutputIterator transform(
PolyCollectionIterator first1,PolyCollectionIterator last1,
InputIterator first2,OutputIterator res,BinaryOperation op);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename T
>
OutputIterator replace_copy(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,const T& old_x,const T& new_x);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename Predicate,typename T
>
OutputIterator replace_copy_if(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,Predicate pred,const T& new_x);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename T
>
OutputIterator remove_copy(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,const T& x);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename Predicate
>
OutputIterator remove_copy_if(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,Predicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename OutputIterator
>
OutputIterator unique_copy(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator,typename BinaryPredicate
>
OutputIterator unique_copy(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,BinaryPredicate pred);
template<
typename... Ts,typename PolyCollectionIterator,typename OutputIterator
>
OutputIterator rotate_copy(
PolyCollectionIterator first,PolyCollectionIterator middle,
PolyCollectionIterator last,OutputIterator res);
template<
typename... Ts,typename PolyCollectionIterator,typename OutputIterator,
typename Distance,typename UniformRandomBitGenerator
>
OutputIterator sample(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator res,Distance n,UniformRandomBitGenerator&& g);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
bool is_partitioned(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
template<
typename... Ts,typename PolyCollectionIterator,
typename OutputIterator1,typename OutputIterator2,typename Predicate
>
std::pair<OutputIterator1,OutputIterator2> partition_copy(
PolyCollectionIterator first,PolyCollectionIterator last,
OutputIterator1 rest,OutputIterator2 resf,Predicate pred);
template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
PolyCollectionIterator partition_point(
PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
} /* namespace poly_collection */
} /* namespace boost */
The algorithms provided mimic the functionality of their homonyms in
[@http://en.cppreference.com/w/cpp/algorithm `<algorithm>`] but take advantage
of the segmented nature of Boost.PolyCollection (global) iterators to
deliver better performance. Additionally, concrete types can be passed to
these algorithms for /type restitution/.
For the description of the algorithms we use the following notation:
* [' `alg`] is the (unqualified) name of any of the algorithms in
`"boost/poly_collection/algorithm.hpp"` except `copy_n` and `rotate_copy`.
* `first`, `middle` and `last` are (same-typed) possibly const global iterators
of a collection of Boost.PolyCollection such that \[`first`, `middle`) and
\[`middle`, `last`) are valid ranges.
* `args...` is a function parameter pack of types `Args&&...`,
* `Ts...` is a template parameter pack of arbitrary types.
(1) [' `alg`]`(first,last,args...)`[br]
(2) `for_each_n(first,args...)`[br]
(3) `copy_n(first,args...)`[br]
(4) `rotate_copy(first,middle,last,args...)`
[*Requires:] The expression `expr` is well-formed, where `expr` is defined
as:[br]
(1) `std::`[' `alg`]`(first,last,args...)`,[br]
(2) `std::for_each_n(first,args...)`,[br]
(3) `std::copy_n(first,args...)`,[br]
(4) `std::rotate_copy(first,middle,last,args...)`.[br]
[*Effects:] Equivalent to `expr`.[br]
[*Returns:] `expr`.[br]
[*Complexity:] That of `expr`.
(1) [' `alg`]`<Ts...>(first,last,args...)`[br]
(2) `for_each_n<Ts...>(first,args...)`[br]
(3) `copy_n<Ts...>(first,args...)`[br]
(4) `rotate_copy<Ts...>(first,middle,last,args...)`
[*Requires:] The expression `expr` is well-formed, where `expr` is defined
as:[br]
(1) `std::`[' `alg`]`(rfirst,rlast,args...)`,[br]
(2) `std::for_each_n(rfirst,args...)`,[br]
(3) `std::copy_n(rfirst,args...)`,[br]
(4) `std::rotate_copy(rfirst,rmiddle,rlast,args...)`,[br]
and `rfirst`, `rmiddle` and `rlast` are iterator-like objects behaving like
their `first`, `middle` and `last` counterparts except that they
dereference to the corresponding subobject (`const`) `T&` if pointing to a
segment for `T` and `T` is in `Ts...`
[footnote Strictly speaking a proper _ForwardIterator_ cannot behave
like this as dereferencing must yield /exactly/ a (`const`) `value_type&`
value, which disallows this type of polymorphism.].[br]
[*Effects:] Equivalent to `expr`.[br]
[*Returns:] `expr`.[br]
[*Complexity:] That of `expr`.
[endsect]
[endsect]
|