Commit graph

301 commits

Author SHA1 Message Date
Ate Eskola
490caa7090 RefCounted -> SafeRefCounted, OldRefCounted -> RefCounted. 2022-09-11 01:35:35 +03:00
Ate Eskola
bb145a09a6 Ate's work on safe ref counted 2022-09-11 01:35:35 +03:00
Martin Nowak
32733a908d Merge remote-tracking branch 'upstream/stable' into merge_stable 2022-08-30 08:12:00 +02:00
Walter Bright
5d2baa46b6 rbtree lambda references stack frame 2022-08-19 06:14:33 -07:00
RubyTheRoobster
4cbac77a8a I'm sick of my text editor adding random whitespace 2022-08-10 15:47:54 -04:00
RubyTheRoobster
7caaa7838d I have no idea why the unittest works now, but okay 2022-08-10 15:37:32 -04:00
RubyTheRoobster
e0280ae2fc Use Unshared only when necessary 2022-08-10 14:49:05 -04:00
RubyTheRoobster
ce098b99d4 Fix tests (they should still work) 2022-08-04 08:08:37 -04:00
RubyTheRoobster
4b5cfc17b9 D Style Fix (again) 2022-08-03 21:12:08 -04:00
RubyTheRoobster
9aa628a64d D Style Fix 2022-08-03 21:08:12 -04:00
RubyTheRoobster
4cfb36aece Add tests 2022-08-03 20:57:38 -04:00
RubyTheRoobster
6343d5a58d Private the Unshared alias. 2022-08-03 14:19:22 -04:00
RubyTheRoobster
15860563c7 fixup! Remove limit-violating lines to fit D style. 2022-08-03 13:46:14 -04:00
RubyTheRoobster
08ea63f4f4 Remove limit-violating lines to fit D style. 2022-08-03 13:14:38 -04:00
RubyTheRoobster
2023b271e5 Fix issue 23140 - Array!T where T is a shared class no longer works 2022-08-03 11:58:12 -04:00
dkorpel
f7c93036b3 Fix return/inout usage in rbtree 2022-02-16 16:27:04 +00:00
wolframw
dc697c8dd8 Fix Issue 22105 - std.container.array.Array.length setter creates values of init-less types 2021-12-28 23:33:31 +00:00
dkorpel
ea76f45494 Use return scope instead of just return 2021-11-26 17:03:06 +01:00
Ömer Faruk IRMAK
61d3fe3293 Add explicit default ctor for DList.PayNode
Worksaround Issue 22510 (https://issues.dlang.org/show_bug.cgi?id=22510)
which prevented us from using structs with explicit copy ctors with DList.
2021-11-14 14:50:23 +03:00
Petar Kirov
dfaaf8fa53 Merge remote-tracking branch 'upstream/stable' into merge_stable 2021-11-09 10:30:28 +02:00
MoonlightSentinel
c0981769a0 Fix 22487 - Don't access payload for unititialized array data
Explicitly return `[]` when `store` wasn't intialized yet.
2021-11-08 05:40:08 +00:00
MoonlightSentinel
a22571f59a Fix 22488 - Add inout to allow Array.data for const/immutable Array's
Simply propagate the const'ness to the return slice.
2021-11-08 05:34:08 +00:00
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
dkorpel
53cd09c1fb mark RBNode.left and RBNode.right @trusted 2021-08-09 12:29:07 +02:00
Razvan Nitu
b48cca57e8
Merge pull request #8151 from DoctorNoobingstoneIPresume/210615_std_container_array_Payload_insertBack_01h
std.container.Array: insertBack: Extra checks (including addition overflow).
2021-07-28 18:30:26 +08:00
dandrei279
11bf097658
[DSSv3] Fix Issue #21100: Add data() function to std.container.array.Array (#8174)
[DSSv3] Fix Issue #21100: Add data() function to std.container.array.Array

Signed-off-by: Max Haughton <maxhaton@users.noreply.github.com>
Merged-on-behalf-of: Max Haughton <maxhaton@users.noreply.github.com>
2021-07-21 02:23:10 +00:00
Vladimir Panteleev
9baab6030a std.container.array: Hide unintentionally-public unittest
This is a unittest for a bug, not a public example.
2021-07-05 05:40:36 +00:00
DoctorNoobingstoneIPresume
7f9cc3fbbb std.container.Array: insertBack: Extra checks (including addition overflow). 2021-06-22 19:33:33 +03:00
DoctorNoobingstoneIPresume
0b7bf8dc1f std.container.Array: Simplify implementation of length (by calling reserve). 2021-06-14 05:05:39 +00:00
nordlow
4ba167b15b Annotate std/container/dlist.d to please dlang/dmd#12520 2021-05-18 01:58:16 +02:00
DoctorNoobingstoneIPresume
afeb00d580 container.array: RangeT: moveBack: Improve an assertion. 2021-05-04 08:13:40 +02:00
Razvan Nitu
6e11524c6f
Merge pull request #7189 from burner/assert_messages_container_package
adds assert messages to std.container.package
2021-04-21 20:46:12 +08:00
Razvan Nitu
89abc75f02
Merge pull request #7745 from kinke/emplace
Get rid of std.conv.emplace[Ref](), use core[.internal].lifetime
2021-01-25 15:36:04 +08:00
Luís Ferreira
e0bbaf3649 container: array: simplify some unittests by using Array!bool ctor instead
Since ae90bc7, we can simplify unittests by using Array!bool ctor instead of
manually do .insertBack(...). This improves example code readability.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-01-23 07:26:39 +01:00
Razvan Nitu
d7fd00d792
Merge pull request #7752 from ljmf00/container-array-ctor-bool
container: array: add ctors for Array!bool
2021-01-22 15:30:10 +08:00
Luís Ferreira
ce558d26b1 container: array: add type checks for passed arguments in insertAfter()
insertAfter should receive a valid element or a Range of values according to
type T of the corresponding instance Array!T.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-01-19 03:42:45 +01:00
Luís Ferreira
ae90bc7d9e
container: array: add ctors for Array!bool
Array!bool should have the same ctors as Array!T for other types.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-01-18 23:14:26 +00:00
Luís Ferreira
30f71fd570
Fix issues 21555, 21556: container: array: add missing tests for Array!T .insertBack and .insertAfter
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-01-18 20:55:12 +00:00
Luís Ferreira
93ebaa7291
Fix issue 21555: std.container.array: insertBack is wrong and should be tested for Array!bool
insertBack() returns 0 inserted elements everytime due to a preformed
.popFront() on the range.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-01-18 20:54:14 +00:00
Martin Kinkelin
1a459c5996 Get rid of std.conv.emplace[Ref](), use core[.internal].lifetime
The emplace() stuff was moved to druntime; for some reason, it's still
in Phobos.

I've diffed the two versions, and they are still almost identical (incl.
unittests); the druntime version appears to have seen some improvements
(e.g., forwarding r/lvalueness of the arguments) in the meantime.
2021-01-17 16:02:25 +01:00
Nathan Sashihara
fe1deb2f84 Fix a few places where opDollar could be an alias of length 2020-11-11 02:09:56 +01:00
Simon Naarmann
b0b64c3f41
RedBlackTree.empty: const, .front/.back: inout (#7644)
* RedBlackTree.empty(): Annotated const

RedBlackTree is a template, therefore all other qualifiers
for empty(), length(), and opBinaryRight!"in" will be inferred:
pure, nothrow, @safe, @nogc.

* RedBlackTree.front, .back: inout
2020-09-30 13:29:29 +08:00
Iain Buclaw
68e7cbdbc2 std.container: Fix warnings that memory may be used uninitialized
This is a warning that showed up when running the testsuite in GDC with
the -Wextra flag.  Said warning is by design and based on the assumption
that any function declared to take a const pointer or reference as an
argument reads the pointed-to-object.

In the case of GC.addRange(), the possibility is that a scan could
occur before the memory is initialized, and the GC sees false pointers
as a result of that.
2020-09-16 10:47:10 +02:00
Nathan Sashihara
453faadf5b Replace is(Unqual!T == Unqual!U) with is(immutable T == immutable U) for speed & memory usage 2020-08-03 15:07:32 +02:00
Steven Schveighoffer
b842a66f57 Move stableRemove alias to correct place 2020-07-11 08:58:22 +02:00
Geod24
62c72ca6ff Follow up review on PR 7441
Steven identified a couple mistakes in the massive round of linkification.
Fixing them here.
2020-04-15 02:15:04 +09:00
Geod24
04f3979317 Replace 'Issue XXX' with Bugzilla links
Make the links clickable, as was done in the DMD repository.
Also avoids any ambiguity w.r.t. where the issue is stored.
2020-04-13 16:28:09 +09:00
drug007
e4959d4777 Test for issue 20589 2020-02-26 20:05:34 +03:00
The Dlang Bot
3d322b7cc4
Merge pull request #7370 from burner/std.container.rbtree_assert_messages
adding assert messages to rbtree
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2020-02-02 04:24:33 +01:00
The Dlang Bot
6a8350c688
Merge pull request #7369 from burner/std.container.binary_heap_assert_messages
adding assert messages to std.container.binary_heap
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2020-02-02 04:23:10 +01:00