Commit graph

105 commits

Author SHA1 Message Date
Nick Treleaven
39d921681b Fix import 2023-11-06 17:50:20 +00:00
Nick Treleaven
0eaa3e25a1 Fix Issue 24151 - std.container.array: Array!string("") does not compile 2023-09-19 21:17:07 +01:00
Dennis
5cd77a6e32
User hyperlinks to refer to bugzilla issues (#8766) 2023-06-16 14:45:44 +03:00
Lucian Danescu
322fed7bf7 add local imports 2022-11-12 19:29:28 +02:00
Per Nordlöw
ee64840397 Replace enforce(!empty with assert(!empty at the beginning of range members 2022-10-10 09:08:23 +02: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
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
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
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
DoctorNoobingstoneIPresume
afeb00d580 container.array: RangeT: moveBack: Improve an assertion. 2021-05-04 08:13:40 +02: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
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
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
Robert Schadek
e70d86b75d Add assert messages for container.array (#7190) 2019-11-04 13:08:28 +02:00
Nathan Sashihara
d35c93dac7 Avoid mulu in std.container.array.Array!T when T.sizeof == 1
LDC 1.15 and GDC with optimizations enabled recognize that mulu
with a second argument of 1 will never overflow and elide unnecessary
operations but DMD and LDC 1.14 do not.
2019-06-01 08:50:23 -04:00
Nathan Sashihara
dcca23edca Fix Issue 19164 - malloc may be considered pure when failure results in program exit (no need to reset errno) 2018-11-17 17:00:16 -05:00
Steven Schveighoffer
5a3a181922 Fix issue 19171 - Fix invalid assert in Array!bool slicing 2018-08-15 14:24:51 -04:00
Sebastian Wilzbach
c324714fde Remove a few cases of underscore escaping 2018-06-04 13:05:01 +02:00
Martin Nowak
b2016be155 fix Issue 18800 - Array.length setter segfaults for payloads with indirections 2018-04-30 09:39:52 +02:00
Jack Stouffer
e14f89e170 Make references to input ranges a link to isInputRange 2018-04-08 16:19:57 -04:00
Ryan Frame
e837813478 Fix issue 13642 - Change of length reallocates without notifying GC 2017-12-29 07:24:54 -05:00
n8sh
06d738f069 Fix Issue 17919: Make std.container.Array use pureMalloc
Using pureMalloc like std.typecons.RefCounted does would make it
possible to use std.container.Array in  `pure` code.
2017-10-25 13:14:50 -04:00
The Dlang Bot
8f98afc9ae Merge pull request #5473 from dmarquant/bug12866
Issue 12866: Allows concatenating of std.container.array with static arrays as T.
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
2017-06-27 00:41:40 +02:00