phobos/std/container
DoctorNoobingstoneIPresume 6b05400fba std.container.Array: Payload.reserve re-used, object leak fixed.
This is another attempt to re-use the code in `Payload.reserve` --
similar to https://github.com/dlang/phobos/pull/8143 (commit 0b7bf8dc):
"std.container.Array: Simplify implementation of length (by calling reserve).".

Additionally, `Array`'s variadic constructor is now safer:

  If `emplace`-ing an element fails, successfully `emplace`-d elements are now destroyed.

  Example:

  ```
    auto a = Array!S (S(0), S(1), S(2), S(3));

    // If emplace-ing a[2] (as a copy of S(2)) fails:
    //   - pre-existing behaviour: a[1] and a[0] were not destroyed (bad);
    //   - new behaviour:          a[1] and a[0] are      destroyed (good).
  ```

  A corresponding `unittest` has been added (`S.s_nDestroyed == S.s_nConstructed`):
    When such a failure (`Exception`) is caught, there should be no leaked objects.

  Implementation:
    Previously:
      - the `Payload` `length` used to be increased only once,
        after having successfully `emplace`-d all elements,
        thus incorrectly tracking the number of `emplace`-d elements during the loop
        (but correctly tracking it after the loop -- iff the entire loop succeeded).
    Now:
      - the `Payload` `length` is incremented multiple times,
        at each step i.e. after having successfully `emplace`-d each element,
        thus correctly tracking the number of `emplace`-d elements during the loop.
    Note:
      When the constructor fails, the corresponding destructor is not run.
      But the destructors for successfully constructed sub-objects are run;
      in this case, the destructor for the `_data` sub-object is run --
      and it is this destructor which destroys the successfully emplaced elements
      (iff they have been correctly tracked).
2021-09-27 02:23:14 +03:00
..
array.d std.container.Array: Payload.reserve re-used, object leak fixed. 2021-09-27 02:23:14 +03:00
binaryheap.d Replace 'Issue XXX' with Bugzilla links 2020-04-13 16:28:09 +09:00
dlist.d Annotate std/container/dlist.d to please dlang/dmd#12520 2021-05-18 01:58:16 +02:00
package.d adds assert messages to std.container.package 2019-09-20 12:04:42 +08:00
rbtree.d mark RBNode.left and RBNode.right @trusted 2021-08-09 12:29:07 +02:00
slist.d Replace 'Issue XXX' with Bugzilla links 2020-04-13 16:28:09 +09:00
util.d Replace 'Issue XXX' with Bugzilla links 2020-04-13 16:28:09 +09:00