mirror of
https://github.com/boostorg/unordered.git
synced 2026-08-07 14:14:07 +02:00
Compare commits
515 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf0f90ff03 | |||
| 7c6f1ef227 | |||
| 99985bb1b2 | |||
| 8c5aa5086d | |||
| b1232d8061 | |||
| 2f6b81d8c1 | |||
| e1b39bbbfb | |||
| 6b7cecb9d3 | |||
| 79dcf7cbe8 | |||
| d4702754b7 | |||
| 98d90f26d7 | |||
| b97ceb6442 | |||
| c18c645b92 | |||
| 15cb6d7d1b | |||
| 2f5d98a0cd | |||
| 2216c987a0 | |||
| 86d4d21250 | |||
| 3eb2355182 | |||
| 9440395330 | |||
| 034f2c3779 | |||
| e93f5b0971 | |||
| 8c6f3e910b | |||
| 78bd2c0736 | |||
| 4e6ce91dd0 | |||
| 850d69738b | |||
| 9c62f83e74 | |||
| 99fdce0b4d | |||
| 06b6418044 | |||
| 57819d1dd9 | |||
| 80f3376894 | |||
| 94071cc6e8 | |||
| 038550a9df | |||
| 9ca8c691ac | |||
| a4881436d2 | |||
| 70190b3aa2 | |||
| 8ae166a2c3 | |||
| 7d0c6d2425 | |||
| 5995e5521f | |||
| 59c83ab942 | |||
| 0a552a47cb | |||
| 3b5cf359e7 | |||
| 239453bead | |||
| bea92e8842 | |||
| ddab816ed7 | |||
| 007ddb9a5a | |||
| 6b1a4bfeb7 | |||
| 6ca8d5e0d9 | |||
| 6f3dee13a8 | |||
| 7f14796ba4 | |||
| cfb4a9d254 | |||
| 621c1523c0 | |||
| b4d62e4670 | |||
| 3922d1bb63 | |||
| 9b9a1d21a6 | |||
| 033a611f71 | |||
| 3aa91346ea | |||
| a7c0ddb5b3 | |||
| de0366105c | |||
| 3508ceaa58 | |||
| 29660f9c4d | |||
| 52b42b4e48 | |||
| c88126e1d2 | |||
| e6a6fe92d7 | |||
| 0c7c7cc6ad | |||
| fb93c8cb86 | |||
| 8f0126a13a | |||
| 0f080552fa | |||
| f8a6ea40a1 | |||
| 1a067034c1 | |||
| bd10a8b5aa | |||
| d603e75d03 | |||
| a422b40041 | |||
| 44f61e5878 | |||
| 27c4e90374 | |||
| 0221f1a9bd | |||
| 6b21eeccab | |||
| bf1f24ab04 | |||
| 34b69e67ee | |||
| 64994d76dd | |||
| 10049f8325 | |||
| 654fed166a | |||
| 1bd3b029fa | |||
| 3305caf40c | |||
| 85d2657ac1 | |||
| 8fb85cbb8d | |||
| da455124d2 | |||
| ef4d33ce89 | |||
| 7eefe62efe | |||
| 981f1e2acb | |||
| 73c0d85ae6 | |||
| d495cbd7e6 | |||
| ccc3d1c83d | |||
| 38d8d052d1 | |||
| 2e26534659 | |||
| d1a6e948e3 | |||
| 8f8ea09ce8 | |||
| 9b398ba0c9 | |||
| 556adc1de1 | |||
| 3f060a70d1 | |||
| d6322718f3 | |||
| 94ef1ac391 | |||
| 53f278312f | |||
| 549b93e629 | |||
| c2e7221bf9 | |||
| 37d58e84e3 | |||
| ec6219fe13 | |||
| e68f0c341e | |||
| f47f0f8d16 | |||
| ed369d6374 | |||
| b6b54610c6 | |||
| 1d03bbe213 | |||
| 32ab636fe8 | |||
| 8e5ffbbe6c | |||
| e7f495c094 | |||
| 1e07edc1ad | |||
| 2f09079d3f | |||
| a1bdd82bd5 | |||
| 45b6340a98 | |||
| 22e6daac6c | |||
| 9ea735c975 | |||
| 31f3a10d33 | |||
| d9f49f2b44 | |||
| 73c269398a | |||
| 7a4930f1a1 | |||
| c0faf59a86 | |||
| a822b27efc | |||
| f1e716d897 | |||
| 612d68eecd | |||
| aefea862c2 | |||
| f8968ab022 | |||
| 8f86c2464e | |||
| cd57bf5000 | |||
| a7125259d8 | |||
| 3a163b5449 | |||
| ff31c73970 | |||
| 2e11fd8a86 | |||
| 09c546f63a | |||
| 5be71a0e90 | |||
| 27f5496a65 | |||
| 918b3da91d | |||
| 61516be1db | |||
| 7c968fd38d | |||
| 4a066e4b18 | |||
| 0fccd93e29 | |||
| 6932a2d571 | |||
| f387994422 | |||
| 958b1d468f | |||
| f5292fd9f7 | |||
| ada08d9459 | |||
| 9a284b4106 | |||
| 98083078a3 | |||
| b8d96be8f7 | |||
| 68edec9f97 | |||
| 39bafd7b10 | |||
| 0acb4ee3e6 | |||
| 893ebc5adb | |||
| 7158700502 | |||
| 1eac47a275 | |||
| c6f0175c79 | |||
| 6031b66f99 | |||
| d863f17673 | |||
| 24c08646f4 | |||
| 6604abe600 | |||
| 39aed02e32 | |||
| 6b44f3b887 | |||
| cd88cb4a30 | |||
| 32dc45b7bd | |||
| 275b03e76b | |||
| 995ef1efdb | |||
| 8cb85937c4 | |||
| e615ac67c2 | |||
| 401df0f2fb | |||
| 531f6804ad | |||
| d5230a874b | |||
| 030fd55d02 | |||
| 626bb48013 | |||
| e64f82ed03 | |||
| c8c71d0ad1 | |||
| 4e759b4444 | |||
| 9f199eaa23 | |||
| 2fed2fbd9e | |||
| 29d63e378b | |||
| 8a1a475c58 | |||
| 08230efb44 | |||
| 2aee3add16 | |||
| f6b8d3957d | |||
| 992cc0b077 | |||
| 2f92b12205 | |||
| 2e80a82554 | |||
| 51d2e2564e | |||
| 2665090568 | |||
| d70fcb8c25 | |||
| ac0a2fe6c9 | |||
| 6c09b89d0c | |||
| 8f982c8b27 | |||
| a61e876300 | |||
| 684e40464f | |||
| 2507fd78e3 | |||
| 21f1fe8185 | |||
| aeea8e05ad | |||
| 11c9955902 | |||
| 9cb361f35e | |||
| c3477b2624 | |||
| a5dcc9dab0 | |||
| 6ebc2e72ff | |||
| d2a6ad8c72 | |||
| 087962c16e | |||
| 4471e056f4 | |||
| b56a5ead66 | |||
| e3befdba7f | |||
| 0cf8de5222 | |||
| b6a6f530c0 | |||
| 03245c80ff | |||
| 2775ae2f2e | |||
| 8557a30592 | |||
| fd530b87f6 | |||
| 674d635024 | |||
| f304e56818 | |||
| 5a2bf64a65 | |||
| f1b78931d1 | |||
| 3d7b6c64b5 | |||
| 597d93537d | |||
| 3a909c8747 | |||
| ad38ecf6d8 | |||
| dac1dc5837 | |||
| c0aaf908c0 | |||
| b1d782285c | |||
| b0620a46ff | |||
| 340c98d89a | |||
| 78241de393 | |||
| dbf7c9d6aa | |||
| 983ad956e0 | |||
| 45273ea6a5 | |||
| 9b82dcde10 | |||
| b496bc3fa2 | |||
| f8abb9633a | |||
| 76c37f7805 | |||
| 7d441864ec | |||
| ccd895a356 | |||
| 8ecdee5a93 | |||
| 70c39ad5ea | |||
| 96fc0fa3c2 | |||
| c101aec06c | |||
| bd79d02049 | |||
| 0ea847a64e | |||
| 965e25c989 | |||
| a3ffd4a7c9 | |||
| 41b9b8d841 | |||
| 26a47d33c1 | |||
| 1154b5729a | |||
| fd1aec2998 | |||
| 659b6fe8ba | |||
| ceef4d6521 | |||
| 86b077b9a1 | |||
| 28cdebe7a4 | |||
| d4087f64d9 | |||
| 4ec5a0eebd | |||
| f58a3fc3eb | |||
| 11562b3285 | |||
| 568fd1758d | |||
| f64b5ba3f8 | |||
| 395c744d6f | |||
| 155077cba0 | |||
| 4dcf34c264 | |||
| 4bf3b1bfc5 | |||
| 6bc99ac0c2 | |||
| 09e856562a | |||
| 5dd13dbfb3 | |||
| 9ae19a64d7 | |||
| bd13f2b1ad | |||
| d09bbba6c1 | |||
| 3f4d031c43 | |||
| 674b39243f | |||
| 099a893678 | |||
| cfd52c8f38 | |||
| e295541dae | |||
| 785a6def3b | |||
| 53bdec8aab | |||
| 5191897696 | |||
| 2ecfa0e08c | |||
| c001139465 | |||
| e3353a445a | |||
| ce779452ba | |||
| eb8b8295a1 | |||
| 94c9c61142 | |||
| 11e390bf42 | |||
| a8fdf19c91 | |||
| 08bca9a35f | |||
| 1db630d5c9 | |||
| bbad921022 | |||
| f64cf03e1d | |||
| 559122f67a | |||
| 431f2abfee | |||
| 5f622027cd | |||
| fa97494cc8 | |||
| f4d4975077 | |||
| f030480e44 | |||
| 435c21c155 | |||
| 7438d7a02f | |||
| 0e5930b8dc | |||
| eacca89d4e | |||
| 99e6bef4ef | |||
| 3d5314b5f5 | |||
| f0517463a5 | |||
| c9e0fb9730 | |||
| d86a4b0c2f | |||
| eced4266c2 | |||
| fc483e60bc | |||
| 910cd41c47 | |||
| b4e1d32e85 | |||
| ff66f79721 | |||
| 8b610a6d34 | |||
| 20e923ba0d | |||
| 4777eaf367 | |||
| a40422fada | |||
| b1912055a9 | |||
| e8714d79b2 | |||
| f8e2a917f9 | |||
| 140e8852e8 | |||
| 547e141166 | |||
| d9c49a6cde | |||
| 8ade57b9e3 | |||
| a4750fbdba | |||
| a33949a0a5 | |||
| 4d57147c3d | |||
| 3d7abd9cbe | |||
| 5a81ca6ffe | |||
| b9188caf7d | |||
| df726c038f | |||
| 14e0e1afc2 | |||
| 2c1a8894cb | |||
| a49c76c69c | |||
| eb04f68351 | |||
| 77bd36d038 | |||
| 1b85f812af | |||
| daad24388c | |||
| 0cbd02d3cc | |||
| 3a13ddb4a3 | |||
| 7b272c85d5 | |||
| 5edc45349f | |||
| dfaa61b666 | |||
| 076e195cac | |||
| 71a8e56ae3 | |||
| ef79fea0b7 | |||
| ea33b5d134 | |||
| 5bab4d4360 | |||
| 10e24f93c4 | |||
| 00cebc3dfb | |||
| ee034e23bb | |||
| 1d02663275 | |||
| e594f1eda7 | |||
| 1bcb5f8b6f | |||
| 06f63fdc0d | |||
| 7efcf9ccff | |||
| 6649b4df3c | |||
| 71096f4d26 | |||
| 0f0161a5a2 | |||
| b99382b551 | |||
| 493f905598 | |||
| 4e6292b439 | |||
| 2f0a94bcfd | |||
| 618a51df13 | |||
| 18a5010436 | |||
| c8b893cb77 | |||
| a1252fcc0e | |||
| ef67d9ae12 | |||
| 3e638049ec | |||
| 7f59e8e058 | |||
| 7023460394 | |||
| 0dcf1b5cd2 | |||
| 7b2c5189b3 | |||
| d3fe62a646 | |||
| 1f17294cd3 | |||
| 3882a61065 | |||
| df72c4886f | |||
| 26c72f9860 | |||
| 55957bbab5 | |||
| ab843eb587 | |||
| 4438b8e017 | |||
| 5747836754 | |||
| ba5c383877 | |||
| b4f08db391 | |||
| 060acb3f25 | |||
| 8727de1a1b | |||
| 8cde8d1252 | |||
| 6bac25221a | |||
| 5bedbde746 | |||
| 2fdd33381c | |||
| 8d4b503e56 | |||
| 6c24cccf96 | |||
| 51fdfa7ac7 | |||
| 3dff89c240 | |||
| 4e07c94502 | |||
| 854dc0b353 | |||
| 373791d0b2 | |||
| fe3d612fe0 | |||
| ae0c97a77a | |||
| 788a3661a2 | |||
| 1e24f85fbc | |||
| 4601f5c51f | |||
| 55eafdf0ee | |||
| 63e04cfb60 | |||
| d0a3efab6a | |||
| 2b8680d2c4 | |||
| 31cd8f4e16 | |||
| b75b7dd5ac | |||
| 437a35feaa | |||
| f76af2d0c8 | |||
| efbf13685e | |||
| 08d533cb88 | |||
| ff6e457651 | |||
| 965c2ae89c | |||
| 78b078f41d | |||
| 491fa330f6 | |||
| 9ec148aec5 | |||
| 7598d0d49b | |||
| 6a8506d959 | |||
| 7fe53ef5a3 | |||
| 1743ed118d | |||
| 848b73f99f | |||
| ccc88ecf0a | |||
| c40cb50fe5 | |||
| 386d9f28d7 | |||
| 4350660626 | |||
| 1632522967 | |||
| 178154082f | |||
| d5dac9bdae | |||
| cf363355df | |||
| ca018bfba6 | |||
| 3c48fa3818 | |||
| 7bc588d8df | |||
| 6d1aece43a | |||
| 7e1dbc4cb7 | |||
| 2b09a34467 | |||
| 78ea3024b5 | |||
| cec1891586 | |||
| 6d8ce11934 | |||
| b83a73ab40 | |||
| caa0b7cdf6 | |||
| 46caec7d77 | |||
| 04234cecee | |||
| 84ff0c3227 | |||
| 35a3894a88 | |||
| bde5df043c | |||
| 8f70ddf4ef | |||
| cfc134b871 | |||
| 20c9360528 | |||
| 09b239ed28 | |||
| 294d58d2fe | |||
| 3e70155100 | |||
| ce379f7bb5 | |||
| f8e1ec8d2b | |||
| 24091f8bd8 | |||
| 4c3c18467c | |||
| 3f0e2b478b | |||
| ac2409627a | |||
| a07e4c5810 | |||
| 5a86d08271 | |||
| 4ac0a12a83 | |||
| 290c7566ff | |||
| 6ccc68b15c | |||
| 188bcafdec | |||
| 3a8739cd60 | |||
| 2bc986ecbc | |||
| 638accbec4 | |||
| d8fb4f4c38 | |||
| 3e55934381 | |||
| 40a89ac649 | |||
| d442f20bf8 | |||
| d36fc98c15 | |||
| 700c4717d6 | |||
| 1e73578ab6 | |||
| 971224a282 | |||
| acce19ce43 | |||
| 77021c5bbb | |||
| fe3873b28f | |||
| c1e9a6ac59 | |||
| c2425106ea | |||
| c8e7874534 | |||
| 601daa0e5d | |||
| d022cc48ad | |||
| 527a72860d | |||
| f0bb74a530 | |||
| b75f06d935 | |||
| e2d1d75955 | |||
| 80dc7b5e6a | |||
| 1f4d8e7c21 | |||
| 366c09f199 | |||
| d98f72c4e1 | |||
| e6417fe652 | |||
| f5d52cc9b2 | |||
| 62427c8287 | |||
| ab588fe872 | |||
| fe1385ab34 | |||
| d6f513be52 | |||
| d8fa4cef60 | |||
| 506f478ec7 | |||
| f2c420e289 | |||
| eae2a90463 | |||
| 4305d10264 | |||
| d5b38b01fc | |||
| c49dbd782d | |||
| c7bde21be7 | |||
| d5fdc0b47e | |||
| c3d97bd613 | |||
| 2960390f79 | |||
| f723f857e4 | |||
| d66936a640 | |||
| 3640e1e96c | |||
| ec1e809fc3 | |||
| 8868fa4687 | |||
| ebd75b4010 | |||
| 9bd3f498a7 | |||
| 659a014976 | |||
| 885574e1bf |
@@ -0,0 +1 @@
|
||||
/doc/html/
|
||||
+41
-1
@@ -47,7 +47,7 @@ First official release.
|
||||
|
||||
[h2 Boost 1.38.0]
|
||||
|
||||
* Use [@boost:/libs/utility/swap.html `boost::swap`].
|
||||
* Use [@boost:/libs/core/swap.html `boost::swap`].
|
||||
* [@https://svn.boost.org/trac/boost/ticket/2237 Ticket 2237]:
|
||||
Document that the equality and inequality operators are undefined for two
|
||||
objects if their equality predicates aren't equivalent. Thanks to Daniel
|
||||
@@ -220,4 +220,44 @@ C++11 support has resulted in some breaking changes:
|
||||
for C++11 allocators.
|
||||
* Simplified the implementation a bit. Hopefully more robust.
|
||||
|
||||
[h2 Boost 1.53.0]
|
||||
|
||||
* Remove support for the old pre-standard variadic pair constructors, and
|
||||
equality implementation. Both have been deprecated since Boost 1.48.
|
||||
* Remove use of deprecated config macros.
|
||||
* More internal implementation changes, including a much simpler
|
||||
implementation of `erase`.
|
||||
|
||||
[h2 Boost 1.54.0]
|
||||
|
||||
* Mark methods specified in standard as `noexpect`. More to come in the next
|
||||
release.
|
||||
* If the hash function and equality predicate are known to both have nothrow
|
||||
move assignment or construction then use them.
|
||||
|
||||
[h2 Boost 1.55.0]
|
||||
|
||||
* Avoid some warnings ([ticket 8851], [ticket 8874]).
|
||||
* Avoid exposing some detail functions via. ADL on the iterators.
|
||||
* Follow the standard by only using the allocators' construct and destroy
|
||||
methods to construct and destroy stored elements. Don't use them for internal
|
||||
data like pointers.
|
||||
|
||||
[h2 Boost 1.56.0]
|
||||
|
||||
* Fix some shadowed variable warnings ([ticket 9377]).
|
||||
* Fix allocator use in documentation ([ticket 9719]).
|
||||
* Always use prime number of buckets for integers. Fixes performance
|
||||
regression when inserting consecutive integers, although makes other
|
||||
uses slower ([ticket 9282]).
|
||||
* Only construct elements using allocators, as specified in C++11 standard.
|
||||
|
||||
[h2 Boost 1.57.0]
|
||||
|
||||
* Fix the `pointer` typedef in iterators ([ticket 10672]).
|
||||
* Fix Coverity warning
|
||||
([@https://github.com/boostorg/unordered/pull/2 GitHub #2]).
|
||||
* Rename private `iterator` typedef in some iterator classes, as it
|
||||
confuses some traits classes.
|
||||
|
||||
[endsect]
|
||||
|
||||
+5
-4
@@ -8,11 +8,12 @@
|
||||
|
||||
Support for move semantics is implemented using Boost.Move. If rvalue
|
||||
references are available it will use them, but if not it uses a close,
|
||||
but imperfect emulation. On such compilers you'll need to use Boost.Move
|
||||
to take advantage of using movable container elements, also note that:
|
||||
but imperfect emulation. On such compilers:
|
||||
|
||||
* Non-copyable objects can be stored in the containers, but without support
|
||||
for rvalue references the container will not be movable.
|
||||
* Non-copyable objects can be stored in the containers.
|
||||
They can be constructed in place using `emplace`, or if they support
|
||||
Boost.Move, moved into place.
|
||||
* The containers themselves are not movable.
|
||||
* Argument forwarding is not perfect.
|
||||
|
||||
[endsect]
|
||||
|
||||
+2
-2
@@ -54,14 +54,14 @@ order to work with non-C++11 compilers and libraries.
|
||||
class Key, class Mapped,
|
||||
class Hash = ``[classref boost::hash]``<Key>,
|
||||
class Pred = std::equal_to<Key>,
|
||||
class Alloc = std::allocator<Key> >
|
||||
class Alloc = std::allocator<std::pair<Key const, Mapped> > >
|
||||
class ``[classref boost::unordered_map unordered_map]``;
|
||||
|
||||
template<
|
||||
class Key, class Mapped,
|
||||
class Hash = ``[classref boost::hash]``<Key>,
|
||||
class Pred = std::equal_to<Key>,
|
||||
class Alloc = std::allocator<Key> >
|
||||
class Alloc = std::allocator<std::pair<Key const, Mapped> > >
|
||||
class ``[classref boost::unordered_multimap unordered_multimap]``;
|
||||
}
|
||||
|
||||
|
||||
+13
-8
@@ -3,7 +3,7 @@
|
||||
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||
|
||||
[def __wang__
|
||||
[@http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||
[@http://web.archive.org/web/20121102023700/http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||
Thomas Wang's article on integer hash functions]]
|
||||
|
||||
[section:rationale Implementation Rationale]
|
||||
@@ -85,7 +85,8 @@ of 2.
|
||||
|
||||
Using a prime number of buckets, and choosing a bucket by using the modulus
|
||||
of the hash function's result will usually give a good result. The downside
|
||||
is that the required modulus operation is fairly expensive.
|
||||
is that the required modulus operation is fairly expensive. This is what the
|
||||
containers do in most cases.
|
||||
|
||||
Using a power of 2 allows for much quicker selection of the bucket
|
||||
to use, but at the expense of loosing the upper bits of the hash value.
|
||||
@@ -95,12 +96,16 @@ functions this can't be relied on.
|
||||
|
||||
To avoid this a transformation could be applied to the hash function, for an
|
||||
example see __wang__. Unfortunately, a transformation like Wang's requires
|
||||
knowledge of the number of bits in the hash value, so it isn't portable enough.
|
||||
This leaves more expensive methods, such as Knuth's Multiplicative Method
|
||||
(mentioned in Wang's article). These don't tend to work as well as taking the
|
||||
modulus of a prime, and the extra computation required might negate
|
||||
efficiency advantage of power of 2 hash tables.
|
||||
knowledge of the number of bits in the hash value, so it isn't portable enough
|
||||
to use as a default. It can applicable in certain cases so the containers
|
||||
have a policy based implementation that can use this alternative technique.
|
||||
|
||||
So, this implementation uses a prime number for the hash table size.
|
||||
Currently this is only done on 64 bit architecures, where prime number
|
||||
modulus can be expensive. Although this varies depending on the architecture,
|
||||
so I probably should revisit it.
|
||||
|
||||
I'm also thinking of introducing a mechanism whereby a hash function can
|
||||
indicate that it's safe to be used directly with power of 2 buckets, in
|
||||
which case a faster plain power of 2 implementation can be used.
|
||||
|
||||
[endsect]
|
||||
|
||||
+2
-14
@@ -449,10 +449,6 @@ EOL;
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="emplace_hint">
|
||||
@@ -499,10 +495,6 @@ EOL;
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="insert">
|
||||
@@ -1114,9 +1106,7 @@ EOL;
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -1157,9 +1147,7 @@ EOL;
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
|
||||
+8
-56
@@ -383,10 +383,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="emplace_hint">
|
||||
@@ -426,10 +422,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="insert">
|
||||
@@ -970,9 +962,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -1005,9 +995,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -1429,10 +1417,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="emplace_hint">
|
||||
@@ -1472,10 +1456,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="insert">
|
||||
@@ -2014,9 +1994,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -2049,9 +2027,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -2488,10 +2464,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="emplace_hint">
|
||||
@@ -2531,10 +2503,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="insert">
|
||||
@@ -3108,9 +3076,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -3145,9 +3111,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -3581,10 +3545,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="emplace_hint">
|
||||
@@ -3624,10 +3584,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
<para>Since existing <code>std::pair</code> implementations don't support
|
||||
<code>std::piecewise_construct</code> this emulates it,
|
||||
but using <code>boost::unordered::piecewise_construct</code>.</para>
|
||||
<para>In version of Boost before 1.48 this emulated the variadic pair
|
||||
constructor from older C++0x drafts. For backwards compatability
|
||||
this can be enabled by defining the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT</code>.</para>
|
||||
</notes>
|
||||
</method>
|
||||
<method name="insert">
|
||||
@@ -4168,9 +4124,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
@@ -4205,9 +4159,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</description>
|
||||
<notes>
|
||||
<para>The behavior of this function was changed to match
|
||||
the C++11 standard in Boost 1.48. If you wish to use
|
||||
the old behaviour, define the macro
|
||||
<code>BOOST_UNORDERED_DEPRECATED_EQUALITY</code>.</para>
|
||||
the C++11 standard in Boost 1.48.</para>
|
||||
<para>Behavior is undefined if the two containers don't have
|
||||
equivalent equality predicates.</para>
|
||||
</notes>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#ifndef BOOST_UNORDERED_ALLOCATE_HPP
|
||||
#define BOOST_UNORDERED_ALLOCATE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/detail/fwd.hpp>
|
||||
@@ -85,7 +86,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// Either forwarding variadic arguments, or storing the arguments in
|
||||
// emplace_args##n
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#define BOOST_UNORDERED_EMPLACE_TEMPLATE typename... Args
|
||||
#define BOOST_UNORDERED_EMPLACE_ARGS BOOST_FWD_REF(Args)... args
|
||||
@@ -136,7 +137,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
#define BOOST_UNORDERED_EMPLACE_ARGS2 create_emplace_args
|
||||
#define BOOST_UNORDERED_EMPLACE_ARGS3 create_emplace_args
|
||||
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
#define BOOST_UNORDERED_EARGS_MEMBER(z, n, _) \
|
||||
typedef BOOST_FWD_REF(BOOST_PP_CAT(A, n)) BOOST_PP_CAT(Arg, n); \
|
||||
@@ -234,9 +235,11 @@ namespace boost { namespace unordered { namespace detail {
|
||||
#pragma warning(disable:4100) // unreferenced formal parameter
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
inline void destroy(T* x) {
|
||||
x->~T();
|
||||
namespace func {
|
||||
template <class T>
|
||||
inline void destroy(T* x) {
|
||||
x->~T();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
@@ -257,13 +260,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
template <typename T, unsigned int> struct expr_test;
|
||||
template <typename T> struct expr_test<T, sizeof(char)> : T {};
|
||||
template <typename U> static char for_expr_test(U const&);
|
||||
|
||||
# define BOOST_UNORDERED_CHECK_EXPRESSION(count, result, expression) \
|
||||
template <typename U> \
|
||||
static typename boost::unordered::detail::expr_test< \
|
||||
BOOST_PP_CAT(choice, result), \
|
||||
sizeof(boost::unordered::detail::for_expr_test(( \
|
||||
sizeof(for_expr_test(( \
|
||||
(expression), \
|
||||
0)))>::type test( \
|
||||
BOOST_PP_CAT(choice, count))
|
||||
@@ -276,6 +278,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
# define BOOST_UNORDERED_HAS_FUNCTION(name, thing, args, _) \
|
||||
struct BOOST_PP_CAT(has_, name) \
|
||||
{ \
|
||||
template <typename U> static char for_expr_test(U const&); \
|
||||
BOOST_UNORDERED_CHECK_EXPRESSION(1, 1, \
|
||||
boost::unordered::detail::make< thing >().name args); \
|
||||
BOOST_UNORDERED_DEFAULT_EXPRESSION(2, 2); \
|
||||
@@ -342,7 +345,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# endif
|
||||
|
||||
# if !defined(BOOST_NO_VARIADIC_TEMPLATES) && \
|
||||
# if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_SFINAE_EXPR)
|
||||
# define BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT 1
|
||||
# else
|
||||
@@ -432,7 +435,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
max_size, U const, (), 0
|
||||
);
|
||||
|
||||
# if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
# if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename T, typename ValueType, typename... Args>
|
||||
BOOST_UNORDERED_HAS_FUNCTION(
|
||||
@@ -473,6 +476,9 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
# endif
|
||||
|
||||
namespace func
|
||||
{
|
||||
|
||||
template <typename Alloc>
|
||||
inline Alloc call_select_on_container_copy_construction(const Alloc& rhs,
|
||||
typename boost::enable_if_c<
|
||||
@@ -510,6 +516,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
return (std::numeric_limits<SizeType>::max)();
|
||||
}
|
||||
|
||||
} // namespace func.
|
||||
|
||||
template <typename Alloc>
|
||||
struct allocator_traits
|
||||
{
|
||||
@@ -589,7 +597,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
boost::unordered::detail::has_destroy<Alloc, T>::value>::type
|
||||
destroy(Alloc&, T* p)
|
||||
{
|
||||
boost::unordered::detail::destroy(p);
|
||||
boost::unordered::detail::func::destroy(p);
|
||||
}
|
||||
|
||||
# elif !defined(BOOST_NO_SFINAE_EXPR)
|
||||
@@ -623,7 +631,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
boost::unordered::detail::has_destroy<Alloc, T>::value>::type
|
||||
destroy(Alloc&, T* p)
|
||||
{
|
||||
boost::unordered::detail::destroy(p);
|
||||
boost::unordered::detail::func::destroy(p);
|
||||
}
|
||||
|
||||
# else
|
||||
@@ -669,21 +677,22 @@ namespace boost { namespace unordered { namespace detail {
|
||||
boost::is_same<T, value_type>::value,
|
||||
void*>::type = 0)
|
||||
{
|
||||
boost::unordered::detail::destroy(p);
|
||||
boost::unordered::detail::func::destroy(p);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
static size_type max_size(const Alloc& a)
|
||||
{
|
||||
return boost::unordered::detail::call_max_size<size_type>(a);
|
||||
return boost::unordered::detail::func::
|
||||
call_max_size<size_type>(a);
|
||||
}
|
||||
|
||||
// Allocator propagation on construction
|
||||
|
||||
static Alloc select_on_container_copy_construction(Alloc const& rhs)
|
||||
{
|
||||
return boost::unordered::detail::
|
||||
return boost::unordered::detail::func::
|
||||
call_select_on_container_copy_construction(rhs);
|
||||
}
|
||||
|
||||
@@ -758,12 +767,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost { namespace unordered { namespace detail {
|
||||
namespace boost { namespace unordered { namespace detail { namespace func {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// call_construct
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
# if BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT
|
||||
|
||||
@@ -792,7 +801,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
template <typename Alloc, typename T>
|
||||
inline void destroy_value_impl(Alloc&, T* x) {
|
||||
boost::unordered::detail::destroy(x);
|
||||
boost::unordered::detail::func::destroy(x);
|
||||
}
|
||||
|
||||
|
||||
@@ -802,7 +811,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
template <typename Alloc, typename T>
|
||||
inline void destroy_value_impl(Alloc&, T* x) {
|
||||
boost::unordered::detail::destroy(x);
|
||||
boost::unordered::detail::func::destroy(x);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -812,13 +821,13 @@ namespace boost { namespace unordered { namespace detail {
|
||||
//
|
||||
// Used for piecewise construction.
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
# define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \
|
||||
template<typename Alloc, typename T> \
|
||||
void construct_from_tuple(Alloc& alloc, T* ptr, namespace_ tuple<>) \
|
||||
{ \
|
||||
boost::unordered::detail::call_construct(alloc, ptr); \
|
||||
boost::unordered::detail::func::call_construct(alloc, ptr); \
|
||||
} \
|
||||
\
|
||||
BOOST_PP_REPEAT_FROM_TO(1, n, \
|
||||
@@ -830,7 +839,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
void construct_from_tuple(Alloc& alloc, T* ptr, \
|
||||
namespace_ tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x) \
|
||||
{ \
|
||||
boost::unordered::detail::call_construct(alloc, ptr, \
|
||||
boost::unordered::detail::func::call_construct(alloc, ptr, \
|
||||
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_GET_TUPLE_ARG, namespace_) \
|
||||
); \
|
||||
}
|
||||
@@ -871,7 +880,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
# define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \
|
||||
template<typename Alloc, typename T> \
|
||||
void construct_from_tuple_impl( \
|
||||
boost::unordered::detail::length<0>, Alloc&, T* ptr, \
|
||||
boost::unordered::detail::func::length<0>, Alloc&, T* ptr, \
|
||||
namespace_ tuple<>) \
|
||||
{ \
|
||||
new ((void*) ptr) T(); \
|
||||
@@ -884,7 +893,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
template<typename Alloc, typename T, \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
|
||||
void construct_from_tuple_impl( \
|
||||
boost::unordered::detail::length<n>, Alloc&, T* ptr, \
|
||||
boost::unordered::detail::func::length<n>, Alloc&, T* ptr, \
|
||||
namespace_ tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x) \
|
||||
{ \
|
||||
new ((void*) ptr) T( \
|
||||
@@ -913,7 +922,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
void construct_from_tuple(Alloc& alloc, T* ptr, Tuple const& x)
|
||||
{
|
||||
construct_from_tuple_impl(
|
||||
boost::unordered::detail::length<
|
||||
boost::unordered::detail::func::length<
|
||||
boost::tuples::length<Tuple>::value>(),
|
||||
alloc, ptr, x);
|
||||
}
|
||||
@@ -921,146 +930,58 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SFINAE traits for construction.
|
||||
// Trait to check for piecewise construction.
|
||||
|
||||
// Decide which construction method to use for a three argument
|
||||
// call. Note that this is difficult to do using overloads because
|
||||
// the arguments are packed into 'emplace_args3'.
|
||||
//
|
||||
// The decision is made on the first argument.
|
||||
|
||||
|
||||
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
|
||||
template <typename A, typename B, typename A0>
|
||||
struct emulation1 {
|
||||
static choice1::type test(choice1, std::pair<A, B> const&);
|
||||
static choice2::type test(choice2, A const&);
|
||||
static choice3::type test(choice3, convert_from_anything const&);
|
||||
|
||||
enum { value =
|
||||
sizeof(test(choose(), boost::unordered::detail::make<A0>())) ==
|
||||
sizeof(choice2::type) };
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename A, typename B, typename A0>
|
||||
struct check3_base {
|
||||
template <typename A0>
|
||||
struct use_piecewise {
|
||||
static choice1::type test(choice1,
|
||||
boost::unordered::piecewise_construct_t);
|
||||
|
||||
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
|
||||
static choice2::type test(choice2, A const&);
|
||||
#endif
|
||||
static choice2::type test(choice2, ...);
|
||||
|
||||
static choice3::type test(choice3, ...);
|
||||
|
||||
enum { value =
|
||||
enum { value = sizeof(choice1::type) ==
|
||||
sizeof(test(choose(), boost::unordered::detail::make<A0>())) };
|
||||
};
|
||||
|
||||
template <typename A, typename B, typename A0>
|
||||
struct piecewise3 {
|
||||
enum { value = check3_base<A,B,A0>::value == sizeof(choice1::type) };
|
||||
};
|
||||
|
||||
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
|
||||
template <typename A, typename B, typename A0>
|
||||
struct emulation3 {
|
||||
enum { value = check3_base<A,B,A0>::value == sizeof(choice2::type) };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// TODO: Full construct?
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Construct from variadic parameters
|
||||
|
||||
// For the standard pair constructor.
|
||||
|
||||
template <typename Alloc, typename T, typename... Args>
|
||||
inline void construct_value_impl(Alloc& alloc, T* address,
|
||||
BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::unordered::detail::func::call_construct(alloc,
|
||||
address, boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Special case for piece_construct
|
||||
//
|
||||
// TODO: When possible, it might be better to use std::pair's
|
||||
// constructor for std::piece_construct with std::tuple.
|
||||
|
||||
template <typename Alloc, typename A, typename B,
|
||||
typename A0, typename A1, typename A2>
|
||||
inline typename enable_if<piecewise3<A, B, A0>, void>::type
|
||||
inline typename enable_if<use_piecewise<A0>, void>::type
|
||||
construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
|
||||
BOOST_FWD_REF(A0), BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
|
||||
{
|
||||
boost::unordered::detail::construct_from_tuple(alloc,
|
||||
boost::unordered::detail::func::construct_from_tuple(alloc,
|
||||
boost::addressof(address->first), boost::forward<A1>(a1));
|
||||
boost::unordered::detail::construct_from_tuple(alloc,
|
||||
boost::unordered::detail::func::construct_from_tuple(alloc,
|
||||
boost::addressof(address->second), boost::forward<A2>(a2));
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
|
||||
|
||||
template <typename Alloc, typename A, typename B, typename A0>
|
||||
inline typename enable_if<emulation1<A, B, A0>, void>::type
|
||||
construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
|
||||
BOOST_FWD_REF(A0) a0)
|
||||
{
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::addressof(address->first),boost::forward<A0>(a0));
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::addressof(address->second));
|
||||
}
|
||||
|
||||
template <typename Alloc, typename A, typename B,
|
||||
typename A0, typename A1, typename A2>
|
||||
inline typename enable_if<emulation3<A, B, A0>, void>::type
|
||||
construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
|
||||
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
|
||||
{
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::addressof(address->first),boost::forward<A0>(a0));
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::addressof(address->second),
|
||||
boost::forward<A1>(a1),
|
||||
boost::forward<A2>(a2));
|
||||
}
|
||||
|
||||
template <typename Alloc, typename A, typename B,
|
||||
typename A0, typename A1, typename A2, typename A3,
|
||||
typename... Args>
|
||||
inline void construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
|
||||
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2,
|
||||
BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::addressof(address->first),boost::forward<A0>(a0));
|
||||
boost::unordered::detail::call_construct(alloc,
|
||||
boost::addressof(address->second),
|
||||
boost::forward<A1>(a1),
|
||||
boost::forward<A2>(a2),
|
||||
boost::forward<A3>(a3),
|
||||
boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
|
||||
#else // BOOST_NO_VARIADIC_TEMPLATES
|
||||
#else // BOOST_NO_CXX11_VARIADIC_TEMPLATES
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Construct from emplace_args
|
||||
|
||||
#define BOOST_UNORDERED_CONSTRUCT_IMPL(z, num_params, _) \
|
||||
template < \
|
||||
typename Alloc, typename T, \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A) \
|
||||
> \
|
||||
inline void construct_value_impl(Alloc&, T* address, \
|
||||
boost::unordered::detail::BOOST_PP_CAT(emplace_args,num_params) < \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) \
|
||||
> const& args) \
|
||||
{ \
|
||||
new((void*) address) T( \
|
||||
BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_CALL_FORWARD, \
|
||||
args.a)); \
|
||||
}
|
||||
// Explicitly write out first three overloads for the sake of sane
|
||||
// error messages.
|
||||
|
||||
template <typename Alloc, typename T, typename A0>
|
||||
inline void construct_value_impl(Alloc&, T* address,
|
||||
@@ -1090,82 +1011,45 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
);
|
||||
}
|
||||
|
||||
// Use a macro for the rest.
|
||||
|
||||
#define BOOST_UNORDERED_CONSTRUCT_IMPL(z, num_params, _) \
|
||||
template < \
|
||||
typename Alloc, typename T, \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A) \
|
||||
> \
|
||||
inline void construct_value_impl(Alloc&, T* address, \
|
||||
boost::unordered::detail::BOOST_PP_CAT(emplace_args,num_params) < \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) \
|
||||
> const& args) \
|
||||
{ \
|
||||
new((void*) address) T( \
|
||||
BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_CALL_FORWARD, \
|
||||
args.a)); \
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
|
||||
BOOST_UNORDERED_CONSTRUCT_IMPL, _)
|
||||
|
||||
#undef BOOST_UNORDERED_CONSTRUCT_IMPL
|
||||
|
||||
// Construct with piece_construct
|
||||
|
||||
template <typename Alloc, typename A, typename B,
|
||||
typename A0, typename A1, typename A2>
|
||||
inline void construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
|
||||
boost::unordered::detail::emplace_args3<A0, A1, A2> const& args,
|
||||
typename enable_if<piecewise3<A, B, A0>, void*>::type = 0)
|
||||
typename enable_if<use_piecewise<A0>, void*>::type = 0)
|
||||
{
|
||||
boost::unordered::detail::construct_from_tuple(alloc,
|
||||
boost::unordered::detail::func::construct_from_tuple(alloc,
|
||||
boost::addressof(address->first), args.a1);
|
||||
boost::unordered::detail::construct_from_tuple(alloc,
|
||||
boost::unordered::detail::func::construct_from_tuple(alloc,
|
||||
boost::addressof(address->second), args.a2);
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
|
||||
#endif // BOOST_NO_CXX11_VARIADIC_TEMPLATES
|
||||
|
||||
template <typename Alloc, typename A, typename B, typename A0>
|
||||
inline void construct_value_impl(Alloc&, std::pair<A, B>* address,
|
||||
boost::unordered::detail::emplace_args1<A0> const& args,
|
||||
typename enable_if<emulation1<A, B, A0>, void*>::type = 0)
|
||||
{
|
||||
new((void*) boost::addressof(address->first)) A(
|
||||
boost::forward<A0>(args.a0));
|
||||
new((void*) boost::addressof(address->second)) B();
|
||||
}
|
||||
|
||||
template <typename Alloc, typename A, typename B,
|
||||
typename A0, typename A1, typename A2>
|
||||
inline void construct_value_impl(Alloc&, std::pair<A, B>* address,
|
||||
boost::unordered::detail::emplace_args3<A0, A1, A2> const& args,
|
||||
typename enable_if<emulation3<A, B, A0>, void*>::type = 0)
|
||||
{
|
||||
new((void*) boost::addressof(address->first)) A(
|
||||
boost::forward<A0>(args.a0));
|
||||
new((void*) boost::addressof(address->second)) B(
|
||||
boost::forward<A1>(args.a1),
|
||||
boost::forward<A2>(args.a2));
|
||||
}
|
||||
|
||||
#define BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL(z, num_params, _) \
|
||||
template <typename Alloc, typename A, typename B, \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A) \
|
||||
> \
|
||||
inline void construct_value_impl(Alloc&, std::pair<A, B>* address, \
|
||||
boost::unordered::detail::BOOST_PP_CAT(emplace_args, num_params) < \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) \
|
||||
> const& args) \
|
||||
{ \
|
||||
new((void*) boost::addressof(address->first)) A( \
|
||||
boost::forward<A0>(args.a0)); \
|
||||
new((void*) boost::addressof(address->second)) B( \
|
||||
BOOST_PP_ENUM_##z(BOOST_PP_DEC(num_params), \
|
||||
BOOST_UNORDERED_CALL_FORWARD2, args.a)); \
|
||||
}
|
||||
|
||||
#define BOOST_UNORDERED_CALL_FORWARD2(z, i, a) \
|
||||
BOOST_UNORDERED_CALL_FORWARD(z, BOOST_PP_INC(i), a)
|
||||
|
||||
BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL(1, 2, _)
|
||||
BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
|
||||
BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL, _)
|
||||
|
||||
#undef BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL
|
||||
#undef BOOST_UNORDERED_CALL_FORWARD2
|
||||
|
||||
#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
|
||||
#endif // BOOST_NO_VARIADIC_TEMPLATES
|
||||
|
||||
}}}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Some helper functions for allocating & constructing
|
||||
}}}}
|
||||
|
||||
namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
@@ -1197,8 +1081,10 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
~array_constructor() {
|
||||
if (ptr_) {
|
||||
for(pointer p = ptr_; p != constructed_; ++p)
|
||||
traits::destroy(alloc_, boost::addressof(*p));
|
||||
for(pointer p = ptr_; p != constructed_; ++p) {
|
||||
boost::unordered::detail::func::destroy(
|
||||
boost::addressof(*p));
|
||||
}
|
||||
|
||||
traits::deallocate(alloc_, ptr_, length_);
|
||||
}
|
||||
@@ -1211,8 +1097,9 @@ namespace boost { namespace unordered { namespace detail {
|
||||
length_ = l;
|
||||
ptr_ = traits::allocate(alloc_, length_);
|
||||
pointer end = ptr_ + static_cast<std::ptrdiff_t>(length_);
|
||||
for(constructed_ = ptr_; constructed_ != end; ++constructed_)
|
||||
traits::construct(alloc_, boost::addressof(*constructed_), v);
|
||||
for(constructed_ = ptr_; constructed_ != end; ++constructed_) {
|
||||
new ((void*) boost::addressof(*constructed_)) V(v);
|
||||
}
|
||||
}
|
||||
|
||||
pointer get() const
|
||||
|
||||
@@ -7,14 +7,17 @@
|
||||
#ifndef BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/detail/util.hpp>
|
||||
#include <boost/unordered/detail/allocate.hpp>
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_assignable.hpp>
|
||||
#include <boost/swap.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
@@ -30,6 +33,10 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
}}}
|
||||
|
||||
// The 'iterator_detail' namespace was a misguided attempt at avoiding ADL
|
||||
// in the detail namespace. It didn't work because the template parameters
|
||||
// were in detail. I'm not changing it at the moment to be safe. I might
|
||||
// do in the future if I change the iterator types.
|
||||
namespace boost { namespace unordered { namespace iterator_detail {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -37,49 +44,50 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
//
|
||||
// all no throw
|
||||
|
||||
template <typename NodePointer, typename Value> struct iterator;
|
||||
template <typename ConstNodePointer, typename NodePointer,
|
||||
typename Value> struct c_iterator;
|
||||
template <typename NodePointer, typename Value, typename Policy>
|
||||
struct l_iterator;
|
||||
template <typename ConstNodePointer, typename NodePointer,
|
||||
typename Value, typename Policy> struct cl_iterator;
|
||||
template <typename Node> struct iterator;
|
||||
template <typename Node, typename ConstNodePointer> struct c_iterator;
|
||||
template <typename Node, typename Policy> struct l_iterator;
|
||||
template <typename Node, typename ConstNodePointer, typename Policy>
|
||||
struct cl_iterator;
|
||||
|
||||
// Local Iterators
|
||||
//
|
||||
// all no throw
|
||||
|
||||
template <typename NodePointer, typename Value, typename Policy>
|
||||
template <typename Node, typename Policy>
|
||||
struct l_iterator
|
||||
: public boost::iterator<
|
||||
std::forward_iterator_tag, Value, std::ptrdiff_t,
|
||||
NodePointer, Value&>
|
||||
std::forward_iterator_tag,
|
||||
typename Node::value_type,
|
||||
std::ptrdiff_t,
|
||||
typename Node::value_type*,
|
||||
typename Node::value_type&>
|
||||
{
|
||||
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
template <typename ConstNodePointer, typename NodePointer2,
|
||||
typename Value2, typename Policy2>
|
||||
template <typename Node2, typename ConstNodePointer, typename Policy2>
|
||||
friend struct boost::unordered::iterator_detail::cl_iterator;
|
||||
private:
|
||||
#endif
|
||||
typedef NodePointer node_pointer;
|
||||
typedef boost::unordered::iterator_detail::iterator<NodePointer, Value>
|
||||
iterator;
|
||||
typedef typename Node::node_pointer node_pointer;
|
||||
typedef boost::unordered::iterator_detail::iterator<Node> iterator;
|
||||
node_pointer ptr_;
|
||||
std::size_t bucket_;
|
||||
std::size_t bucket_count_;
|
||||
|
||||
public:
|
||||
|
||||
l_iterator() : ptr_() {}
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
l_iterator(iterator x, std::size_t b, std::size_t c)
|
||||
l_iterator() BOOST_NOEXCEPT : ptr_() {}
|
||||
|
||||
l_iterator(iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT
|
||||
: ptr_(x.node_), bucket_(b), bucket_count_(c) {}
|
||||
|
||||
Value& operator*() const {
|
||||
value_type& operator*() const {
|
||||
return ptr_->value();
|
||||
}
|
||||
|
||||
Value* operator->() const {
|
||||
value_type* operator->() const {
|
||||
return ptr_->value_ptr();
|
||||
}
|
||||
|
||||
@@ -97,51 +105,53 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
bool operator==(l_iterator x) const {
|
||||
bool operator==(l_iterator x) const BOOST_NOEXCEPT {
|
||||
return ptr_ == x.ptr_;
|
||||
}
|
||||
|
||||
bool operator!=(l_iterator x) const {
|
||||
bool operator!=(l_iterator x) const BOOST_NOEXCEPT {
|
||||
return ptr_ != x.ptr_;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ConstNodePointer, typename NodePointer, typename Value,
|
||||
typename Policy>
|
||||
template <typename Node, typename ConstNodePointer, typename Policy>
|
||||
struct cl_iterator
|
||||
: public boost::iterator<
|
||||
std::forward_iterator_tag, Value, std::ptrdiff_t,
|
||||
ConstNodePointer, Value const&>
|
||||
std::forward_iterator_tag,
|
||||
typename Node::value_type,
|
||||
std::ptrdiff_t,
|
||||
typename Node::value_type const*,
|
||||
typename Node::value_type const&>
|
||||
{
|
||||
friend struct boost::unordered::iterator_detail::l_iterator
|
||||
<NodePointer, Value, Policy>;
|
||||
<Node, Policy>;
|
||||
private:
|
||||
|
||||
typedef NodePointer node_pointer;
|
||||
typedef boost::unordered::iterator_detail::iterator<NodePointer, Value>
|
||||
iterator;
|
||||
typedef typename Node::node_pointer node_pointer;
|
||||
typedef boost::unordered::iterator_detail::iterator<Node> iterator;
|
||||
node_pointer ptr_;
|
||||
std::size_t bucket_;
|
||||
std::size_t bucket_count_;
|
||||
|
||||
public:
|
||||
|
||||
cl_iterator() : ptr_() {}
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
cl_iterator(iterator x, std::size_t b, std::size_t c) :
|
||||
cl_iterator() BOOST_NOEXCEPT : ptr_() {}
|
||||
|
||||
cl_iterator(iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT :
|
||||
ptr_(x.node_), bucket_(b), bucket_count_(c) {}
|
||||
|
||||
cl_iterator(boost::unordered::iterator_detail::l_iterator<
|
||||
NodePointer, Value, Policy> const& x) :
|
||||
Node, Policy> const& x) BOOST_NOEXCEPT :
|
||||
ptr_(x.ptr_), bucket_(x.bucket_), bucket_count_(x.bucket_count_)
|
||||
{}
|
||||
|
||||
Value const&
|
||||
operator*() const {
|
||||
value_type const& operator*() const {
|
||||
return ptr_->value();
|
||||
}
|
||||
|
||||
Value const* operator->() const {
|
||||
value_type const* operator->() const {
|
||||
return ptr_->value_ptr();
|
||||
}
|
||||
|
||||
@@ -159,27 +169,34 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
friend bool operator==(cl_iterator const& x, cl_iterator const& y) {
|
||||
friend bool operator==(cl_iterator const& x, cl_iterator const& y)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
return x.ptr_ == y.ptr_;
|
||||
}
|
||||
|
||||
friend bool operator!=(cl_iterator const& x, cl_iterator const& y) {
|
||||
friend bool operator!=(cl_iterator const& x, cl_iterator const& y)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
return x.ptr_ != y.ptr_;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename NodePointer, typename Value>
|
||||
template <typename Node>
|
||||
struct iterator
|
||||
: public boost::iterator<
|
||||
std::forward_iterator_tag, Value, std::ptrdiff_t,
|
||||
NodePointer, Value&>
|
||||
std::forward_iterator_tag,
|
||||
typename Node::value_type,
|
||||
std::ptrdiff_t,
|
||||
typename Node::value_type*,
|
||||
typename Node::value_type&>
|
||||
{
|
||||
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
template <typename, typename, typename>
|
||||
template <typename, typename>
|
||||
friend struct boost::unordered::iterator_detail::c_iterator;
|
||||
template <typename, typename, typename>
|
||||
template <typename, typename>
|
||||
friend struct boost::unordered::iterator_detail::l_iterator;
|
||||
template <typename, typename, typename, typename>
|
||||
template <typename, typename, typename>
|
||||
friend struct boost::unordered::iterator_detail::cl_iterator;
|
||||
template <typename>
|
||||
friend struct boost::unordered::detail::table;
|
||||
@@ -189,20 +206,23 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
friend struct boost::unordered::detail::grouped_table_impl;
|
||||
private:
|
||||
#endif
|
||||
typedef NodePointer node_pointer;
|
||||
typedef typename Node::node_pointer node_pointer;
|
||||
node_pointer node_;
|
||||
|
||||
public:
|
||||
|
||||
iterator() : node_() {}
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
explicit iterator(node_pointer const& x) : node_(x) {}
|
||||
iterator() BOOST_NOEXCEPT : node_() {}
|
||||
|
||||
Value& operator*() const {
|
||||
explicit iterator(typename Node::link_pointer x) BOOST_NOEXCEPT :
|
||||
node_(static_cast<node_pointer>(x)) {}
|
||||
|
||||
value_type& operator*() const {
|
||||
return node_->value();
|
||||
}
|
||||
|
||||
Value* operator->() const {
|
||||
value_type* operator->() const {
|
||||
return &node_->value();
|
||||
}
|
||||
|
||||
@@ -217,23 +237,25 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
bool operator==(iterator const& x) const {
|
||||
bool operator==(iterator const& x) const BOOST_NOEXCEPT {
|
||||
return node_ == x.node_;
|
||||
}
|
||||
|
||||
bool operator!=(iterator const& x) const {
|
||||
bool operator!=(iterator const& x) const BOOST_NOEXCEPT {
|
||||
return node_ != x.node_;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ConstNodePointer, typename NodePointer, typename Value>
|
||||
template <typename Node, typename ConstNodePointer>
|
||||
struct c_iterator
|
||||
: public boost::iterator<
|
||||
std::forward_iterator_tag, Value, std::ptrdiff_t,
|
||||
ConstNodePointer, Value const&>
|
||||
std::forward_iterator_tag,
|
||||
typename Node::value_type,
|
||||
std::ptrdiff_t,
|
||||
typename Node::value_type const*,
|
||||
typename Node::value_type const&>
|
||||
{
|
||||
friend struct boost::unordered::iterator_detail::iterator<
|
||||
NodePointer, Value>;
|
||||
friend struct boost::unordered::iterator_detail::iterator<Node>;
|
||||
|
||||
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
template <typename>
|
||||
@@ -245,26 +267,26 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
|
||||
private:
|
||||
#endif
|
||||
|
||||
typedef NodePointer node_pointer;
|
||||
typedef boost::unordered::iterator_detail::iterator<NodePointer, Value>
|
||||
iterator;
|
||||
typedef typename Node::node_pointer node_pointer;
|
||||
typedef boost::unordered::iterator_detail::iterator<Node> iterator;
|
||||
node_pointer node_;
|
||||
|
||||
public:
|
||||
|
||||
c_iterator() : node_() {}
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
explicit c_iterator(node_pointer const& x) : node_(x) {}
|
||||
c_iterator() BOOST_NOEXCEPT : node_() {}
|
||||
|
||||
c_iterator(boost::unordered::iterator_detail::iterator<
|
||||
NodePointer, Value> const& x) : node_(x.node_) {}
|
||||
explicit c_iterator(typename Node::link_pointer x) BOOST_NOEXCEPT :
|
||||
node_(static_cast<node_pointer>(x)) {}
|
||||
|
||||
Value const& operator*() const {
|
||||
c_iterator(iterator const& x) BOOST_NOEXCEPT : node_(x.node_) {}
|
||||
|
||||
value_type const& operator*() const {
|
||||
return node_->value();
|
||||
}
|
||||
|
||||
Value const* operator->() const {
|
||||
value_type const* operator->() const {
|
||||
return &node_->value();
|
||||
}
|
||||
|
||||
@@ -279,11 +301,15 @@ namespace boost { namespace unordered { namespace iterator_detail {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
friend bool operator==(c_iterator const& x, c_iterator const& y) {
|
||||
friend bool operator==(c_iterator const& x, c_iterator const& y)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
return x.node_ == y.node_;
|
||||
}
|
||||
|
||||
friend bool operator!=(c_iterator const& x, c_iterator const& y) {
|
||||
friend bool operator!=(c_iterator const& x, c_iterator const& y)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
return x.node_ != y.node_;
|
||||
}
|
||||
};
|
||||
@@ -310,9 +336,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
protected:
|
||||
|
||||
node_allocator& alloc_;
|
||||
|
||||
private:
|
||||
|
||||
node_pointer node_;
|
||||
bool node_constructed_;
|
||||
bool value_constructed_;
|
||||
@@ -335,7 +358,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
void construct_with_value(BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
{
|
||||
construct();
|
||||
boost::unordered::detail::construct_value_impl(
|
||||
boost::unordered::detail::func::construct_value_impl(
|
||||
alloc_, node_->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD);
|
||||
value_constructed_ = true;
|
||||
}
|
||||
@@ -344,7 +367,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
void construct_with_value2(BOOST_FWD_REF(A0) a0)
|
||||
{
|
||||
construct();
|
||||
boost::unordered::detail::construct_value_impl(
|
||||
boost::unordered::detail::func::construct_value_impl(
|
||||
alloc_, node_->value_ptr(),
|
||||
BOOST_UNORDERED_EMPLACE_ARGS1(boost::forward<A0>(a0)));
|
||||
value_constructed_ = true;
|
||||
@@ -374,12 +397,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
{
|
||||
if (node_) {
|
||||
if (value_constructed_) {
|
||||
boost::unordered::detail::destroy_value_impl(alloc_,
|
||||
boost::unordered::detail::func::destroy_value_impl(alloc_,
|
||||
node_->value_ptr());
|
||||
}
|
||||
|
||||
if (node_constructed_) {
|
||||
node_allocator_traits::destroy(alloc_,
|
||||
boost::unordered::detail::func::destroy(
|
||||
boost::addressof(*node_));
|
||||
}
|
||||
|
||||
@@ -396,9 +419,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
node_ = node_allocator_traits::allocate(alloc_, 1);
|
||||
|
||||
node_allocator_traits::construct(alloc_,
|
||||
boost::addressof(*node_), node());
|
||||
node_->init(static_cast<typename node::link_pointer>(node_));
|
||||
new ((void*) boost::addressof(*node_)) node();
|
||||
node_->init(node_);
|
||||
node_constructed_ = true;
|
||||
}
|
||||
else {
|
||||
@@ -406,7 +428,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
if (value_constructed_)
|
||||
{
|
||||
boost::unordered::detail::destroy_value_impl(alloc_,
|
||||
boost::unordered::detail::func::destroy_value_impl(alloc_,
|
||||
node_->value_ptr());
|
||||
value_constructed_ = false;
|
||||
}
|
||||
@@ -432,8 +454,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef typename node_allocator_traits::pointer node_pointer;
|
||||
typedef typename node::value_type value_type;
|
||||
typedef typename node::link_pointer link_pointer;
|
||||
typedef boost::unordered::iterator_detail::
|
||||
iterator<node_pointer, value_type> iterator;
|
||||
typedef boost::unordered::iterator_detail::iterator<node> iterator;
|
||||
|
||||
node_pointer nodes_;
|
||||
|
||||
@@ -445,7 +466,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
nodes_()
|
||||
{
|
||||
if (b.size_) {
|
||||
typename Table::previous_pointer prev = b.get_previous_start();
|
||||
typename Table::link_pointer prev = b.get_previous_start();
|
||||
nodes_ = static_cast<node_pointer>(prev->next_);
|
||||
prev->next_ = link_pointer();
|
||||
b.size_ = 0;
|
||||
@@ -454,60 +475,61 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
~node_holder();
|
||||
|
||||
void node_for_assignment()
|
||||
{
|
||||
if (!this->node_ && nodes_) {
|
||||
this->node_ = nodes_;
|
||||
nodes_ = static_cast<node_pointer>(nodes_->next_);
|
||||
this->node_->init(this->node_);
|
||||
this->node_->next_ = link_pointer();
|
||||
|
||||
this->node_constructed_ = true;
|
||||
this->value_constructed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void assign_impl(T const& v) {
|
||||
nodes_->value() = v;
|
||||
if (this->node_ && this->value_constructed_) {
|
||||
this->node_->value() = v;
|
||||
}
|
||||
else {
|
||||
this->construct_with_value2(v);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline void assign_impl(std::pair<T1 const, T2> const& v) {
|
||||
const_cast<T1&>(nodes_->value().first) = v.first;
|
||||
nodes_->value().second = v.second;
|
||||
this->construct_with_value2(v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void move_assign_impl(T& v) {
|
||||
nodes_->value() = boost::move(v);
|
||||
if (this->node_ && this->value_constructed_) {
|
||||
this->node_->value() = boost::move(v);
|
||||
}
|
||||
else {
|
||||
this->construct_with_value2(boost::move(v));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline void move_assign_impl(std::pair<T1 const, T2>& v) {
|
||||
// TODO: Move key as well?
|
||||
const_cast<T1&>(nodes_->value().first) =
|
||||
boost::move(const_cast<T1&>(v.first));
|
||||
nodes_->value().second = boost::move(v.second);
|
||||
this->construct_with_value2(boost::move(v));
|
||||
}
|
||||
|
||||
node_pointer copy_of(value_type const& v)
|
||||
{
|
||||
if (nodes_) {
|
||||
assign_impl(v);
|
||||
node_pointer p = nodes_;
|
||||
nodes_ = static_cast<node_pointer>(p->next_);
|
||||
p->init(static_cast<typename node::link_pointer>(p));
|
||||
p->next_ = link_pointer();
|
||||
return p;
|
||||
}
|
||||
else {
|
||||
this->construct_with_value2(v);
|
||||
return base::release();
|
||||
}
|
||||
node_for_assignment();
|
||||
assign_impl(v);
|
||||
return base::release();
|
||||
}
|
||||
|
||||
node_pointer move_copy_of(value_type& v)
|
||||
{
|
||||
if (nodes_) {
|
||||
move_assign_impl(v);
|
||||
node_pointer p = nodes_;
|
||||
nodes_ = static_cast<node_pointer>(p->next_);
|
||||
p->init(static_cast<typename node::link_pointer>(p));
|
||||
p->next_ = link_pointer();
|
||||
return p;
|
||||
}
|
||||
else {
|
||||
this->construct_with_value2(boost::move(v));
|
||||
return base::release();
|
||||
}
|
||||
node_for_assignment();
|
||||
move_assign_impl(v);
|
||||
return base::release();
|
||||
}
|
||||
|
||||
iterator begin() const
|
||||
@@ -523,9 +545,9 @@ namespace boost { namespace unordered { namespace detail {
|
||||
node_pointer p = nodes_;
|
||||
nodes_ = static_cast<node_pointer>(p->next_);
|
||||
|
||||
boost::unordered::detail::destroy_value_impl(this->alloc_,
|
||||
boost::unordered::detail::func::destroy_value_impl(this->alloc_,
|
||||
p->value_ptr());
|
||||
node_allocator_traits::destroy(this->alloc_, boost::addressof(*p));
|
||||
boost::unordered::detail::func::destroy(boost::addressof(*p));
|
||||
node_allocator_traits::deallocate(this->alloc_, p, 1);
|
||||
}
|
||||
}
|
||||
@@ -537,12 +559,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
template <typename NodePointer>
|
||||
struct bucket
|
||||
{
|
||||
typedef NodePointer previous_pointer;
|
||||
previous_pointer next_;
|
||||
typedef NodePointer link_pointer;
|
||||
link_pointer next_;
|
||||
|
||||
bucket() : next_() {}
|
||||
|
||||
previous_pointer first_from_start()
|
||||
link_pointer first_from_start()
|
||||
{
|
||||
return next_;
|
||||
}
|
||||
@@ -552,12 +574,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
struct ptr_bucket
|
||||
{
|
||||
typedef ptr_bucket* previous_pointer;
|
||||
previous_pointer next_;
|
||||
typedef ptr_bucket* link_pointer;
|
||||
link_pointer next_;
|
||||
|
||||
ptr_bucket() : next_(0) {}
|
||||
|
||||
previous_pointer first_from_start()
|
||||
link_pointer first_from_start()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
@@ -568,8 +590,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Hash Policy
|
||||
//
|
||||
// Don't really want table to derive from this, but will for now.
|
||||
|
||||
template <typename SizeT>
|
||||
struct prime_policy
|
||||
@@ -645,11 +665,51 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef mix64_policy<std::size_t> type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct pick_policy :
|
||||
pick_policy_impl<
|
||||
std::numeric_limits<std::size_t>::digits,
|
||||
std::numeric_limits<std::size_t>::radix> {};
|
||||
|
||||
// While the mix policy is generally faster, the prime policy is a lot
|
||||
// faster when a large number consecutive integers are used, because
|
||||
// there are no collisions. Since that is probably quite common, use
|
||||
// prime policy for integeral types. But not the smaller ones, as they
|
||||
// don't have enough unique values for this to be an issue.
|
||||
|
||||
template <>
|
||||
struct pick_policy<int> {
|
||||
typedef prime_policy<std::size_t> type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pick_policy<unsigned int> {
|
||||
typedef prime_policy<std::size_t> type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pick_policy<long> {
|
||||
typedef prime_policy<std::size_t> type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pick_policy<unsigned long> {
|
||||
typedef prime_policy<std::size_t> type;
|
||||
};
|
||||
|
||||
// TODO: Maybe not if std::size_t is smaller than long long.
|
||||
#if !defined(BOOST_NO_LONG_LONG)
|
||||
template <>
|
||||
struct pick_policy<long long> {
|
||||
typedef prime_policy<std::size_t> type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pick_policy<unsigned long long> {
|
||||
typedef prime_policy<std::size_t> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Functions
|
||||
|
||||
@@ -664,12 +724,23 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// atomically assigns the new function objects in a strongly
|
||||
// exception safe manner.
|
||||
|
||||
template <class H, class P> class set_hash_functions;
|
||||
template <class H, class P, bool NoThrowMoveAssign>
|
||||
class set_hash_functions;
|
||||
|
||||
template <class H, class P>
|
||||
class functions
|
||||
{
|
||||
friend class boost::unordered::detail::set_hash_functions<H, P>;
|
||||
public:
|
||||
static const bool nothrow_move_assignable =
|
||||
boost::is_nothrow_move_assignable<H>::value &&
|
||||
boost::is_nothrow_move_assignable<P>::value;
|
||||
static const bool nothrow_move_constructible =
|
||||
boost::is_nothrow_move_constructible<H>::value &&
|
||||
boost::is_nothrow_move_constructible<P>::value;
|
||||
|
||||
private:
|
||||
friend class boost::unordered::detail::set_hash_functions<H, P,
|
||||
nothrow_move_assignable>;
|
||||
functions& operator=(functions const&);
|
||||
|
||||
typedef compressed<H, P> function_pair;
|
||||
@@ -686,23 +757,40 @@ namespace boost { namespace unordered { namespace detail {
|
||||
static_cast<void const*>(&funcs_[current_]));
|
||||
}
|
||||
|
||||
function_pair& current() {
|
||||
return *static_cast<function_pair*>(
|
||||
static_cast<void*>(&funcs_[current_]));
|
||||
}
|
||||
|
||||
void construct(bool which, H const& hf, P const& eq)
|
||||
{
|
||||
new((void*) &funcs_[which]) function_pair(hf, eq);
|
||||
}
|
||||
|
||||
void construct(bool which, function_pair const& f)
|
||||
void construct(bool which, function_pair const& f,
|
||||
boost::unordered::detail::false_type =
|
||||
boost::unordered::detail::false_type())
|
||||
{
|
||||
new((void*) &funcs_[which]) function_pair(f);
|
||||
}
|
||||
|
||||
void construct(bool which, function_pair& f,
|
||||
boost::unordered::detail::true_type)
|
||||
{
|
||||
new((void*) &funcs_[which]) function_pair(f,
|
||||
boost::unordered::detail::move_tag());
|
||||
}
|
||||
|
||||
void destroy(bool which)
|
||||
{
|
||||
boost::unordered::detail::destroy((function_pair*)(&funcs_[which]));
|
||||
boost::unordered::detail::func::destroy((function_pair*)(&funcs_[which]));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
typedef boost::unordered::detail::set_hash_functions<H, P,
|
||||
nothrow_move_assignable> set_hash_functions;
|
||||
|
||||
functions(H const& hf, P const& eq)
|
||||
: current_(false)
|
||||
{
|
||||
@@ -715,6 +803,14 @@ namespace boost { namespace unordered { namespace detail {
|
||||
construct(current_, bf.current());
|
||||
}
|
||||
|
||||
functions(functions& bf, boost::unordered::detail::move_tag)
|
||||
: current_(false)
|
||||
{
|
||||
construct(current_, bf.current(),
|
||||
boost::unordered::detail::integral_constant<bool,
|
||||
nothrow_move_constructible>());
|
||||
}
|
||||
|
||||
~functions() {
|
||||
this->destroy(current_);
|
||||
}
|
||||
@@ -727,26 +823,28 @@ namespace boost { namespace unordered { namespace detail {
|
||||
return current().second();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class H, class P>
|
||||
class set_hash_functions
|
||||
class set_hash_functions<H, P, false>
|
||||
{
|
||||
set_hash_functions(set_hash_functions const&);
|
||||
set_hash_functions& operator=(set_hash_functions const&);
|
||||
|
||||
typedef functions<H, P> functions_type;
|
||||
|
||||
functions<H,P>& functions_;
|
||||
functions_type& functions_;
|
||||
bool tmp_functions_;
|
||||
|
||||
public:
|
||||
|
||||
set_hash_functions(functions<H,P>& f, H const& h, P const& p)
|
||||
set_hash_functions(functions_type& f, H const& h, P const& p)
|
||||
: functions_(f),
|
||||
tmp_functions_(!f.current_)
|
||||
{
|
||||
f.construct(tmp_functions_, h, p);
|
||||
}
|
||||
|
||||
set_hash_functions(functions<H,P>& f, functions<H,P> const& other)
|
||||
set_hash_functions(functions_type& f, functions_type const& other)
|
||||
: functions_(f),
|
||||
tmp_functions_(!f.current_)
|
||||
{
|
||||
@@ -765,11 +863,42 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
};
|
||||
|
||||
template <class H, class P>
|
||||
class set_hash_functions<H, P, true>
|
||||
{
|
||||
set_hash_functions(set_hash_functions const&);
|
||||
set_hash_functions& operator=(set_hash_functions const&);
|
||||
|
||||
typedef functions<H, P> functions_type;
|
||||
|
||||
functions_type& functions_;
|
||||
H hash_;
|
||||
P pred_;
|
||||
|
||||
public:
|
||||
|
||||
set_hash_functions(functions_type& f, H const& h, P const& p) :
|
||||
functions_(f),
|
||||
hash_(h),
|
||||
pred_(p) {}
|
||||
|
||||
set_hash_functions(functions_type& f, functions_type const& other) :
|
||||
functions_(f),
|
||||
hash_(other.hash_function()),
|
||||
pred_(other.key_eq()) {}
|
||||
|
||||
void commit()
|
||||
{
|
||||
functions_.current().first() = boost::move(hash_);
|
||||
functions_.current().second() = boost::move(pred_);
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// rvalue parameters when type can't be a BOOST_RV_REF(T) parameter
|
||||
// e.g. for int
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
# define BOOST_UNORDERED_RV_REF(T) BOOST_RV_REF(T)
|
||||
#else
|
||||
struct please_ignore_this_overload {
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#ifndef BOOST_UNORDERED_DETAIL_EQUIVALENT_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_DETAIL_EQUIVALENT_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/detail/table.hpp>
|
||||
@@ -25,10 +26,13 @@ namespace boost { namespace unordered { namespace detail {
|
||||
boost::unordered::detail::value_base<T>
|
||||
{
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<
|
||||
A, grouped_node<A, T> >::type::pointer link_pointer;
|
||||
A, grouped_node<A, T> >::type allocator;
|
||||
typedef typename ::boost::unordered::detail::
|
||||
allocator_traits<allocator>::pointer node_pointer;
|
||||
typedef node_pointer link_pointer;
|
||||
|
||||
link_pointer next_;
|
||||
link_pointer group_prev_;
|
||||
node_pointer group_prev_;
|
||||
std::size_t hash_;
|
||||
|
||||
grouped_node() :
|
||||
@@ -37,7 +41,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
hash_(0)
|
||||
{}
|
||||
|
||||
void init(link_pointer self)
|
||||
void init(node_pointer self)
|
||||
{
|
||||
group_prev_ = self;
|
||||
}
|
||||
@@ -48,14 +52,16 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct grouped_ptr_node :
|
||||
boost::unordered::detail::value_base<T>,
|
||||
boost::unordered::detail::ptr_bucket
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef boost::unordered::detail::ptr_bucket bucket_base;
|
||||
typedef grouped_ptr_node<T>* node_pointer;
|
||||
typedef ptr_bucket* link_pointer;
|
||||
|
||||
link_pointer group_prev_;
|
||||
node_pointer group_prev_;
|
||||
std::size_t hash_;
|
||||
boost::unordered::detail::value_base<T> value_base_;
|
||||
|
||||
grouped_ptr_node() :
|
||||
bucket_base(),
|
||||
@@ -63,11 +69,15 @@ namespace boost { namespace unordered { namespace detail {
|
||||
hash_(0)
|
||||
{}
|
||||
|
||||
void init(link_pointer self)
|
||||
void init(node_pointer self)
|
||||
{
|
||||
group_prev_ = self;
|
||||
}
|
||||
|
||||
void* address() { return value_base_.address(); }
|
||||
value_type& value() { return value_base_.value(); }
|
||||
value_type* value_ptr() { return value_base_.value_ptr(); }
|
||||
|
||||
private:
|
||||
grouped_ptr_node& operator=(grouped_ptr_node const&);
|
||||
};
|
||||
@@ -141,7 +151,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef boost::unordered::detail::grouped_table_impl<types> table;
|
||||
typedef boost::unordered::detail::set_extractor<value_type> extractor;
|
||||
|
||||
typedef boost::unordered::detail::pick_policy::type policy;
|
||||
typedef typename boost::unordered::detail::pick_policy<T>::type policy;
|
||||
};
|
||||
|
||||
template <typename A, typename K, typename M, typename H, typename P>
|
||||
@@ -166,7 +176,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef boost::unordered::detail::map_extractor<key_type, value_type>
|
||||
extractor;
|
||||
|
||||
typedef boost::unordered::detail::pick_policy::type policy;
|
||||
typedef typename boost::unordered::detail::pick_policy<K>::type policy;
|
||||
};
|
||||
|
||||
template <typename Types>
|
||||
@@ -181,7 +191,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef typename table::node_allocator_traits node_allocator_traits;
|
||||
typedef typename table::bucket_pointer bucket_pointer;
|
||||
typedef typename table::link_pointer link_pointer;
|
||||
typedef typename table::previous_pointer previous_pointer;
|
||||
typedef typename table::hasher hasher;
|
||||
typedef typename table::key_equal key_equal;
|
||||
typedef typename table::key_type key_type;
|
||||
@@ -234,8 +243,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
Key const& k,
|
||||
Pred const& eq) const
|
||||
{
|
||||
std::size_t bucket_index =
|
||||
policy::to_bucket(this->bucket_count_, key_hash);
|
||||
std::size_t bucket_index = this->hash_to_bucket(key_hash);
|
||||
iterator n = this->begin(bucket_index);
|
||||
|
||||
for (;;)
|
||||
@@ -250,13 +258,11 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (policy::to_bucket(this->bucket_count_, node_hash)
|
||||
!= bucket_index)
|
||||
if (this->hash_to_bucket(node_hash) != bucket_index)
|
||||
return iterator();
|
||||
}
|
||||
|
||||
n = iterator(static_cast<node_pointer>(
|
||||
static_cast<node_pointer>(n.node_->group_prev_)->next_));
|
||||
n = iterator(n.node_->group_prev_->next_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +274,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
std::size_t x = 0;
|
||||
node_pointer it = n.node_;
|
||||
do {
|
||||
it = static_cast<node_pointer>(it->group_prev_);
|
||||
it = it->group_prev_;
|
||||
++x;
|
||||
} while(it != n.node_);
|
||||
|
||||
@@ -280,10 +286,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
{
|
||||
iterator n = this->find_node(k);
|
||||
return std::make_pair(
|
||||
n, n.node_ ? iterator(
|
||||
static_cast<node_pointer>(
|
||||
static_cast<node_pointer>(n.node_->group_prev_)->next_
|
||||
)) : n);
|
||||
n, n.node_ ? iterator(n.node_->group_prev_->next_) : n);
|
||||
}
|
||||
|
||||
// Equality
|
||||
@@ -296,10 +299,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
{
|
||||
iterator n2 = other.find_matching_node(n1);
|
||||
if (!n2.node_) return false;
|
||||
iterator end1(static_cast<node_pointer>(
|
||||
static_cast<node_pointer>(n1.node_->group_prev_)->next_));
|
||||
iterator end2(static_cast<node_pointer>(
|
||||
static_cast<node_pointer>(n2.node_->group_prev_)->next_));
|
||||
iterator end1(n1.node_->group_prev_->next_);
|
||||
iterator end2(n2.node_->group_prev_->next_);
|
||||
if (!group_equals(n1, end1, n2, end2)) return false;
|
||||
n1 = end1;
|
||||
}
|
||||
@@ -307,8 +308,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_UNORDERED_DEPRECATED_EQUALITY)
|
||||
|
||||
static bool group_equals(iterator n1, iterator end1,
|
||||
iterator n2, iterator end2)
|
||||
{
|
||||
@@ -369,37 +368,16 @@ namespace boost { namespace unordered { namespace detail {
|
||||
return count;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static bool group_equals(iterator n1, iterator end1,
|
||||
iterator n2, iterator end2)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(!extractor::compare_mapped(*n1, *n2))
|
||||
return false;
|
||||
|
||||
++n1;
|
||||
++n2;
|
||||
|
||||
if (n1 == end1) return n2 == end2;
|
||||
if (n2 == end2) return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Emplace/Insert
|
||||
|
||||
static inline void add_after_node(
|
||||
node_pointer n,
|
||||
node_pointer pos)
|
||||
{
|
||||
n->next_ = static_cast<node_pointer>(pos->group_prev_)->next_;
|
||||
n->next_ = pos->group_prev_->next_;
|
||||
n->group_prev_ = pos->group_prev_;
|
||||
static_cast<node_pointer>(pos->group_prev_)->next_ =
|
||||
static_cast<link_pointer>(n);
|
||||
pos->group_prev_ = static_cast<link_pointer>(n);
|
||||
pos->group_prev_->next_ = n;
|
||||
pos->group_prev_ = n;
|
||||
}
|
||||
|
||||
inline iterator add_node(
|
||||
@@ -412,37 +390,35 @@ namespace boost { namespace unordered { namespace detail {
|
||||
if (pos.node_) {
|
||||
this->add_after_node(n, pos.node_);
|
||||
if (n->next_) {
|
||||
std::size_t next_bucket = policy::to_bucket(
|
||||
this->bucket_count_,
|
||||
std::size_t next_bucket = this->hash_to_bucket(
|
||||
static_cast<node_pointer>(n->next_)->hash_);
|
||||
if (next_bucket !=
|
||||
policy::to_bucket(this->bucket_count_, key_hash)) {
|
||||
if (next_bucket != this->hash_to_bucket(key_hash)) {
|
||||
this->get_bucket(next_bucket)->next_ = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
bucket_pointer b = this->get_bucket(
|
||||
policy::to_bucket(this->bucket_count_, key_hash));
|
||||
this->hash_to_bucket(key_hash));
|
||||
|
||||
if (!b->next_)
|
||||
{
|
||||
previous_pointer start_node = this->get_previous_start();
|
||||
link_pointer start_node = this->get_previous_start();
|
||||
|
||||
if (start_node->next_) {
|
||||
this->get_bucket(policy::to_bucket(this->bucket_count_,
|
||||
this->get_bucket(this->hash_to_bucket(
|
||||
static_cast<node_pointer>(start_node->next_)->hash_
|
||||
))->next_ = n;
|
||||
}
|
||||
|
||||
b->next_ = start_node;
|
||||
n->next_ = start_node->next_;
|
||||
start_node->next_ = static_cast<link_pointer>(n);
|
||||
start_node->next_ = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
n->next_ = b->next_->next_;
|
||||
b->next_->next_ = static_cast<link_pointer>(n);
|
||||
b->next_->next_ = n;
|
||||
}
|
||||
}
|
||||
++this->size_;
|
||||
@@ -468,8 +444,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
this->add_node(a, key_hash, this->find_node(key_hash, k));
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
# if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
# if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
iterator emplace(boost::unordered::detail::emplace_args1<
|
||||
boost::unordered::detail::please_ignore_this_overload> const&)
|
||||
{
|
||||
@@ -545,11 +521,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
if(!this->size_) return 0;
|
||||
|
||||
std::size_t key_hash = this->hash(k);
|
||||
std::size_t bucket_index =
|
||||
policy::to_bucket(this->bucket_count_, key_hash);
|
||||
bucket_pointer this_bucket = this->get_bucket(bucket_index);
|
||||
|
||||
previous_pointer prev = this_bucket->next_;
|
||||
std::size_t bucket_index = this->hash_to_bucket(key_hash);
|
||||
link_pointer prev = this->get_previous_start(bucket_index);
|
||||
if (!prev) return 0;
|
||||
|
||||
for (;;)
|
||||
@@ -557,24 +530,21 @@ namespace boost { namespace unordered { namespace detail {
|
||||
if (!prev->next_) return 0;
|
||||
std::size_t node_hash =
|
||||
static_cast<node_pointer>(prev->next_)->hash_;
|
||||
if (policy::to_bucket(this->bucket_count_, node_hash)
|
||||
!= bucket_index)
|
||||
if (this->hash_to_bucket(node_hash) != bucket_index)
|
||||
return 0;
|
||||
if (node_hash == key_hash &&
|
||||
this->key_eq()(k, this->get_key(
|
||||
static_cast<node_pointer>(prev->next_)->value())))
|
||||
break;
|
||||
prev = static_cast<previous_pointer>(
|
||||
static_cast<node_pointer>(prev->next_)->group_prev_);
|
||||
prev = static_cast<node_pointer>(prev->next_)->group_prev_;
|
||||
}
|
||||
|
||||
node_pointer pos = static_cast<node_pointer>(prev->next_);
|
||||
link_pointer end1 =
|
||||
static_cast<node_pointer>(pos->group_prev_)->next_;
|
||||
node_pointer end = static_cast<node_pointer>(end1);
|
||||
prev->next_ = end1;
|
||||
this->fix_buckets(this_bucket, prev, end);
|
||||
return this->delete_nodes(c_iterator(pos), c_iterator(end));
|
||||
node_pointer first_node = static_cast<node_pointer>(prev->next_);
|
||||
link_pointer end = first_node->group_prev_->next_;
|
||||
|
||||
std::size_t deleted_count = this->delete_nodes(prev, end);
|
||||
this->fix_bucket(bucket_index, prev);
|
||||
return deleted_count;
|
||||
}
|
||||
|
||||
iterator erase(c_iterator r)
|
||||
@@ -582,130 +552,70 @@ namespace boost { namespace unordered { namespace detail {
|
||||
BOOST_ASSERT(r.node_);
|
||||
iterator next(r.node_);
|
||||
++next;
|
||||
|
||||
bucket_pointer this_bucket = this->get_bucket(
|
||||
policy::to_bucket(this->bucket_count_, r.node_->hash_));
|
||||
previous_pointer prev = unlink_node(*this_bucket, r.node_);
|
||||
|
||||
this->fix_buckets(this_bucket, prev, next.node_);
|
||||
|
||||
this->delete_node(r);
|
||||
|
||||
erase_nodes(r.node_, next.node_);
|
||||
return next;
|
||||
}
|
||||
|
||||
iterator erase_range(c_iterator r1, c_iterator r2)
|
||||
{
|
||||
if (r1 == r2) return iterator(r2.node_);
|
||||
|
||||
std::size_t bucket_index =
|
||||
policy::to_bucket(this->bucket_count_, r1.node_->hash_);
|
||||
previous_pointer prev = unlink_nodes(
|
||||
*this->get_bucket(bucket_index), r1.node_, r2.node_);
|
||||
this->fix_buckets_range(bucket_index, prev, r1.node_, r2.node_);
|
||||
this->delete_nodes(r1, r2);
|
||||
|
||||
erase_nodes(r1.node_, r2.node_);
|
||||
return iterator(r2.node_);
|
||||
}
|
||||
|
||||
static previous_pointer unlink_node(bucket& b, node_pointer n)
|
||||
link_pointer erase_nodes(node_pointer i, node_pointer j)
|
||||
{
|
||||
node_pointer next = static_cast<node_pointer>(n->next_);
|
||||
previous_pointer prev =
|
||||
static_cast<previous_pointer>(n->group_prev_);
|
||||
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
|
||||
|
||||
if(prev->next_ != n) {
|
||||
// The node is at the beginning of a group.
|
||||
// Split the groups containing 'i' and 'j'.
|
||||
// And get the pointer to the node before i while
|
||||
// we're at it.
|
||||
link_pointer prev = split_groups(i, j);
|
||||
|
||||
// Find the previous node pointer:
|
||||
prev = b.next_;
|
||||
while(prev->next_ != n) {
|
||||
prev = static_cast<previous_pointer>(
|
||||
static_cast<node_pointer>(prev->next_)->group_prev_);
|
||||
}
|
||||
|
||||
// Remove from group
|
||||
if (next && next->group_prev_ == static_cast<link_pointer>(n))
|
||||
{
|
||||
next->group_prev_ = n->group_prev_;
|
||||
}
|
||||
}
|
||||
else if (next && next->group_prev_ == static_cast<link_pointer>(n))
|
||||
{
|
||||
// The deleted node is not at the end of the group, so
|
||||
// change the link from the next node.
|
||||
next->group_prev_ = n->group_prev_;
|
||||
}
|
||||
else {
|
||||
// The deleted node is at the end of the group, so the
|
||||
// first node in the group is pointing to it.
|
||||
// Find that to change its pointer.
|
||||
node_pointer x = static_cast<node_pointer>(n->group_prev_);
|
||||
while(x->group_prev_ != static_cast<link_pointer>(n)) {
|
||||
x = static_cast<node_pointer>(x->group_prev_);
|
||||
}
|
||||
x->group_prev_ = n->group_prev_;
|
||||
// If we don't have a 'prev' it means that i is at the
|
||||
// beginning of a block, so search through the blocks in the
|
||||
// same bucket.
|
||||
if (!prev) {
|
||||
prev = this->get_previous_start(bucket_index);
|
||||
while (prev->next_ != i)
|
||||
prev = static_cast<node_pointer>(prev->next_)->group_prev_;
|
||||
}
|
||||
|
||||
prev->next_ = static_cast<link_pointer>(next);
|
||||
return prev;
|
||||
}
|
||||
|
||||
static previous_pointer unlink_nodes(bucket& b,
|
||||
node_pointer begin, node_pointer end)
|
||||
{
|
||||
previous_pointer prev = static_cast<previous_pointer>(
|
||||
begin->group_prev_);
|
||||
|
||||
if(prev->next_ != static_cast<link_pointer>(begin)) {
|
||||
// The node is at the beginning of a group.
|
||||
|
||||
// Find the previous node pointer:
|
||||
prev = b.next_;
|
||||
while(prev->next_ != static_cast<link_pointer>(begin))
|
||||
prev = static_cast<previous_pointer>(
|
||||
static_cast<node_pointer>(prev->next_)->group_prev_);
|
||||
|
||||
if (end) split_group(end);
|
||||
}
|
||||
else {
|
||||
node_pointer group1 = split_group(begin);
|
||||
|
||||
if (end) {
|
||||
node_pointer group2 = split_group(end);
|
||||
|
||||
if(begin == group2) {
|
||||
link_pointer end1 = group1->group_prev_;
|
||||
link_pointer end2 = end->group_prev_;
|
||||
group1->group_prev_ = end2;
|
||||
end->group_prev_ = end1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev->next_ = static_cast<link_pointer>(end);
|
||||
// Delete the nodes.
|
||||
do {
|
||||
link_pointer group_end =
|
||||
static_cast<node_pointer>(prev->next_)->group_prev_->next_;
|
||||
this->delete_nodes(prev, group_end);
|
||||
bucket_index = this->fix_bucket(bucket_index, prev);
|
||||
} while(prev->next_ != j);
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
// Break a ciruclar list into two, with split as the beginning
|
||||
// of the second group (if split is at the beginning then don't
|
||||
// split).
|
||||
static node_pointer split_group(node_pointer split)
|
||||
static link_pointer split_groups(node_pointer i, node_pointer j)
|
||||
{
|
||||
// Find first node in group.
|
||||
node_pointer first = split;
|
||||
while (static_cast<node_pointer>(first->group_prev_)->next_ ==
|
||||
static_cast<link_pointer>(first))
|
||||
first = static_cast<node_pointer>(first->group_prev_);
|
||||
node_pointer prev = i->group_prev_;
|
||||
if (prev->next_ != i) prev = node_pointer();
|
||||
|
||||
if(first == split) return split;
|
||||
if (j) {
|
||||
node_pointer first = j;
|
||||
while (first != i && first->group_prev_->next_ == first) {
|
||||
first = first->group_prev_;
|
||||
}
|
||||
|
||||
link_pointer last = first->group_prev_;
|
||||
first->group_prev_ = split->group_prev_;
|
||||
split->group_prev_ = last;
|
||||
boost::swap(first->group_prev_, j->group_prev_);
|
||||
if (first == i) return prev;
|
||||
}
|
||||
|
||||
return first;
|
||||
if (prev) {
|
||||
node_pointer first = prev;
|
||||
while (first->group_prev_->next_ == first) {
|
||||
first = first->group_prev_;
|
||||
}
|
||||
boost::swap(first->group_prev_, i->group_prev_);
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -715,19 +625,16 @@ namespace boost { namespace unordered { namespace detail {
|
||||
static void fill_buckets(iterator n, table& dst,
|
||||
NodeCreator& creator)
|
||||
{
|
||||
previous_pointer prev = dst.get_previous_start();
|
||||
link_pointer prev = dst.get_previous_start();
|
||||
|
||||
while (n.node_) {
|
||||
std::size_t key_hash = n.node_->hash_;
|
||||
iterator group_end(
|
||||
static_cast<node_pointer>(
|
||||
static_cast<node_pointer>(n.node_->group_prev_)->next_
|
||||
));
|
||||
iterator group_end(n.node_->group_prev_->next_);
|
||||
|
||||
node_pointer first_node = creator.create(*n);
|
||||
node_pointer end = first_node;
|
||||
first_node->hash_ = key_hash;
|
||||
prev->next_ = static_cast<link_pointer>(first_node);
|
||||
prev->next_ = first_node;
|
||||
++dst.size_;
|
||||
|
||||
for (++n; n != group_end; ++n)
|
||||
@@ -748,24 +655,22 @@ namespace boost { namespace unordered { namespace detail {
|
||||
BOOST_ASSERT(this->buckets_);
|
||||
|
||||
this->create_buckets(num_buckets);
|
||||
previous_pointer prev = this->get_previous_start();
|
||||
link_pointer prev = this->get_previous_start();
|
||||
while (prev->next_)
|
||||
prev = place_in_bucket(*this, prev,
|
||||
static_cast<node_pointer>(
|
||||
static_cast<node_pointer>(prev->next_)->group_prev_));
|
||||
static_cast<node_pointer>(prev->next_)->group_prev_);
|
||||
}
|
||||
|
||||
// Iterate through the nodes placing them in the correct buckets.
|
||||
// pre: prev->next_ is not null.
|
||||
static previous_pointer place_in_bucket(table& dst,
|
||||
previous_pointer prev, node_pointer end)
|
||||
static link_pointer place_in_bucket(table& dst,
|
||||
link_pointer prev, node_pointer end)
|
||||
{
|
||||
bucket_pointer b = dst.get_bucket(policy::to_bucket(
|
||||
dst.bucket_count_, end->hash_));
|
||||
bucket_pointer b = dst.get_bucket(dst.hash_to_bucket(end->hash_));
|
||||
|
||||
if (!b->next_) {
|
||||
b->next_ = static_cast<node_pointer>(prev);
|
||||
return static_cast<previous_pointer>(end);
|
||||
b->next_ = prev;
|
||||
return end;
|
||||
}
|
||||
else {
|
||||
link_pointer next = end->next_;
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
#ifndef BOOST_UNORDERED_DETAIL_EXTRACT_KEY_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_DETAIL_EXTRACT_KEY_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/detail/table.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -56,30 +61,25 @@ namespace detail {
|
||||
return no_key();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
static no_key extract(Args const&...)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
#else
|
||||
template <class Arg>
|
||||
static no_key extract(Arg const&)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class Arg1, class Arg2, class... Args>
|
||||
static no_key extract(Arg1 const&, Arg2 const&, Args const&...)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
#else
|
||||
template <class Arg1, class Arg2>
|
||||
static no_key extract(Arg1 const&, Arg2 const&)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool compare_mapped(value_type const&, value_type const&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Key, class ValueType>
|
||||
@@ -93,11 +93,6 @@ namespace detail {
|
||||
return v.first;
|
||||
}
|
||||
|
||||
static key_type const& extract(key_type const& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template <class Second>
|
||||
static key_type const& extract(std::pair<key_type, Second> const& v)
|
||||
{
|
||||
@@ -111,21 +106,6 @@ namespace detail {
|
||||
return v.first;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class Arg1, class... Args>
|
||||
static key_type const& extract(key_type const& k,
|
||||
Arg1 const&, Args const&...)
|
||||
{
|
||||
return k;
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
static no_key extract(Args const&...)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
#else
|
||||
|
||||
template <class Arg1>
|
||||
static key_type const& extract(key_type const& k, Arg1 const&)
|
||||
{
|
||||
@@ -143,19 +123,27 @@ namespace detail {
|
||||
return no_key();
|
||||
}
|
||||
|
||||
template <class Arg, class Arg1>
|
||||
static no_key extract(Arg const&, Arg1 const&)
|
||||
template <class Arg1, class Arg2>
|
||||
static no_key extract(Arg1 const&, Arg2 const&)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class Arg1, class Arg2, class Arg3, class... Args>
|
||||
static no_key extract(Arg1 const&, Arg2 const&, Arg3 const&,
|
||||
Args const&...)
|
||||
{
|
||||
return no_key();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_) \
|
||||
template <typename T2> \
|
||||
static no_key extract(boost::unordered::piecewise_construct_t, \
|
||||
namespace_::tuple<> const&, BOOST_FWD_REF(T2)) \
|
||||
namespace_ tuple<> const&, T2 const&) \
|
||||
{ \
|
||||
return no_key(); \
|
||||
} \
|
||||
@@ -163,17 +151,17 @@ namespace detail {
|
||||
template <typename T, typename T2> \
|
||||
static typename is_key<key_type, T>::type \
|
||||
extract(boost::unordered::piecewise_construct_t, \
|
||||
namespace_::tuple<T> const& k, BOOST_FWD_REF(T2)) \
|
||||
namespace_ tuple<T> const& k, T2 const&) \
|
||||
{ \
|
||||
return typename is_key<key_type, T>::type( \
|
||||
namespace_::get<0>(k)); \
|
||||
namespace_ get<0>(k)); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_) \
|
||||
static no_key extract(boost::unordered::piecewise_construct_t, \
|
||||
namespace_::tuple<> const&) \
|
||||
namespace_ tuple<> const&) \
|
||||
{ \
|
||||
return no_key(); \
|
||||
} \
|
||||
@@ -181,25 +169,19 @@ namespace detail {
|
||||
template <typename T> \
|
||||
static typename is_key<key_type, T>::type \
|
||||
extract(boost::unordered::piecewise_construct_t, \
|
||||
namespace_::tuple<T> const& k) \
|
||||
namespace_ tuple<T> const& k) \
|
||||
{ \
|
||||
return typename is_key<key_type, T>::type( \
|
||||
namespace_::get<0>(k)); \
|
||||
namespace_ get<0>(k)); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_UNORDERED_KEY_FROM_TUPLE(boost)
|
||||
BOOST_UNORDERED_KEY_FROM_TUPLE(boost::)
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
BOOST_UNORDERED_KEY_FROM_TUPLE(std)
|
||||
BOOST_UNORDERED_KEY_FROM_TUPLE(std::)
|
||||
#endif
|
||||
|
||||
|
||||
static bool compare_mapped(value_type const& x, value_type const& y)
|
||||
{
|
||||
return x.second == y.second;
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#ifndef BOOST_UNORDERED_FWD_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_FWD_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace unordered
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
#ifndef BOOST_UNORDERED_DETAIL_ALL_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_DETAIL_ALL_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/detail/buckets.hpp>
|
||||
#include <boost/unordered/detail/util.hpp>
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
@@ -18,6 +23,18 @@
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_UNORDERED_DEPRECATED_EQUALITY)
|
||||
|
||||
#if defined(__EDG__)
|
||||
#elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__)
|
||||
#pragma message("Warning: BOOST_UNORDERED_DEPRECATED_EQUALITY is no longer supported.")
|
||||
#elif defined(__GNUC__) || defined(__HP_aCC) || \
|
||||
defined(__SUNPRO_CC) || defined(__IBMCPP__)
|
||||
#warning "BOOST_UNORDERED_DEPRECATED_EQUALITY is no longer supported."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -42,6 +59,10 @@ namespace boost { namespace unordered { namespace detail {
|
||||
sizeof(value_type),
|
||||
boost::alignment_of<value_type>::value>::type data_;
|
||||
|
||||
value_base() :
|
||||
data_()
|
||||
{}
|
||||
|
||||
void* address() {
|
||||
return this;
|
||||
}
|
||||
@@ -125,7 +146,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
template <typename Types>
|
||||
struct table :
|
||||
Types::policy,
|
||||
boost::unordered::detail::functions<
|
||||
typename Types::hasher,
|
||||
typename Types::key_equal>
|
||||
@@ -148,6 +168,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef boost::unordered::detail::functions<
|
||||
typename Types::hasher,
|
||||
typename Types::key_equal> functions;
|
||||
typedef typename functions::set_hash_functions set_hash_functions;
|
||||
|
||||
typedef typename Types::allocator allocator;
|
||||
typedef typename boost::unordered::detail::
|
||||
@@ -164,20 +185,17 @@ namespace boost { namespace unordered { namespace detail {
|
||||
const_node_pointer;
|
||||
typedef typename bucket_allocator_traits::pointer
|
||||
bucket_pointer;
|
||||
typedef typename bucket::previous_pointer
|
||||
previous_pointer;
|
||||
typedef boost::unordered::detail::node_constructor<node_allocator>
|
||||
node_constructor;
|
||||
|
||||
typedef boost::unordered::iterator_detail::
|
||||
iterator<node_pointer, value_type> iterator;
|
||||
iterator<node> iterator;
|
||||
typedef boost::unordered::iterator_detail::
|
||||
c_iterator<const_node_pointer, node_pointer, value_type> c_iterator;
|
||||
c_iterator<node, const_node_pointer> c_iterator;
|
||||
typedef boost::unordered::iterator_detail::
|
||||
l_iterator<node_pointer, value_type, policy> l_iterator;
|
||||
l_iterator<node, policy> l_iterator;
|
||||
typedef boost::unordered::iterator_detail::
|
||||
cl_iterator<const_node_pointer, node_pointer, value_type, policy>
|
||||
cl_iterator;
|
||||
cl_iterator<node, const_node_pointer, policy> cl_iterator;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Members
|
||||
@@ -226,28 +244,31 @@ namespace boost { namespace unordered { namespace detail {
|
||||
return buckets_ + static_cast<std::ptrdiff_t>(bucket_index);
|
||||
}
|
||||
|
||||
previous_pointer get_previous_start() const
|
||||
link_pointer get_previous_start() const
|
||||
{
|
||||
return get_bucket(bucket_count_)->first_from_start();
|
||||
}
|
||||
|
||||
previous_pointer get_previous_start(std::size_t bucket_index) const
|
||||
link_pointer get_previous_start(std::size_t bucket_index) const
|
||||
{
|
||||
return get_bucket(bucket_index)->next_;
|
||||
}
|
||||
|
||||
iterator begin() const
|
||||
{
|
||||
return size_ ? iterator(static_cast<node_pointer>(
|
||||
get_previous_start()->next_)) : iterator();
|
||||
return size_ ? iterator(get_previous_start()->next_) : iterator();
|
||||
}
|
||||
|
||||
iterator begin(std::size_t bucket_index) const
|
||||
{
|
||||
if (!size_) return iterator();
|
||||
previous_pointer prev = get_previous_start(bucket_index);
|
||||
return prev ? iterator(static_cast<node_pointer>(prev->next_)) :
|
||||
iterator();
|
||||
link_pointer prev = get_previous_start(bucket_index);
|
||||
return prev ? iterator(prev->next_) : iterator();
|
||||
}
|
||||
|
||||
std::size_t hash_to_bucket(std::size_t hash_value) const
|
||||
{
|
||||
return policy::to_bucket(bucket_count_, hash_value);
|
||||
}
|
||||
|
||||
float load_factor() const
|
||||
@@ -263,8 +284,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
if (!it.node_) return 0;
|
||||
|
||||
std::size_t count = 0;
|
||||
while(it.node_ && policy::to_bucket(
|
||||
bucket_count_, it.node_->hash_) == index)
|
||||
while(it.node_ && hash_to_bucket(it.node_->hash_) == index)
|
||||
{
|
||||
++count;
|
||||
++it;
|
||||
@@ -353,7 +373,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
{}
|
||||
|
||||
table(table& x, boost::unordered::detail::move_tag m) :
|
||||
functions(x),
|
||||
functions(x, m),
|
||||
allocators_(x.allocators_, m),
|
||||
bucket_count_(x.bucket_count_),
|
||||
size_(x.size_),
|
||||
@@ -367,8 +387,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
|
||||
table(table& x, node_allocator const& a,
|
||||
boost::unordered::detail::move_tag) :
|
||||
functions(x),
|
||||
boost::unordered::detail::move_tag m) :
|
||||
functions(x, m),
|
||||
allocators_(a, a),
|
||||
bucket_count_(x.bucket_count_),
|
||||
size_(0),
|
||||
@@ -384,8 +404,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
{
|
||||
if (x.size_) {
|
||||
create_buckets(bucket_count_);
|
||||
copy_nodes<node_allocator> copy(node_alloc());
|
||||
table_impl::fill_buckets(x.begin(), *this, copy);
|
||||
copy_nodes<node_allocator> node_creator(node_alloc());
|
||||
table_impl::fill_buckets(x.begin(), *this, node_creator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,9 +418,9 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// TODO: Could pick new bucket size?
|
||||
create_buckets(bucket_count_);
|
||||
|
||||
move_nodes<node_allocator> move(node_alloc());
|
||||
move_nodes<node_allocator> node_creator(node_alloc());
|
||||
node_holder<node_allocator> nodes(x);
|
||||
table_impl::fill_buckets(nodes.begin(), *this, move);
|
||||
table_impl::fill_buckets(nodes.begin(), *this, node_creator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +465,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
void swap_allocators(table& other, false_type)
|
||||
{
|
||||
boost::unordered::detail::func::ignore_unused_variable_warning(other);
|
||||
|
||||
// According to 23.2.1.8, if propagate_on_container_swap is
|
||||
// false the behaviour is undefined unless the allocators
|
||||
// are equal.
|
||||
@@ -459,10 +481,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// Only swaps the allocators if propagate_on_container_swap
|
||||
void swap(table& x)
|
||||
{
|
||||
boost::unordered::detail::set_hash_functions<hasher, key_equal>
|
||||
op1(*this, x);
|
||||
boost::unordered::detail::set_hash_functions<hasher, key_equal>
|
||||
op2(x, *this);
|
||||
set_hash_functions op1(*this, x);
|
||||
set_hash_functions op2(x, *this);
|
||||
|
||||
// I think swap can throw if Propagate::value,
|
||||
// since the allocators' swap can throw. Not sure though.
|
||||
@@ -500,26 +520,28 @@ namespace boost { namespace unordered { namespace detail {
|
||||
delete_buckets();
|
||||
}
|
||||
|
||||
void delete_node(c_iterator n)
|
||||
void delete_node(link_pointer prev)
|
||||
{
|
||||
boost::unordered::detail::destroy_value_impl(node_alloc(),
|
||||
n.node_->value_ptr());
|
||||
node_allocator_traits::destroy(node_alloc(),
|
||||
boost::addressof(*n.node_));
|
||||
node_allocator_traits::deallocate(node_alloc(), n.node_, 1);
|
||||
node_pointer n = static_cast<node_pointer>(prev->next_);
|
||||
prev->next_ = n->next_;
|
||||
|
||||
boost::unordered::detail::func::destroy_value_impl(node_alloc(),
|
||||
n->value_ptr());
|
||||
boost::unordered::detail::func::destroy(boost::addressof(*n));
|
||||
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
||||
--size_;
|
||||
}
|
||||
|
||||
std::size_t delete_nodes(c_iterator begin, c_iterator end)
|
||||
std::size_t delete_nodes(link_pointer prev, link_pointer end)
|
||||
{
|
||||
BOOST_ASSERT(prev->next_ != end);
|
||||
|
||||
std::size_t count = 0;
|
||||
|
||||
while(begin != end) {
|
||||
c_iterator n = begin;
|
||||
++begin;
|
||||
delete_node(n);
|
||||
do {
|
||||
delete_node(prev);
|
||||
++count;
|
||||
}
|
||||
} while (prev->next_ != end);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -527,12 +549,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
void delete_buckets()
|
||||
{
|
||||
if(buckets_) {
|
||||
delete_nodes(begin(), iterator());
|
||||
if (size_) delete_nodes(get_previous_start(), link_pointer());
|
||||
|
||||
if (bucket::extra_node) {
|
||||
node_pointer n = static_cast<node_pointer>(
|
||||
get_bucket(bucket_count_)->next_);
|
||||
node_allocator_traits::destroy(node_alloc(),
|
||||
boost::unordered::detail::func::destroy(
|
||||
boost::addressof(*n));
|
||||
node_allocator_traits::deallocate(node_alloc(), n, 1);
|
||||
}
|
||||
@@ -547,10 +569,9 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
void clear()
|
||||
{
|
||||
if(!size_) return;
|
||||
if (!size_) return;
|
||||
|
||||
delete_nodes(begin(), iterator());
|
||||
get_previous_start()->next_ = link_pointer();
|
||||
delete_nodes(get_previous_start(), link_pointer());
|
||||
clear_buckets();
|
||||
|
||||
BOOST_ASSERT(!size_);
|
||||
@@ -570,7 +591,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
bucket_pointer end = get_bucket(bucket_count_ + 1);
|
||||
for(bucket_pointer it = buckets_; it != end; ++it)
|
||||
{
|
||||
bucket_allocator_traits::destroy(bucket_alloc(),
|
||||
boost::unordered::detail::func::destroy(
|
||||
boost::addressof(*it));
|
||||
}
|
||||
|
||||
@@ -579,86 +600,33 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Fix buckets after erase
|
||||
// Fix buckets after delete
|
||||
//
|
||||
|
||||
// This is called after erasing a node or group of nodes to fix up
|
||||
// the bucket pointers.
|
||||
void fix_buckets(bucket_pointer this_bucket,
|
||||
previous_pointer prev, node_pointer next)
|
||||
std::size_t fix_bucket(std::size_t bucket_index, link_pointer prev)
|
||||
{
|
||||
if (!next)
|
||||
link_pointer end = prev->next_;
|
||||
std::size_t bucket_index2 = bucket_index;
|
||||
|
||||
if (end)
|
||||
{
|
||||
if (this_bucket->next_ == prev)
|
||||
this_bucket->next_ = node_pointer();
|
||||
}
|
||||
else
|
||||
{
|
||||
bucket_pointer next_bucket = get_bucket(
|
||||
policy::to_bucket(bucket_count_, next->hash_));
|
||||
bucket_index2 = hash_to_bucket(
|
||||
static_cast<node_pointer>(end)->hash_);
|
||||
|
||||
if (next_bucket != this_bucket)
|
||||
{
|
||||
next_bucket->next_ = prev;
|
||||
if (this_bucket->next_ == prev)
|
||||
this_bucket->next_ = node_pointer();
|
||||
}
|
||||
}
|
||||
}
|
||||
// If begin and end are in the same bucket, then
|
||||
// there's nothing to do.
|
||||
if (bucket_index == bucket_index2) return bucket_index2;
|
||||
|
||||
// This is called after erasing a range of nodes to fix any bucket
|
||||
// pointers into that range.
|
||||
void fix_buckets_range(std::size_t bucket_index,
|
||||
previous_pointer prev, node_pointer begin, node_pointer end)
|
||||
{
|
||||
node_pointer n = begin;
|
||||
|
||||
// If we're not at the start of the current bucket, then
|
||||
// go to the start of the next bucket.
|
||||
if (get_bucket(bucket_index)->next_ != prev)
|
||||
{
|
||||
for(;;) {
|
||||
n = static_cast<node_pointer>(n->next_);
|
||||
if (n == end) {
|
||||
if (n) {
|
||||
std::size_t new_bucket_index =
|
||||
policy::to_bucket(bucket_count_, n->hash_);
|
||||
if (bucket_index != new_bucket_index) {
|
||||
get_bucket(new_bucket_index)->next_ = prev;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t new_bucket_index =
|
||||
policy::to_bucket(bucket_count_, n->hash_);
|
||||
if (bucket_index != new_bucket_index) {
|
||||
bucket_index = new_bucket_index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Update the bucket containing end.
|
||||
get_bucket(bucket_index2)->next_ = prev;
|
||||
}
|
||||
|
||||
// Iterate through the remaining nodes, clearing out the bucket
|
||||
// pointers.
|
||||
get_bucket(bucket_index)->next_ = previous_pointer();
|
||||
for(;;) {
|
||||
n = static_cast<node_pointer>(n->next_);
|
||||
if (n == end) break;
|
||||
// Check if this bucket is now empty.
|
||||
bucket_pointer this_bucket = get_bucket(bucket_index);
|
||||
if (this_bucket->next_ == prev)
|
||||
this_bucket->next_ = link_pointer();
|
||||
|
||||
std::size_t new_bucket_index =
|
||||
policy::to_bucket(bucket_count_, n->hash_);
|
||||
if (bucket_index != new_bucket_index) {
|
||||
bucket_index = new_bucket_index;
|
||||
get_bucket(bucket_index)->next_ = previous_pointer();
|
||||
}
|
||||
};
|
||||
|
||||
// Finally fix the bucket containing the trailing node.
|
||||
if (n) {
|
||||
get_bucket(
|
||||
policy::to_bucket(bucket_count_, n->hash_))->next_
|
||||
= prev;
|
||||
}
|
||||
return bucket_index2;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -678,8 +646,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
void assign(table const& x, false_type)
|
||||
{
|
||||
// Strong exception safety.
|
||||
boost::unordered::detail::set_hash_functions<hasher, key_equal>
|
||||
new_func_this(*this, x);
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
new_func_this.commit();
|
||||
mlf_ = x.mlf_;
|
||||
recalculate_max_load();
|
||||
@@ -696,8 +663,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// assign_nodes takes ownership of the container's elements,
|
||||
// assigning to them if possible, and deleting any that are
|
||||
// left over.
|
||||
assign_nodes<table> assign(*this);
|
||||
table_impl::fill_buckets(x.begin(), *this, assign);
|
||||
assign_nodes<table> node_creator(*this);
|
||||
table_impl::fill_buckets(x.begin(), *this, node_creator);
|
||||
}
|
||||
|
||||
void assign(table const& x, true_type)
|
||||
@@ -707,8 +674,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
assign(x, false_type());
|
||||
}
|
||||
else {
|
||||
boost::unordered::detail::set_hash_functions<hasher, key_equal>
|
||||
new_func_this(*this, x);
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
|
||||
// Delete everything with current allocators before assigning
|
||||
// the new ones.
|
||||
@@ -724,8 +690,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// Finally copy the elements.
|
||||
if (x.size_) {
|
||||
create_buckets(bucket_count_);
|
||||
copy_nodes<node_allocator> copy(node_alloc());
|
||||
table_impl::fill_buckets(x.begin(), *this, copy);
|
||||
copy_nodes<node_allocator> node_creator(node_alloc());
|
||||
table_impl::fill_buckets(x.begin(), *this, node_creator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -755,8 +721,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
move_assign_no_alloc(x);
|
||||
}
|
||||
else {
|
||||
boost::unordered::detail::set_hash_functions<hasher, key_equal>
|
||||
new_func_this(*this, x);
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
new_func_this.commit();
|
||||
mlf_ = x.mlf_;
|
||||
recalculate_max_load();
|
||||
@@ -773,16 +738,15 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// move_assign_nodes takes ownership of the container's
|
||||
// elements, assigning to them if possible, and deleting
|
||||
// any that are left over.
|
||||
move_assign_nodes<table> assign(*this);
|
||||
move_assign_nodes<table> node_creator(*this);
|
||||
node_holder<node_allocator> nodes(x);
|
||||
table_impl::fill_buckets(nodes.begin(), *this, assign);
|
||||
table_impl::fill_buckets(nodes.begin(), *this, node_creator);
|
||||
}
|
||||
}
|
||||
|
||||
void move_assign_no_alloc(table& x)
|
||||
{
|
||||
boost::unordered::detail::set_hash_functions<hasher, key_equal>
|
||||
new_func_this(*this, x);
|
||||
set_hash_functions new_func_this(*this, x);
|
||||
// No throw from here.
|
||||
mlf_ = x.mlf_;
|
||||
max_load_ = x.max_load_;
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#ifndef BOOST_UNORDERED_DETAIL_UNIQUE_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_DETAIL_UNIQUE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/detail/table.hpp>
|
||||
@@ -27,7 +28,10 @@ namespace boost { namespace unordered { namespace detail {
|
||||
boost::unordered::detail::value_base<T>
|
||||
{
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<
|
||||
A, unique_node<A, T> >::type::pointer link_pointer;
|
||||
A, unique_node<A, T> >::type allocator;
|
||||
typedef typename ::boost::unordered::detail::
|
||||
allocator_traits<allocator>::pointer node_pointer;
|
||||
typedef node_pointer link_pointer;
|
||||
|
||||
link_pointer next_;
|
||||
std::size_t hash_;
|
||||
@@ -37,7 +41,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
hash_(0)
|
||||
{}
|
||||
|
||||
void init(link_pointer)
|
||||
void init(node_pointer)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,23 +51,29 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct ptr_node :
|
||||
boost::unordered::detail::value_base<T>,
|
||||
boost::unordered::detail::ptr_bucket
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef boost::unordered::detail::ptr_bucket bucket_base;
|
||||
typedef ptr_node<T>* node_pointer;
|
||||
typedef ptr_bucket* link_pointer;
|
||||
|
||||
std::size_t hash_;
|
||||
boost::unordered::detail::value_base<T> value_base_;
|
||||
|
||||
ptr_node() :
|
||||
bucket_base(),
|
||||
hash_(0)
|
||||
{}
|
||||
|
||||
void init(link_pointer)
|
||||
void init(node_pointer)
|
||||
{
|
||||
}
|
||||
|
||||
void* address() { return value_base_.address(); }
|
||||
value_type& value() { return value_base_.value(); }
|
||||
value_type* value_ptr() { return value_base_.value_ptr(); }
|
||||
|
||||
private:
|
||||
ptr_node& operator=(ptr_node const&);
|
||||
};
|
||||
@@ -136,7 +146,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef boost::unordered::detail::table_impl<types> table;
|
||||
typedef boost::unordered::detail::set_extractor<value_type> extractor;
|
||||
|
||||
typedef boost::unordered::detail::pick_policy::type policy;
|
||||
typedef typename boost::unordered::detail::pick_policy<T>::type policy;
|
||||
};
|
||||
|
||||
template <typename A, typename K, typename M, typename H, typename P>
|
||||
@@ -161,7 +171,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef boost::unordered::detail::map_extractor<key_type, value_type>
|
||||
extractor;
|
||||
|
||||
typedef boost::unordered::detail::pick_policy::type policy;
|
||||
typedef typename boost::unordered::detail::pick_policy<K>::type policy;
|
||||
};
|
||||
|
||||
template <typename Types>
|
||||
@@ -176,7 +186,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
typedef typename table::node_allocator_traits node_allocator_traits;
|
||||
typedef typename table::bucket_pointer bucket_pointer;
|
||||
typedef typename table::link_pointer link_pointer;
|
||||
typedef typename table::previous_pointer previous_pointer;
|
||||
typedef typename table::hasher hasher;
|
||||
typedef typename table::key_equal key_equal;
|
||||
typedef typename table::key_type key_type;
|
||||
@@ -231,8 +240,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
Key const& k,
|
||||
Pred const& eq) const
|
||||
{
|
||||
std::size_t bucket_index =
|
||||
policy::to_bucket(this->bucket_count_, key_hash);
|
||||
std::size_t bucket_index = this->hash_to_bucket(key_hash);
|
||||
iterator n = this->begin(bucket_index);
|
||||
|
||||
for (;;)
|
||||
@@ -247,8 +255,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (policy::to_bucket(this->bucket_count_, node_hash)
|
||||
!= bucket_index)
|
||||
if (this->hash_to_bucket(node_hash) != bucket_index)
|
||||
return iterator();
|
||||
}
|
||||
|
||||
@@ -291,13 +298,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
{
|
||||
iterator n2 = other.find_matching_node(n1);
|
||||
|
||||
#if !defined(BOOST_UNORDERED_DEPRECATED_EQUALITY)
|
||||
if (!n2.node_ || *n1 != *n2)
|
||||
return false;
|
||||
#else
|
||||
if (!n2.node_ || !extractor::compare_mapped(*n1, *n2))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -312,27 +314,26 @@ namespace boost { namespace unordered { namespace detail {
|
||||
node_pointer n = a.release();
|
||||
n->hash_ = key_hash;
|
||||
|
||||
bucket_pointer b = this->get_bucket(
|
||||
policy::to_bucket(this->bucket_count_, key_hash));
|
||||
bucket_pointer b = this->get_bucket(this->hash_to_bucket(key_hash));
|
||||
|
||||
if (!b->next_)
|
||||
{
|
||||
previous_pointer start_node = this->get_previous_start();
|
||||
link_pointer start_node = this->get_previous_start();
|
||||
|
||||
if (start_node->next_) {
|
||||
this->get_bucket(policy::to_bucket(this->bucket_count_,
|
||||
this->get_bucket(this->hash_to_bucket(
|
||||
static_cast<node_pointer>(start_node->next_)->hash_)
|
||||
)->next_ = n;
|
||||
}
|
||||
|
||||
b->next_ = start_node;
|
||||
n->next_ = start_node->next_;
|
||||
start_node->next_ = static_cast<link_pointer>(n);
|
||||
start_node->next_ = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
n->next_ = b->next_->next_;
|
||||
b->next_->next_ = static_cast<link_pointer>(n);
|
||||
b->next_->next_ = n;
|
||||
}
|
||||
|
||||
++this->size_;
|
||||
@@ -341,8 +342,6 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
value_type& operator[](key_type const& k)
|
||||
{
|
||||
typedef typename value_type::second_type mapped_type;
|
||||
|
||||
std::size_t key_hash = this->hash(k);
|
||||
iterator pos = this->find_node(key_hash, k);
|
||||
|
||||
@@ -360,8 +359,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
return *add_node(a, key_hash);
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
# if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
# if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
emplace_return emplace(boost::unordered::detail::emplace_args1<
|
||||
boost::unordered::detail::please_ignore_this_overload> const&)
|
||||
{
|
||||
@@ -381,7 +380,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||
emplace_return emplace(BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
{
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
return emplace_impl(
|
||||
extractor::extract(BOOST_UNORDERED_EMPLACE_FORWARD),
|
||||
BOOST_UNORDERED_EMPLACE_FORWARD);
|
||||
@@ -392,7 +391,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <typename A0>
|
||||
emplace_return emplace(
|
||||
boost::unordered::detail::emplace_args1<A0> const& args)
|
||||
@@ -518,11 +517,8 @@ namespace boost { namespace unordered { namespace detail {
|
||||
if(!this->size_) return 0;
|
||||
|
||||
std::size_t key_hash = this->hash(k);
|
||||
std::size_t bucket_index =
|
||||
policy::to_bucket(this->bucket_count_, key_hash);
|
||||
bucket_pointer this_bucket = this->get_bucket(bucket_index);
|
||||
|
||||
previous_pointer prev = this_bucket->next_;
|
||||
std::size_t bucket_index = this->hash_to_bucket(key_hash);
|
||||
link_pointer prev = this->get_previous_start(bucket_index);
|
||||
if (!prev) return 0;
|
||||
|
||||
for (;;)
|
||||
@@ -530,21 +526,20 @@ namespace boost { namespace unordered { namespace detail {
|
||||
if (!prev->next_) return 0;
|
||||
std::size_t node_hash =
|
||||
static_cast<node_pointer>(prev->next_)->hash_;
|
||||
if (policy::to_bucket(this->bucket_count_, node_hash)
|
||||
!= bucket_index)
|
||||
if (this->hash_to_bucket(node_hash) != bucket_index)
|
||||
return 0;
|
||||
if (node_hash == key_hash &&
|
||||
this->key_eq()(k, this->get_key(
|
||||
static_cast<node_pointer>(prev->next_)->value())))
|
||||
break;
|
||||
prev = static_cast<previous_pointer>(prev->next_);
|
||||
prev = prev->next_;
|
||||
}
|
||||
|
||||
node_pointer pos = static_cast<node_pointer>(prev->next_);
|
||||
node_pointer end = static_cast<node_pointer>(pos->next_);
|
||||
prev->next_ = pos->next_;
|
||||
this->fix_buckets(this_bucket, prev, end);
|
||||
return this->delete_nodes(c_iterator(pos), c_iterator(end));
|
||||
link_pointer end = static_cast<node_pointer>(prev->next_)->next_;
|
||||
|
||||
std::size_t deleted_count = this->delete_nodes(prev, end);
|
||||
this->fix_bucket(bucket_index, prev);
|
||||
return deleted_count;
|
||||
}
|
||||
|
||||
iterator erase(c_iterator r)
|
||||
@@ -552,46 +547,30 @@ namespace boost { namespace unordered { namespace detail {
|
||||
BOOST_ASSERT(r.node_);
|
||||
iterator next(r.node_);
|
||||
++next;
|
||||
|
||||
bucket_pointer this_bucket = this->get_bucket(
|
||||
policy::to_bucket(this->bucket_count_, r.node_->hash_));
|
||||
previous_pointer prev = unlink_node(*this_bucket, r.node_);
|
||||
|
||||
this->fix_buckets(this_bucket, prev, next.node_);
|
||||
|
||||
this->delete_node(r);
|
||||
|
||||
erase_nodes(r.node_, next.node_);
|
||||
return next;
|
||||
}
|
||||
|
||||
iterator erase_range(c_iterator r1, c_iterator r2)
|
||||
{
|
||||
if (r1 == r2) return iterator(r2.node_);
|
||||
|
||||
std::size_t bucket_index =
|
||||
policy::to_bucket(this->bucket_count_, r1.node_->hash_);
|
||||
previous_pointer prev = unlink_nodes(
|
||||
*this->get_bucket(bucket_index), r1.node_, r2.node_);
|
||||
this->fix_buckets_range(bucket_index, prev, r1.node_, r2.node_);
|
||||
this->delete_nodes(r1, r2);
|
||||
|
||||
erase_nodes(r1.node_, r2.node_);
|
||||
return iterator(r2.node_);
|
||||
}
|
||||
|
||||
static previous_pointer unlink_node(bucket& b, node_pointer n)
|
||||
void erase_nodes(node_pointer i, node_pointer j)
|
||||
{
|
||||
return unlink_nodes(b, n, static_cast<node_pointer>(n->next_));
|
||||
}
|
||||
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
|
||||
|
||||
static previous_pointer unlink_nodes(bucket& b,
|
||||
node_pointer begin, node_pointer end)
|
||||
{
|
||||
previous_pointer prev = b.next_;
|
||||
link_pointer begin_void = static_cast<link_pointer>(begin);
|
||||
while(prev->next_ != begin_void)
|
||||
prev = static_cast<previous_pointer>(prev->next_);
|
||||
prev->next_ = static_cast<link_pointer>(end);
|
||||
return prev;
|
||||
// Find the node before i.
|
||||
link_pointer prev = this->get_previous_start(bucket_index);
|
||||
while(prev->next_ != i) prev = prev->next_;
|
||||
|
||||
// Delete the nodes.
|
||||
do {
|
||||
this->delete_node(prev);
|
||||
bucket_index = this->fix_bucket(bucket_index, prev);
|
||||
} while (prev->next_ != j);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -601,12 +580,12 @@ namespace boost { namespace unordered { namespace detail {
|
||||
static void fill_buckets(iterator n, table& dst,
|
||||
NodeCreator& creator)
|
||||
{
|
||||
previous_pointer prev = dst.get_previous_start();
|
||||
link_pointer prev = dst.get_previous_start();
|
||||
|
||||
while (n.node_) {
|
||||
node_pointer node = creator.create(*n);
|
||||
node->hash_ = n.node_->hash_;
|
||||
prev->next_ = static_cast<link_pointer>(node);
|
||||
prev->next_ = node;
|
||||
++dst.size_;
|
||||
++n;
|
||||
|
||||
@@ -620,28 +599,26 @@ namespace boost { namespace unordered { namespace detail {
|
||||
BOOST_ASSERT(this->buckets_);
|
||||
|
||||
this->create_buckets(num_buckets);
|
||||
previous_pointer prev = this->get_previous_start();
|
||||
link_pointer prev = this->get_previous_start();
|
||||
while (prev->next_)
|
||||
prev = place_in_bucket(*this, prev);
|
||||
}
|
||||
|
||||
// Iterate through the nodes placing them in the correct buckets.
|
||||
// pre: prev->next_ is not null.
|
||||
static previous_pointer place_in_bucket(table& dst,
|
||||
previous_pointer prev)
|
||||
static link_pointer place_in_bucket(table& dst, link_pointer prev)
|
||||
{
|
||||
node_pointer n = static_cast<node_pointer>(prev->next_);
|
||||
bucket_pointer b = dst.get_bucket(
|
||||
table::to_bucket(dst.bucket_count_, n->hash_));
|
||||
bucket_pointer b = dst.get_bucket(dst.hash_to_bucket(n->hash_));
|
||||
|
||||
if (!b->next_) {
|
||||
b->next_ = prev;
|
||||
return static_cast<previous_pointer>(n);
|
||||
return n;
|
||||
}
|
||||
else {
|
||||
prev->next_ = n->next_;
|
||||
n->next_ = b->next_->next_;
|
||||
b->next_->next_ = static_cast<link_pointer>(n);
|
||||
b->next_->next_ = n;
|
||||
return prev;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#ifndef BOOST_UNORDERED_DETAIL_UTIL_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_DETAIL_UTIL_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
@@ -28,6 +29,11 @@ namespace boost { namespace unordered { namespace detail {
|
||||
struct move_tag {};
|
||||
struct empty_emplace {};
|
||||
|
||||
namespace func {
|
||||
template <class T>
|
||||
inline void ignore_unused_variable_warning(T const&) {}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// iterator SFINAE
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#ifndef BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/unordered_map_fwd.hpp>
|
||||
@@ -117,17 +118,19 @@ namespace unordered
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_map(BOOST_RV_REF(unordered_map) other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_map(unordered_map&& other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_map(unordered_map&&, allocator_type const&);
|
||||
#endif
|
||||
|
||||
@@ -142,7 +145,7 @@ namespace unordered
|
||||
|
||||
// Destructor
|
||||
|
||||
~unordered_map();
|
||||
~unordered_map() BOOST_NOEXCEPT;
|
||||
|
||||
// Assign
|
||||
|
||||
@@ -165,7 +168,7 @@ namespace unordered
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_map& operator=(unordered_map&& x)
|
||||
{
|
||||
table_.move_assign(x.table_);
|
||||
@@ -178,60 +181,60 @@ namespace unordered
|
||||
unordered_map& operator=(std::initializer_list<value_type>);
|
||||
#endif
|
||||
|
||||
allocator_type get_allocator() const
|
||||
allocator_type get_allocator() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.node_alloc();
|
||||
}
|
||||
|
||||
// size and capacity
|
||||
|
||||
bool empty() const
|
||||
bool empty() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_ == 0;
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
size_type size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_;
|
||||
}
|
||||
|
||||
size_type max_size() const;
|
||||
size_type max_size() const BOOST_NOEXCEPT;
|
||||
|
||||
// iterators
|
||||
|
||||
iterator begin()
|
||||
iterator begin() BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
const_iterator begin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
iterator end()
|
||||
iterator end() BOOST_NOEXCEPT
|
||||
{
|
||||
return iterator();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
const_iterator end() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
const_iterator cbegin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
const_iterator cend() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
@@ -449,12 +452,12 @@ namespace unordered
|
||||
|
||||
// bucket interface
|
||||
|
||||
size_type bucket_count() const
|
||||
size_type bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.bucket_count_;
|
||||
}
|
||||
|
||||
size_type max_bucket_count() const
|
||||
size_type max_bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_bucket_count();
|
||||
}
|
||||
@@ -463,8 +466,7 @@ namespace unordered
|
||||
|
||||
size_type bucket(const key_type& k) const
|
||||
{
|
||||
return table::to_bucket(table_.bucket_count_,
|
||||
table_.hash(k));
|
||||
return table_.hash_to_bucket(table_.hash(k));
|
||||
}
|
||||
|
||||
local_iterator begin(size_type n)
|
||||
@@ -502,13 +504,13 @@ namespace unordered
|
||||
|
||||
// hash policy
|
||||
|
||||
float max_load_factor() const
|
||||
float max_load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.mlf_;
|
||||
}
|
||||
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
float load_factor() const BOOST_NOEXCEPT;
|
||||
void max_load_factor(float) BOOST_NOEXCEPT;
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
@@ -599,17 +601,19 @@ namespace unordered
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multimap(unordered_multimap&& other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multimap(unordered_multimap&&, allocator_type const&);
|
||||
#endif
|
||||
|
||||
@@ -624,7 +628,7 @@ namespace unordered
|
||||
|
||||
// Destructor
|
||||
|
||||
~unordered_multimap();
|
||||
~unordered_multimap() BOOST_NOEXCEPT;
|
||||
|
||||
// Assign
|
||||
|
||||
@@ -648,7 +652,7 @@ namespace unordered
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multimap& operator=(unordered_multimap&& x)
|
||||
{
|
||||
table_.move_assign(x.table_);
|
||||
@@ -661,60 +665,60 @@ namespace unordered
|
||||
unordered_multimap& operator=(std::initializer_list<value_type>);
|
||||
#endif
|
||||
|
||||
allocator_type get_allocator() const
|
||||
allocator_type get_allocator() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.node_alloc();
|
||||
}
|
||||
|
||||
// size and capacity
|
||||
|
||||
bool empty() const
|
||||
bool empty() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_ == 0;
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
size_type size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_;
|
||||
}
|
||||
|
||||
size_type max_size() const;
|
||||
size_type max_size() const BOOST_NOEXCEPT;
|
||||
|
||||
// iterators
|
||||
|
||||
iterator begin()
|
||||
iterator begin() BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
const_iterator begin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
iterator end()
|
||||
iterator end() BOOST_NOEXCEPT
|
||||
{
|
||||
return iterator();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
const_iterator end() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
const_iterator cbegin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
const_iterator cend() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
iterator emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
@@ -928,12 +932,12 @@ namespace unordered
|
||||
|
||||
// bucket interface
|
||||
|
||||
size_type bucket_count() const
|
||||
size_type bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.bucket_count_;
|
||||
}
|
||||
|
||||
size_type max_bucket_count() const
|
||||
size_type max_bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_bucket_count();
|
||||
}
|
||||
@@ -942,8 +946,7 @@ namespace unordered
|
||||
|
||||
size_type bucket(const key_type& k) const
|
||||
{
|
||||
return table::to_bucket(table_.bucket_count_,
|
||||
table_.hash(k));
|
||||
return table_.hash_to_bucket(table_.hash(k));
|
||||
}
|
||||
|
||||
local_iterator begin(size_type n)
|
||||
@@ -981,13 +984,13 @@ namespace unordered
|
||||
|
||||
// hash policy
|
||||
|
||||
float max_load_factor() const
|
||||
float max_load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.mlf_;
|
||||
}
|
||||
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
float load_factor() const BOOST_NOEXCEPT;
|
||||
void max_load_factor(float) BOOST_NOEXCEPT;
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
@@ -1059,7 +1062,7 @@ namespace unordered
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
unordered_map<K,T,H,P,A>::~unordered_map() {}
|
||||
unordered_map<K,T,H,P,A>::~unordered_map() BOOST_NOEXCEPT {}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
unordered_map<K,T,H,P,A>::unordered_map(
|
||||
@@ -1068,7 +1071,7 @@ namespace unordered
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
unordered_map<K,T,H,P,A>::unordered_map(
|
||||
@@ -1107,7 +1110,7 @@ namespace unordered
|
||||
// size and capacity
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
std::size_t unordered_map<K,T,H,P,A>::max_size() const
|
||||
std::size_t unordered_map<K,T,H,P,A>::max_size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_size();
|
||||
}
|
||||
@@ -1276,13 +1279,13 @@ namespace unordered
|
||||
// hash policy
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
float unordered_map<K,T,H,P,A>::load_factor() const
|
||||
float unordered_map<K,T,H,P,A>::load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.load_factor();
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
void unordered_map<K,T,H,P,A>::max_load_factor(float m)
|
||||
void unordered_map<K,T,H,P,A>::max_load_factor(float m) BOOST_NOEXCEPT
|
||||
{
|
||||
table_.max_load_factor(m);
|
||||
}
|
||||
@@ -1392,7 +1395,7 @@ namespace unordered
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
unordered_multimap<K,T,H,P,A>::~unordered_multimap() {}
|
||||
unordered_multimap<K,T,H,P,A>::~unordered_multimap() BOOST_NOEXCEPT {}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
unordered_multimap<K,T,H,P,A>::unordered_multimap(
|
||||
@@ -1401,7 +1404,7 @@ namespace unordered
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
unordered_multimap<K,T,H,P,A>::unordered_multimap(
|
||||
@@ -1440,7 +1443,7 @@ namespace unordered
|
||||
// size and capacity
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
std::size_t unordered_multimap<K,T,H,P,A>::max_size() const
|
||||
std::size_t unordered_multimap<K,T,H,P,A>::max_size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_size();
|
||||
}
|
||||
@@ -1588,13 +1591,13 @@ namespace unordered
|
||||
// hash policy
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
float unordered_multimap<K,T,H,P,A>::load_factor() const
|
||||
float unordered_multimap<K,T,H,P,A>::load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.load_factor();
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
void unordered_multimap<K,T,H,P,A>::max_load_factor(float m)
|
||||
void unordered_multimap<K,T,H,P,A>::max_load_factor(float m) BOOST_NOEXCEPT
|
||||
{
|
||||
table_.max_load_factor(m);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#ifndef BOOST_UNORDERED_MAP_FWD_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_MAP_FWD_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#ifndef BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/unordered_set_fwd.hpp>
|
||||
@@ -115,17 +116,19 @@ namespace unordered
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_set(BOOST_RV_REF(unordered_set) other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_set(unordered_set&& other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_set(unordered_set&&, allocator_type const&);
|
||||
#endif
|
||||
|
||||
@@ -140,7 +143,7 @@ namespace unordered
|
||||
|
||||
// Destructor
|
||||
|
||||
~unordered_set();
|
||||
~unordered_set() BOOST_NOEXCEPT;
|
||||
|
||||
// Assign
|
||||
|
||||
@@ -163,7 +166,7 @@ namespace unordered
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_set& operator=(unordered_set&& x)
|
||||
{
|
||||
table_.move_assign(x.table_);
|
||||
@@ -176,60 +179,60 @@ namespace unordered
|
||||
unordered_set& operator=(std::initializer_list<value_type>);
|
||||
#endif
|
||||
|
||||
allocator_type get_allocator() const
|
||||
allocator_type get_allocator() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.node_alloc();
|
||||
}
|
||||
|
||||
// size and capacity
|
||||
|
||||
bool empty() const
|
||||
bool empty() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_ == 0;
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
size_type size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_;
|
||||
}
|
||||
|
||||
size_type max_size() const;
|
||||
size_type max_size() const BOOST_NOEXCEPT;
|
||||
|
||||
// iterators
|
||||
|
||||
iterator begin()
|
||||
iterator begin() BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
const_iterator begin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
iterator end()
|
||||
iterator end() BOOST_NOEXCEPT
|
||||
{
|
||||
return iterator();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
const_iterator end() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
const_iterator cbegin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
const_iterator cend() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
@@ -434,12 +437,12 @@ namespace unordered
|
||||
|
||||
// bucket interface
|
||||
|
||||
size_type bucket_count() const
|
||||
size_type bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.bucket_count_;
|
||||
}
|
||||
|
||||
size_type max_bucket_count() const
|
||||
size_type max_bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_bucket_count();
|
||||
}
|
||||
@@ -448,8 +451,7 @@ namespace unordered
|
||||
|
||||
size_type bucket(const key_type& k) const
|
||||
{
|
||||
return table::to_bucket(table_.bucket_count_,
|
||||
table_.hash(k));
|
||||
return table_.hash_to_bucket(table_.hash(k));
|
||||
}
|
||||
|
||||
local_iterator begin(size_type n)
|
||||
@@ -487,13 +489,13 @@ namespace unordered
|
||||
|
||||
// hash policy
|
||||
|
||||
float max_load_factor() const
|
||||
float max_load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.mlf_;
|
||||
}
|
||||
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
float load_factor() const BOOST_NOEXCEPT;
|
||||
void max_load_factor(float) BOOST_NOEXCEPT;
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
@@ -583,17 +585,19 @@ namespace unordered
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
unordered_multiset(BOOST_RV_REF(unordered_multiset) other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multiset(unordered_multiset&& other)
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multiset(unordered_multiset&&, allocator_type const&);
|
||||
#endif
|
||||
|
||||
@@ -608,7 +612,7 @@ namespace unordered
|
||||
|
||||
// Destructor
|
||||
|
||||
~unordered_multiset();
|
||||
~unordered_multiset() BOOST_NOEXCEPT;
|
||||
|
||||
// Assign
|
||||
|
||||
@@ -632,7 +636,7 @@ namespace unordered
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multiset& operator=(unordered_multiset&& x)
|
||||
{
|
||||
table_.move_assign(x.table_);
|
||||
@@ -645,60 +649,60 @@ namespace unordered
|
||||
unordered_multiset& operator=(std::initializer_list<value_type>);
|
||||
#endif
|
||||
|
||||
allocator_type get_allocator() const
|
||||
allocator_type get_allocator() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.node_alloc();
|
||||
}
|
||||
|
||||
// size and capacity
|
||||
|
||||
bool empty() const
|
||||
bool empty() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_ == 0;
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
size_type size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.size_;
|
||||
}
|
||||
|
||||
size_type max_size() const;
|
||||
size_type max_size() const BOOST_NOEXCEPT;
|
||||
|
||||
// iterators
|
||||
|
||||
iterator begin()
|
||||
iterator begin() BOOST_NOEXCEPT
|
||||
{
|
||||
return iterator(table_.begin());
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
const_iterator begin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator(table_.begin());
|
||||
}
|
||||
|
||||
iterator end()
|
||||
iterator end() BOOST_NOEXCEPT
|
||||
{
|
||||
return iterator();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
const_iterator end() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
const_iterator cbegin() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator(table_.begin());
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
const_iterator cend() const BOOST_NOEXCEPT
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
iterator emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
@@ -903,12 +907,12 @@ namespace unordered
|
||||
|
||||
// bucket interface
|
||||
|
||||
size_type bucket_count() const
|
||||
size_type bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.bucket_count_;
|
||||
}
|
||||
|
||||
size_type max_bucket_count() const
|
||||
size_type max_bucket_count() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_bucket_count();
|
||||
}
|
||||
@@ -917,8 +921,7 @@ namespace unordered
|
||||
|
||||
size_type bucket(const key_type& k) const
|
||||
{
|
||||
return table::to_bucket(table_.bucket_count_,
|
||||
table_.hash(k));
|
||||
return table_.hash_to_bucket(table_.hash(k));
|
||||
}
|
||||
|
||||
local_iterator begin(size_type n)
|
||||
@@ -956,13 +959,13 @@ namespace unordered
|
||||
|
||||
// hash policy
|
||||
|
||||
float max_load_factor() const
|
||||
float max_load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.mlf_;
|
||||
}
|
||||
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
float load_factor() const BOOST_NOEXCEPT;
|
||||
void max_load_factor(float) BOOST_NOEXCEPT;
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
@@ -1034,7 +1037,7 @@ namespace unordered
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_set<T,H,P,A>::~unordered_set() {}
|
||||
unordered_set<T,H,P,A>::~unordered_set() BOOST_NOEXCEPT {}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_set<T,H,P,A>::unordered_set(
|
||||
@@ -1043,7 +1046,7 @@ namespace unordered
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_set<T,H,P,A>::unordered_set(
|
||||
@@ -1082,7 +1085,7 @@ namespace unordered
|
||||
// size and capacity
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
std::size_t unordered_set<T,H,P,A>::max_size() const
|
||||
std::size_t unordered_set<T,H,P,A>::max_size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_size();
|
||||
}
|
||||
@@ -1202,13 +1205,13 @@ namespace unordered
|
||||
// hash policy
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
float unordered_set<T,H,P,A>::load_factor() const
|
||||
float unordered_set<T,H,P,A>::load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.load_factor();
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
void unordered_set<T,H,P,A>::max_load_factor(float m)
|
||||
void unordered_set<T,H,P,A>::max_load_factor(float m) BOOST_NOEXCEPT
|
||||
{
|
||||
table_.max_load_factor(m);
|
||||
}
|
||||
@@ -1318,7 +1321,7 @@ namespace unordered
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_multiset<T,H,P,A>::~unordered_multiset() {}
|
||||
unordered_multiset<T,H,P,A>::~unordered_multiset() BOOST_NOEXCEPT {}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_multiset<T,H,P,A>::unordered_multiset(
|
||||
@@ -1327,7 +1330,7 @@ namespace unordered
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_multiset<T,H,P,A>::unordered_multiset(
|
||||
@@ -1366,7 +1369,7 @@ namespace unordered
|
||||
// size and capacity
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
std::size_t unordered_multiset<T,H,P,A>::max_size() const
|
||||
std::size_t unordered_multiset<T,H,P,A>::max_size() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.max_size();
|
||||
}
|
||||
@@ -1486,13 +1489,13 @@ namespace unordered
|
||||
// hash policy
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
float unordered_multiset<T,H,P,A>::load_factor() const
|
||||
float unordered_multiset<T,H,P,A>::load_factor() const BOOST_NOEXCEPT
|
||||
{
|
||||
return table_.load_factor();
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
void unordered_multiset<T,H,P,A>::max_load_factor(float m)
|
||||
void unordered_multiset<T,H,P,A>::max_load_factor(float m) BOOST_NOEXCEPT
|
||||
{
|
||||
table_.max_load_factor(m);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#ifndef BOOST_UNORDERED_SET_FWD_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_SET_FWD_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#ifndef BOOST_UNORDERED_MAP_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_MAP_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/unordered_map.hpp>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#ifndef BOOST_UNORDERED_SET_HPP_INCLUDED
|
||||
#define BOOST_UNORDERED_SET_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/unordered/unordered_set.hpp>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"key": "unordered",
|
||||
"name": "Unordered",
|
||||
"authors": [
|
||||
"Daniel James"
|
||||
],
|
||||
"maintainers": [
|
||||
"Daniel James <dnljms -at- gmail.com>"
|
||||
],
|
||||
"description": "Unordered associative containers.",
|
||||
"std": [
|
||||
"tr1"
|
||||
],
|
||||
"category": [
|
||||
"Containers"
|
||||
]
|
||||
}
|
||||
@@ -12,13 +12,8 @@ project unordered-test/exception-tests
|
||||
: requirements
|
||||
<warnings>all
|
||||
<toolset>intel:<warnings>on
|
||||
<toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
|
||||
<toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
|
||||
#<toolset>gcc:<define>_GLIBCXX_DEBUG
|
||||
#<toolset>darwin:<define>_GLIBCXX_DEBUG
|
||||
#<toolset>msvc:<warnings-as-errors>on
|
||||
#<toolset>gcc:<warnings-as-errors>on
|
||||
#<toolset>darwin:<warnings-as-errors>on
|
||||
<toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow -Wno-long-long"
|
||||
<toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow"
|
||||
;
|
||||
|
||||
test-suite unordered-exception
|
||||
|
||||
@@ -105,7 +105,8 @@ struct assign_test5 : assign_base<T>
|
||||
assign_test5() : assign_base<T>(5, 60, 0, 0, 1.0, 0.1) {}
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
EXCEPTION_TESTS(
|
||||
(self_assign_test1)(self_assign_test2)
|
||||
(assign_test1)(assign_test2)(assign_test3)(assign_test4)(assign_test5),
|
||||
CONTAINER_SEQ)
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -159,7 +159,7 @@ struct copy_range_construct_test : public range<T>, objects
|
||||
}
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
EXCEPTION_TESTS(
|
||||
(construct_test1)
|
||||
(construct_test2)
|
||||
(construct_test3)
|
||||
@@ -174,3 +174,4 @@ RUN_EXCEPTION_TESTS(
|
||||
(input_range_construct_test)
|
||||
(copy_range_construct_test),
|
||||
CONTAINER_SEQ)
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -64,6 +64,7 @@ struct copy_with_allocator_test : public test::exception_base
|
||||
}
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
EXCEPTION_TESTS(
|
||||
(copy_test1)(copy_test2)(copy_test3)(copy_with_allocator_test),
|
||||
CONTAINER_SEQ)
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -49,6 +49,7 @@ struct erase_by_key_test1 : public erase_test_base<T>
|
||||
}
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
EXCEPTION_TESTS(
|
||||
(erase_by_key_test1),
|
||||
CONTAINER_SEQ)
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -37,7 +37,7 @@ struct insert_test_base : public test::exception_base
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template <class T>
|
||||
struct emplace_test1 : public insert_test_base<T>
|
||||
@@ -236,11 +236,12 @@ struct insert_test_rehash3 : public insert_test_base<T>
|
||||
(insert_test1)(insert_test2)(insert_test3)(insert_test4) \
|
||||
(insert_test_rehash1)(insert_test_rehash2)(insert_test_rehash3)
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#define ALL_TESTS (emplace_test1)BASIC_TESTS
|
||||
#else
|
||||
#define ALL_TESTS BASIC_TESTS
|
||||
#endif
|
||||
|
||||
|
||||
RUN_EXCEPTION_TESTS(ALL_TESTS, CONTAINER_SEQ)
|
||||
EXCEPTION_TESTS(ALL_TESTS, CONTAINER_SEQ)
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -79,7 +79,7 @@ struct rehash_test4 : rehash_test_base<T>
|
||||
void run(T& x) const { x.rehash(0); }
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
EXCEPTION_TESTS(
|
||||
(rehash_test0)(rehash_test1)(rehash_test2)(rehash_test3)(rehash_test4),
|
||||
CONTAINER_SEQ)
|
||||
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -118,7 +118,8 @@ struct swap_test4 : swap_base<T>
|
||||
swap_test4() : swap_base<T>(10, 10, 1, 2) {}
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
EXCEPTION_TESTS(
|
||||
(self_swap_test1)(self_swap_test2)
|
||||
(swap_test1)(swap_test2)(swap_test3)(swap_test4),
|
||||
CONTAINER_SEQ)
|
||||
RUN_TESTS()
|
||||
|
||||
@@ -20,22 +20,37 @@
|
||||
fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||
} \
|
||||
|
||||
# define UNORDERED_EXCEPTION_TEST_CASE_REPEAT(name, test_func, n, type) \
|
||||
UNORDERED_AUTO_TEST(name) \
|
||||
{ \
|
||||
for (unsigned i = 0; i < n; ++i) { \
|
||||
test_func< type > fixture; \
|
||||
::test::lightweight::exception_safety( \
|
||||
fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||
} \
|
||||
} \
|
||||
|
||||
|
||||
# define UNORDERED_EPOINT_IMPL ::test::lightweight::epoint
|
||||
|
||||
#define UNORDERED_EXCEPTION_TEST_POSTFIX RUN_TESTS()
|
||||
|
||||
#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \
|
||||
BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, \
|
||||
(test_seq)(param_seq)) \
|
||||
RUN_TESTS() \
|
||||
#define EXCEPTION_TESTS(test_seq, param_seq) \
|
||||
BOOST_PP_SEQ_FOR_EACH_PRODUCT(EXCEPTION_TESTS_OP, \
|
||||
(test_seq)((1))(param_seq))
|
||||
|
||||
#define RUN_EXCEPTION_TESTS_OP(r, product) \
|
||||
UNORDERED_EXCEPTION_TEST_CASE( \
|
||||
#define EXCEPTION_TESTS_REPEAT(n, test_seq, param_seq) \
|
||||
BOOST_PP_SEQ_FOR_EACH_PRODUCT(EXCEPTION_TESTS_OP, \
|
||||
(test_seq)((n))(param_seq))
|
||||
|
||||
#define EXCEPTION_TESTS_OP(r, product) \
|
||||
UNORDERED_EXCEPTION_TEST_CASE_REPEAT( \
|
||||
BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, product), \
|
||||
BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(1, product)) \
|
||||
BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(2, product)) \
|
||||
), \
|
||||
BOOST_PP_SEQ_ELEM(0, product), \
|
||||
BOOST_PP_SEQ_ELEM(1, product) \
|
||||
BOOST_PP_SEQ_ELEM(1, product), \
|
||||
BOOST_PP_SEQ_ELEM(2, product) \
|
||||
) \
|
||||
|
||||
#define UNORDERED_SCOPE(scope_name) \
|
||||
|
||||
@@ -105,7 +105,8 @@ namespace test
|
||||
i = 0; i < x1.bucket_count(); ++i)
|
||||
{
|
||||
for (BOOST_DEDUCED_TYPENAME X::const_local_iterator
|
||||
begin = x1.begin(i), end = x1.end(i); begin != end; ++begin)
|
||||
begin2 = x1.begin(i), end2 = x1.end(i);
|
||||
begin2 != end2; ++begin2)
|
||||
{
|
||||
++bucket_size;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace test
|
||||
int count = type_ == generate_collisions ?
|
||||
1 + (generate(int_ptr) % 5) : 1;
|
||||
|
||||
for(int i = 0; i < count; ++i) {
|
||||
for(int j = 0; j < count; ++j) {
|
||||
x.push_back(value);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace test
|
||||
int count = type_ == generate_collisions ?
|
||||
1 + (generate(int_ptr) % 5) : 1;
|
||||
|
||||
for(int i = 0; i < count; ++i) {
|
||||
for(int j = 0; j < count; ++j) {
|
||||
x.push_back(std::pair<key_type const, mapped_type>(
|
||||
key, generate(mapped_ptr)));
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace test
|
||||
new(p) T(t);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
new(p) T(boost::forward<Args>(args)...);
|
||||
|
||||
@@ -348,7 +348,7 @@ namespace exception
|
||||
test::detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
UNORDERED_SCOPE(allocator::construct(pointer, BOOST_FWD_REF(Args)...)) {
|
||||
UNORDERED_EPOINT("Mock allocator construct function.");
|
||||
@@ -528,7 +528,7 @@ namespace exception
|
||||
test::detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
UNORDERED_SCOPE(allocator2::construct(pointer, BOOST_FWD_REF(Args)...)) {
|
||||
UNORDERED_EPOINT("Mock allocator2 construct function.");
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace minimal
|
||||
~movable1() {}
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
class movable2
|
||||
{
|
||||
public:
|
||||
@@ -371,7 +371,7 @@ namespace minimal
|
||||
|
||||
void construct(T* p, T const& t) { new((void*)p) T(t); }
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
new((void*)p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ namespace minimal
|
||||
|
||||
void construct(T* p, T const& t) { new((void*)p) T(t); }
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
new((void*)p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ namespace test
|
||||
new(p) T(t);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
new(p) T(boost::forward<Args>(args)...);
|
||||
|
||||
@@ -11,10 +11,8 @@ project unordered-test/unordered
|
||||
<toolset>intel:<warnings>on
|
||||
# Would be nice to define -Wundef, but I'm getting warnings from
|
||||
# Boost.Preprocessor on trunk.
|
||||
<toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wno-long-long -Wfloat-equal"
|
||||
<toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal"
|
||||
#<toolset>gcc:<define>_GLIBCXX_DEBUG
|
||||
#<toolset>darwin:<define>_GLIBCXX_DEBUG
|
||||
<toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow -Wno-long-long"
|
||||
<toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow"
|
||||
;
|
||||
|
||||
test-suite unordered
|
||||
@@ -25,6 +23,7 @@ test-suite unordered
|
||||
[ run minimal_allocator.cpp ]
|
||||
[ run compile_set.cpp ]
|
||||
[ run compile_map.cpp ]
|
||||
[ run noexcept_tests.cpp ]
|
||||
[ run link_test_1.cpp link_test_2.cpp ]
|
||||
[ run incomplete_test.cpp ]
|
||||
[ run simple_tests.cpp ]
|
||||
@@ -34,9 +33,6 @@ test-suite unordered
|
||||
[ run move_tests.cpp ]
|
||||
[ run assign_tests.cpp ]
|
||||
[ run insert_tests.cpp ]
|
||||
[ run insert_tests.cpp : :
|
||||
: <define>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
|
||||
: insert_deprecated ]
|
||||
[ run insert_stable_tests.cpp ]
|
||||
[ run unnecessary_copy_tests.cpp ]
|
||||
[ run erase_tests.cpp ]
|
||||
@@ -47,7 +43,6 @@ test-suite unordered
|
||||
[ run load_factor_tests.cpp ]
|
||||
[ run rehash_tests.cpp ]
|
||||
[ run equality_tests.cpp ]
|
||||
[ run equality_deprecated.cpp ]
|
||||
[ run swap_tests.cpp ]
|
||||
|
||||
[ run compile_set.cpp : :
|
||||
|
||||
@@ -137,7 +137,7 @@ void unordered_destructible_test(X&)
|
||||
|
||||
X x1;
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
X x2(rvalue_default<X>());
|
||||
X x3 = rvalue_default<X>();
|
||||
// This can only be done if propagate_on_container_move_assignment::value
|
||||
@@ -180,6 +180,28 @@ void unordered_set_test(X&, Key const&)
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type, key_type>::value));
|
||||
|
||||
// iterator pointer / const_pointer_type
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<iterator>::type iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<const_iterator>::type
|
||||
const_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<const_local_iterator>::type
|
||||
const_local_iterator_pointer;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const*, iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const*, const_iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const*, local_iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const*, const_local_iterator_pointer>::value));
|
||||
}
|
||||
|
||||
template <class X, class Key, class T>
|
||||
@@ -191,6 +213,30 @@ void unordered_map_test(X& r, Key const& k, T const& v)
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<value_type, std::pair<key_type const, T> >::value));
|
||||
|
||||
// iterator pointer / const_pointer_type
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<iterator>::type iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<const_iterator>::type
|
||||
const_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_pointer<const_local_iterator>::type
|
||||
const_local_iterator_pointer;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type*, iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const*, const_iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type*, local_iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const*, const_local_iterator_pointer>::value));
|
||||
|
||||
// Calling functions
|
||||
|
||||
r.insert(std::pair<Key const, T>(k, v));
|
||||
|
||||
Key k_lvalue(k);
|
||||
@@ -453,7 +499,7 @@ void unordered_movable_test(X& x, Key& k, T& /* t */, Hash& hf, Pred& eq)
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
X x1(rvalue_default<X>());
|
||||
X x2(boost::move(x1));
|
||||
x1 = rvalue_default<X>();
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
|
||||
// Copyright 2008-2009 Daniel James.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_UNORDERED_DEPRECATED_EQUALITY
|
||||
|
||||
#include "../helpers/prefix.hpp"
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include "../helpers/postfix.hpp"
|
||||
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
#include <list>
|
||||
#include "../helpers/test.hpp"
|
||||
|
||||
namespace equality_tests
|
||||
{
|
||||
struct mod_compare
|
||||
{
|
||||
bool alt_hash_;
|
||||
|
||||
explicit mod_compare(bool alt_hash = false) : alt_hash_(alt_hash) {}
|
||||
|
||||
bool operator()(int x, int y) const
|
||||
{
|
||||
return x % 1000 == y % 1000;
|
||||
}
|
||||
|
||||
int operator()(int x) const
|
||||
{
|
||||
return alt_hash_ ? x % 250 : (x + 5) % 250;
|
||||
}
|
||||
};
|
||||
|
||||
#define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \
|
||||
{ \
|
||||
boost::unordered_set<int, mod_compare, mod_compare> set1, set2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
|
||||
BOOST_TEST(set1 op set2); \
|
||||
}
|
||||
|
||||
#define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \
|
||||
{ \
|
||||
boost::unordered_multiset<int, mod_compare, mod_compare> \
|
||||
set1, set2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
|
||||
BOOST_TEST(set1 op set2); \
|
||||
}
|
||||
|
||||
#define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \
|
||||
{ \
|
||||
boost::unordered_map<int, int, mod_compare, mod_compare> \
|
||||
map1, map2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
|
||||
BOOST_TEST(map1 op map2); \
|
||||
}
|
||||
|
||||
#define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \
|
||||
{ \
|
||||
boost::unordered_multimap<int, int, mod_compare, mod_compare> \
|
||||
map1, map2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
|
||||
BOOST_TEST(map1 op map2); \
|
||||
}
|
||||
|
||||
#define UNORDERED_SET_INSERT(r, set, item) set.insert(item);
|
||||
#define UNORDERED_MAP_INSERT(r, map, item) \
|
||||
map.insert(std::pair<int const, int> BOOST_PP_SEQ_TO_TUPLE(item));
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_size_tests)
|
||||
{
|
||||
boost::unordered_set<int> x1, x2;
|
||||
BOOST_TEST(x1 == x2);
|
||||
BOOST_TEST(!(x1 != x2));
|
||||
|
||||
x1.insert(1);
|
||||
BOOST_TEST(x1 != x2);
|
||||
BOOST_TEST(!(x1 == x2));
|
||||
BOOST_TEST(x2 != x1);
|
||||
BOOST_TEST(!(x2 == x1));
|
||||
|
||||
x2.insert(1);
|
||||
BOOST_TEST(x1 == x2);
|
||||
BOOST_TEST(!(x1 != x2));
|
||||
|
||||
x2.insert(2);
|
||||
BOOST_TEST(x1 != x2);
|
||||
BOOST_TEST(!(x1 == x2));
|
||||
BOOST_TEST(x2 != x1);
|
||||
BOOST_TEST(!(x2 == x1));
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_key_value_tests)
|
||||
{
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2))
|
||||
UNORDERED_EQUALITY_SET_TEST((2), ==, (2))
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_collision_test)
|
||||
{
|
||||
UNORDERED_EQUALITY_MULTISET_TEST(
|
||||
(1), !=, (501))
|
||||
UNORDERED_EQUALITY_MULTISET_TEST(
|
||||
(1)(251), !=, (1)(501))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((251)(1))((1)(1)), !=, ((501)(1))((1)(1)))
|
||||
UNORDERED_EQUALITY_MULTISET_TEST(
|
||||
(1)(501), ==, (1)(501))
|
||||
UNORDERED_EQUALITY_SET_TEST(
|
||||
(1)(501), ==, (501)(1))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_group_size_test)
|
||||
{
|
||||
UNORDERED_EQUALITY_MULTISET_TEST(
|
||||
(10)(20)(20), !=, (10)(10)(20))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((10)(1))((20)(1))((20)(1)), !=,
|
||||
((10)(1))((20)(1))((10)(1)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((20)(1))((10)(1))((10)(1)), ==,
|
||||
((10)(1))((20)(1))((10)(1)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_map_value_test)
|
||||
{
|
||||
UNORDERED_EQUALITY_MAP_TEST(
|
||||
((1)(1)), !=, ((1)(2)))
|
||||
UNORDERED_EQUALITY_MAP_TEST(
|
||||
((1)(1)), ==, ((1)(1)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((1)(1)), !=, ((1)(2)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((1)(1))((1)(1)), !=, ((1)(1))((1)(2)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((1)(2))((1)(1)), !=, ((1)(1))((1)(2)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_predicate_test)
|
||||
{
|
||||
UNORDERED_EQUALITY_SET_TEST(
|
||||
(1), ==, (1001))
|
||||
UNORDERED_EQUALITY_MAP_TEST(
|
||||
((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1)))
|
||||
}
|
||||
|
||||
// Test that equality still works when the two containers have
|
||||
// different hash functions but the same equality predicate.
|
||||
|
||||
UNORDERED_AUTO_TEST(equality_different_hash_test)
|
||||
{
|
||||
typedef boost::unordered_set<int, mod_compare, mod_compare> set;
|
||||
set set1(0, mod_compare(false), mod_compare(false));
|
||||
set set2(0, mod_compare(true), mod_compare(true));
|
||||
BOOST_TEST(set1 == set2);
|
||||
set1.insert(1); set2.insert(2);
|
||||
BOOST_TEST(set1 != set2);
|
||||
set1.insert(2); set2.insert(1);
|
||||
BOOST_TEST(set1 == set2);
|
||||
set1.insert(10); set2.insert(20);
|
||||
BOOST_TEST(set1 != set2);
|
||||
set1.insert(20); set2.insert(10);
|
||||
BOOST_TEST(set1 == set2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RUN_TESTS()
|
||||
@@ -117,7 +117,6 @@ struct compatible_predicate
|
||||
template <class X>
|
||||
void find_compatible_keys_test(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator
|
||||
value_iterator;
|
||||
test::random_values<X> v(500, generator);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../helpers/postfix.hpp"
|
||||
|
||||
#include "../helpers/test.hpp"
|
||||
#include <boost/predef.h>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include "../objects/test.hpp"
|
||||
#include "../helpers/random_values.hpp"
|
||||
@@ -363,9 +364,6 @@ void equivalent_emplace_tests1(X*, test::random_generator generator)
|
||||
template <class X>
|
||||
void move_emplace_tests(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef test::ordered<X> ordered;
|
||||
|
||||
std::cerr<<"emplace(move(value)) tests for containers with unique keys.\n";
|
||||
|
||||
X x;
|
||||
@@ -380,7 +378,7 @@ void move_emplace_tests(X*, test::random_generator generator)
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
typename X::value_type value = *it;
|
||||
typename X::value_type value = *it;
|
||||
x.emplace(boost::move(value));
|
||||
tracker.insert(*it);
|
||||
tracker.compare_key(x, *it);
|
||||
@@ -549,13 +547,13 @@ UNORDERED_TEST(equivalent_emplace_tests1,
|
||||
|
||||
UNORDERED_TEST(move_emplace_tests,
|
||||
((test_set_std_alloc)(test_multimap_std_alloc)(test_set)(test_map)
|
||||
(test_multiset)(test_multimap))
|
||||
(test_multiset)(test_multimap))
|
||||
((default_generator)(generate_collisions))
|
||||
)
|
||||
|
||||
UNORDERED_TEST(default_emplace_tests,
|
||||
((test_set_std_alloc)(test_multimap_std_alloc)(test_set)(test_map)
|
||||
(test_multiset)(test_multimap))
|
||||
(test_multiset)(test_multimap))
|
||||
((default_generator)(generate_collisions))
|
||||
)
|
||||
|
||||
@@ -576,6 +574,21 @@ UNORDERED_TEST(map_insert_range_test2,
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
|
||||
struct initialize_from_two_ints
|
||||
{
|
||||
int a, b;
|
||||
|
||||
friend std::size_t hash_value(initialize_from_two_ints const& x)
|
||||
{
|
||||
return x.a + x.b;
|
||||
}
|
||||
|
||||
bool operator==(initialize_from_two_ints const& x) const
|
||||
{
|
||||
return a == x.a && b == x.b;
|
||||
}
|
||||
};
|
||||
|
||||
UNORDERED_AUTO_TEST(insert_initializer_list_set)
|
||||
{
|
||||
boost::unordered_set<int> set;
|
||||
@@ -583,8 +596,38 @@ UNORDERED_AUTO_TEST(insert_initializer_list_set)
|
||||
BOOST_TEST_EQ(set.size(), 3u);
|
||||
BOOST_TEST(set.find(1) != set.end());
|
||||
BOOST_TEST(set.find(4) == set.end());
|
||||
|
||||
boost::unordered_set<initialize_from_two_ints> set2;
|
||||
|
||||
#if BOOST_COMP_GNUC && BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(4,5,0)
|
||||
set2.insert({{1, 2}});
|
||||
#else
|
||||
set2.insert({1, 2});
|
||||
#endif
|
||||
BOOST_TEST(set2.size() == 1);
|
||||
BOOST_TEST(set2.find({1,2}) != set2.end());
|
||||
BOOST_TEST(set2.find({2,1}) == set2.end());
|
||||
|
||||
set2.insert({{3,4},{5,6},{7,8}});
|
||||
BOOST_TEST(set2.size() == 4);
|
||||
BOOST_TEST(set2.find({1,2}) != set2.end());
|
||||
BOOST_TEST(set2.find({3,4}) != set2.end());
|
||||
BOOST_TEST(set2.find({5,6}) != set2.end());
|
||||
BOOST_TEST(set2.find({7,8}) != set2.end());
|
||||
BOOST_TEST(set2.find({8,7}) == set2.end());
|
||||
|
||||
set2.insert({{2, 1}, {3,4}});
|
||||
BOOST_TEST(set2.size() == 5);
|
||||
BOOST_TEST(set2.find({1,2}) != set2.end());
|
||||
BOOST_TEST(set2.find({2,1}) != set2.end());
|
||||
BOOST_TEST(set2.find({3,4}) != set2.end());
|
||||
BOOST_TEST(set2.find({5,6}) != set2.end());
|
||||
BOOST_TEST(set2.find({7,8}) != set2.end());
|
||||
BOOST_TEST(set2.find({8,7}) == set2.end());
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1800)
|
||||
|
||||
UNORDERED_AUTO_TEST(insert_initializer_list_multiset)
|
||||
{
|
||||
boost::unordered_multiset<std::string> multiset;
|
||||
@@ -601,6 +644,8 @@ UNORDERED_AUTO_TEST(insert_initializer_list_multiset)
|
||||
BOOST_TEST_EQ(multiset.count("c"), 0u);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
UNORDERED_AUTO_TEST(insert_initializer_list_map)
|
||||
{
|
||||
boost::unordered_map<std::string, std::string> map;
|
||||
@@ -624,8 +669,8 @@ UNORDERED_AUTO_TEST(insert_initializer_list_multimap)
|
||||
|
||||
struct overloaded_constructor
|
||||
{
|
||||
overloaded_constructor(int x1 = 1, int x2 = 2, int x3 = 3, int x4 = 4)
|
||||
: x1(x1), x2(x2), x3(x3), x4(x4) {}
|
||||
overloaded_constructor(int x1_ = 1, int x2_ = 2, int x3_ = 3, int x4_ = 4)
|
||||
: x1(x1_), x2(x2_), x3(x3_), x4(x4_) {}
|
||||
|
||||
int x1, x2, x3, x4;
|
||||
|
||||
@@ -658,20 +703,6 @@ UNORDERED_AUTO_TEST(map_emplace_test)
|
||||
x.emplace(2, 3);
|
||||
BOOST_TEST(x.find(2) != x.end() &&
|
||||
x.find(2)->second == overloaded_constructor(3));
|
||||
|
||||
#if defined (BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
|
||||
x.emplace(1);
|
||||
BOOST_TEST(x.find(1) != x.end() &&
|
||||
x.find(1)->second == overloaded_constructor());
|
||||
|
||||
x.emplace(4, 5, 6);
|
||||
BOOST_TEST(x.find(4) != x.end() &&
|
||||
x.find(4)->second == overloaded_constructor(5, 6));
|
||||
|
||||
x.emplace(7, 8, 9, 10);
|
||||
BOOST_TEST(x.find(7) != x.end() &&
|
||||
x.find(7)->second == overloaded_constructor(8, 9, 10));
|
||||
#endif
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(set_emplace_test)
|
||||
@@ -705,6 +736,19 @@ UNORDERED_AUTO_TEST(set_emplace_test)
|
||||
BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check);
|
||||
}
|
||||
|
||||
struct derived_from_piecewise_construct_t :
|
||||
boost::unordered::piecewise_construct_t {};
|
||||
|
||||
derived_from_piecewise_construct_t piecewise_rvalue() {
|
||||
return derived_from_piecewise_construct_t();
|
||||
}
|
||||
|
||||
struct convertible_to_piecewise {
|
||||
operator boost::unordered::piecewise_construct_t() const {
|
||||
return boost::unordered::piecewise_construct;
|
||||
}
|
||||
};
|
||||
|
||||
UNORDERED_AUTO_TEST(map_emplace_test2)
|
||||
{
|
||||
boost::unordered_map<overloaded_constructor, overloaded_constructor> x;
|
||||
@@ -713,13 +757,18 @@ UNORDERED_AUTO_TEST(map_emplace_test2)
|
||||
BOOST_TEST(x.find(overloaded_constructor()) != x.end() &&
|
||||
x.find(overloaded_constructor())->second == overloaded_constructor());
|
||||
|
||||
x.emplace(boost::unordered::piecewise_construct, boost::make_tuple(1), boost::make_tuple());
|
||||
x.emplace(convertible_to_piecewise(), boost::make_tuple(1), boost::make_tuple());
|
||||
BOOST_TEST(x.find(overloaded_constructor(1)) != x.end() &&
|
||||
x.find(overloaded_constructor(1))->second == overloaded_constructor());
|
||||
|
||||
x.emplace(boost::unordered::piecewise_construct, boost::make_tuple(2,3), boost::make_tuple(4,5,6));
|
||||
x.emplace(piecewise_rvalue(), boost::make_tuple(2,3), boost::make_tuple(4,5,6));
|
||||
BOOST_TEST(x.find(overloaded_constructor(2,3)) != x.end() &&
|
||||
x.find(overloaded_constructor(2,3))->second == overloaded_constructor(4,5,6));
|
||||
|
||||
derived_from_piecewise_construct_t d;
|
||||
x.emplace(d, boost::make_tuple(9,3,1), boost::make_tuple(10));
|
||||
BOOST_TEST(x.find(overloaded_constructor(9,3,1)) != x.end() &&
|
||||
x.find(overloaded_constructor(9,3,1))->second == overloaded_constructor(10));
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(set_emplace_test2)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
namespace move_tests
|
||||
{
|
||||
test::seed_t initialize_seed(98624);
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE) || !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE) || !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#define BOOST_UNORDERED_TEST_MOVING 1
|
||||
#else
|
||||
#define BOOST_UNORDERED_TEST_MOVING 0
|
||||
@@ -154,7 +154,7 @@ namespace move_tests
|
||||
|
||||
test::random_values<T> v(25, generator);
|
||||
T y(create(v, count, hf, eq, al, 1.0), al);
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_TEST(count == test::global_object_count);
|
||||
#elif defined(BOOST_HAS_NRVO)
|
||||
BOOST_TEST(
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
|
||||
// Copyright 2013 Daniel James.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "../helpers/prefix.hpp"
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include "../helpers/postfix.hpp"
|
||||
|
||||
#include "../helpers/test.hpp"
|
||||
|
||||
namespace noexcept_tests
|
||||
{
|
||||
// Test the noexcept is set correctly for the move constructor.
|
||||
|
||||
struct hash_possible_exception : boost::hash<int>
|
||||
{
|
||||
hash_possible_exception(hash_possible_exception const&) {}
|
||||
};
|
||||
|
||||
struct equal_to_possible_exception : std::equal_to<int>
|
||||
{
|
||||
equal_to_possible_exception(equal_to_possible_exception const&) {}
|
||||
};
|
||||
|
||||
UNORDERED_AUTO_TEST(test_noexcept)
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_set<int> >::value));
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_multiset<int> >::value));
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_map<int, int> >::value));
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_multimap<int, int> >::value));
|
||||
#endif
|
||||
|
||||
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
||||
boost::unordered_set<int, hash_possible_exception>
|
||||
>::value));
|
||||
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
||||
boost::unordered_multiset<int, boost::hash<int>,
|
||||
equal_to_possible_exception>
|
||||
>::value));
|
||||
}
|
||||
|
||||
// Test that the move constructor does actually move without throwing
|
||||
// an exception when it claims to.
|
||||
|
||||
struct test_exception {};
|
||||
|
||||
bool throwing_test_exception = false;
|
||||
void test_throw(char const* name) {
|
||||
if (throwing_test_exception) {
|
||||
std::cerr << "Throw exception in: " << name << std::endl;
|
||||
throw test_exception();
|
||||
}
|
||||
}
|
||||
|
||||
class hash_nothrow_move : boost::hash<int>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(hash_nothrow_move)
|
||||
|
||||
typedef boost::hash<int> base;
|
||||
public:
|
||||
hash_nothrow_move(BOOST_RV_REF(hash_nothrow_move))
|
||||
BOOST_NOEXCEPT {}
|
||||
|
||||
hash_nothrow_move() { test_throw("Constructor"); }
|
||||
hash_nothrow_move(hash_nothrow_move const&) { test_throw("Copy"); }
|
||||
hash_nothrow_move& operator=(hash_nothrow_move const&)
|
||||
{ test_throw("Assign"); return *this; }
|
||||
std::size_t operator()(int x) const
|
||||
{ test_throw("Operator"); return static_cast<base const&>(*this)(x); }
|
||||
};
|
||||
|
||||
class equal_to_nothrow_move : std::equal_to<int>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(equal_to_nothrow_move)
|
||||
|
||||
typedef std::equal_to<int> base;
|
||||
public:
|
||||
equal_to_nothrow_move(BOOST_RV_REF(equal_to_nothrow_move))
|
||||
BOOST_NOEXCEPT {}
|
||||
equal_to_nothrow_move() { test_throw("Constructor"); }
|
||||
equal_to_nothrow_move(equal_to_nothrow_move const&)
|
||||
{ test_throw("Copy"); }
|
||||
equal_to_nothrow_move& operator=(equal_to_nothrow_move const&)
|
||||
{ test_throw("Assign"); return *this; }
|
||||
std::size_t operator()(int x, int y) const
|
||||
{ test_throw("Operator"); return static_cast<base const&>(*this)(x, y); }
|
||||
};
|
||||
|
||||
UNORDERED_AUTO_TEST(test_no_throw_when_noexcept)
|
||||
{
|
||||
typedef boost::unordered_set<int,
|
||||
hash_nothrow_move, equal_to_nothrow_move> throwing_set;
|
||||
|
||||
if (boost::is_nothrow_move_constructible<throwing_set>::value)
|
||||
{
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
|
||||
|
||||
try {
|
||||
throwing_test_exception = true;
|
||||
|
||||
throwing_set x2 = boost::move(x1);
|
||||
BOOST_TEST(x2.size() == 2);
|
||||
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
|
||||
} catch(test_exception) {
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RUN_TESTS()
|
||||
@@ -119,6 +119,20 @@ namespace unnecessary_copy_tests
|
||||
}
|
||||
}
|
||||
|
||||
// Boost.Move doesn't seem to work very well on this compiler.
|
||||
// For example for:
|
||||
//
|
||||
// T x;
|
||||
//
|
||||
// It will default construct T, and then move it in.
|
||||
// For 'T const' it seems to copy.
|
||||
|
||||
#if defined(__IBMCPP__) && __IBMCPP__ <= 1210
|
||||
#define EXTRA_CONSTRUCT_COST 1
|
||||
#else
|
||||
#define EXTRA_CONSTRUCT_COST 0
|
||||
#endif
|
||||
|
||||
#define COPY_COUNT(n) \
|
||||
if(::unnecessary_copy_tests::count_copies::copies != n) { \
|
||||
BOOST_ERROR("Wrong number of copies."); \
|
||||
@@ -150,9 +164,13 @@ namespace unnecessary_copy_tests
|
||||
BOOST_ERROR("Wrong number of moves."); \
|
||||
std::cerr \
|
||||
<< "Number of moves: " \
|
||||
<< ::unnecessary_copy_tests::count_copies::copies \
|
||||
<< ::unnecessary_copy_tests::count_copies::moves \
|
||||
<< " expecting: [" << a << ", " << b << "]" << std::endl; \
|
||||
}
|
||||
#define COPY_COUNT_EXTRA(a, b) \
|
||||
COPY_COUNT_RANGE(a, a + b * EXTRA_CONSTRUCT_COST)
|
||||
#define MOVE_COUNT_EXTRA(a, b) \
|
||||
MOVE_COUNT_RANGE(a, a + b * EXTRA_CONSTRUCT_COST)
|
||||
|
||||
namespace unnecessary_copy_tests
|
||||
{
|
||||
@@ -195,7 +213,7 @@ namespace unnecessary_copy_tests
|
||||
reset();
|
||||
T x;
|
||||
x.emplace(source<BOOST_DEDUCED_TYPENAME T::value_type>());
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
COPY_COUNT(1);
|
||||
#else
|
||||
COPY_COUNT(2);
|
||||
@@ -207,15 +225,31 @@ namespace unnecessary_copy_tests
|
||||
UNORDERED_TEST(unnecessary_copy_emplace_rvalue_test,
|
||||
((set)(multiset)(map)(multimap)))
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <class T>
|
||||
void unnecessary_copy_emplace_move_test(T*)
|
||||
void unnecessary_copy_emplace_std_move_test(T*)
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
COPY_COUNT(1); MOVE_COUNT(0);
|
||||
x.emplace(std::move(a));
|
||||
COPY_COUNT(1); MOVE_COUNT(1);
|
||||
}
|
||||
|
||||
UNORDERED_TEST(unnecessary_copy_emplace_std_move_test,
|
||||
((set)(multiset)(map)(multimap)))
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
void unnecessary_copy_emplace_boost_move_test(T*)
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
COPY_COUNT(1); MOVE_COUNT_EXTRA(0, 1);
|
||||
x.emplace(boost::move(a));
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
COPY_COUNT(1); MOVE_COUNT(1);
|
||||
#else
|
||||
// Since std::pair isn't movable, move only works for sets.
|
||||
@@ -223,7 +257,7 @@ namespace unnecessary_copy_tests
|
||||
#endif
|
||||
}
|
||||
|
||||
UNORDERED_TEST(unnecessary_copy_emplace_move_test,
|
||||
UNORDERED_TEST(unnecessary_copy_emplace_boost_move_test,
|
||||
((set)(multiset)(map)(multimap)))
|
||||
|
||||
template <class T>
|
||||
@@ -247,10 +281,10 @@ namespace unnecessary_copy_tests
|
||||
T x;
|
||||
COPY_COUNT(0); MOVE_COUNT(0);
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
COPY_COUNT(1); MOVE_COUNT(0);
|
||||
COPY_COUNT(1); MOVE_COUNT_EXTRA(0, 1);
|
||||
x.emplace(boost::move(a));
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
COPY_COUNT(2); MOVE_COUNT(0);
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
COPY_COUNT(2); MOVE_COUNT_EXTRA(0, 1);
|
||||
#else
|
||||
COPY_COUNT(1); MOVE_COUNT(1);
|
||||
#endif
|
||||
@@ -285,8 +319,8 @@ namespace unnecessary_copy_tests
|
||||
// the existing element.
|
||||
reset();
|
||||
x.emplace();
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES) || \
|
||||
!defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
|
||||
!defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
// source_cost doesn't make much sense here, but it seems to fit.
|
||||
COPY_COUNT(1); MOVE_COUNT(source_cost);
|
||||
#else
|
||||
@@ -313,7 +347,7 @@ namespace unnecessary_copy_tests
|
||||
// No move should take place.
|
||||
reset();
|
||||
x.emplace(boost::move(a));
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
COPY_COUNT(0); MOVE_COUNT(0);
|
||||
#else
|
||||
COPY_COUNT(0); MOVE_COUNT(1);
|
||||
@@ -364,7 +398,7 @@ namespace unnecessary_copy_tests
|
||||
// TODO: Run tests for pairs without const etc.
|
||||
std::pair<count_copies const, count_copies> a;
|
||||
x.emplace(a);
|
||||
COPY_COUNT(4); MOVE_COUNT(0);
|
||||
COPY_COUNT_EXTRA(4, 1); MOVE_COUNT_EXTRA(0, 1);
|
||||
|
||||
//
|
||||
// 0 arguments
|
||||
@@ -374,7 +408,7 @@ namespace unnecessary_copy_tests
|
||||
// COPY_COUNT(1) would be okay here.
|
||||
reset();
|
||||
x.emplace();
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, >= 1700)
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
|
||||
// This is a little odd, Visual C++ 11 seems to move the pair, which
|
||||
// results in one copy (for the const key) and one move (for the
|
||||
// non-const mapped value). Since 'emplace(boost::move(a))' (see below)
|
||||
@@ -382,7 +416,7 @@ namespace unnecessary_copy_tests
|
||||
// Visual C++ 11 handles calling move for default arguments.
|
||||
COPY_COUNT(3); MOVE_COUNT(1);
|
||||
# else
|
||||
COPY_COUNT(2); MOVE_COUNT(0);
|
||||
COPY_COUNT_EXTRA(2, 1); MOVE_COUNT_EXTRA(0, 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -407,9 +441,8 @@ namespace unnecessary_copy_tests
|
||||
x.emplace(source<std::pair<count_copies, count_copies> >());
|
||||
COPY_COUNT(2); MOVE_COUNT(source_pair_cost);
|
||||
|
||||
#if (defined(__GNUC__) && __GNUC__ > 4) || \
|
||||
(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 2) || \
|
||||
(defined(BOOST_MSVC) && BOOST_MSVC >= 1600 )
|
||||
#if !(defined(__GNUC__) && __cplusplus < 199900L) && \
|
||||
!(defined(_MSC_VER) && _MSC_VER < 1600)
|
||||
count_copies part;
|
||||
reset();
|
||||
std::pair<count_copies const&, count_copies const&> a_ref(part, part);
|
||||
@@ -476,8 +509,9 @@ namespace unnecessary_copy_tests
|
||||
COPY_COUNT(tuple_copy_cost);
|
||||
MOVE_COUNT(tuple_move_cost);
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ > 4 || \
|
||||
defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 6
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
|
||||
!(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6) && \
|
||||
!(defined(BOOST_MSVC) && BOOST_MSVC < 1700)
|
||||
reset();
|
||||
x.emplace(boost::unordered::piecewise_construct,
|
||||
std::forward_as_tuple(b.first),
|
||||
|
||||
Reference in New Issue
Block a user