Commit graph

594 commits

Author SHA1 Message Date
Inkrementator
b48a877814
Fix chain potentially mutating a stale object (#10643)
The constructor of the result of std.range.chain copies it's input tuple
and then has to check which of the input-ranges in the first non-empty
one. The member function empty is not guaranteed to be const, filter is
probably the most prominent function that has to be "primed". On the
first call to empty(), filter will try to advance all it's input ranges
to the first element that matches the predicate.
For ranges with full value semantics, using the old input object instead
of the new internal buffer means that the work of priming is done twice.
If any ranges have reference semantics, the references gets advances,
but the value-semantic parts of the range-composition gets reset.

This fixes #10561 and #9877
2025-02-20 06:23:34 +08:00
Kymorphia, PBC
488ea697a4
RandomFiniteAssignable incorrectly referenced as RandomAccessAssignable in ddoc index (#10630) 2025-01-24 06:11:51 +08:00
Vladiwostok
231ae8b68a
Fix D-Scanner linting issues (#9070)
* Fix UndocumentedDeclarationCheck linting issue

* Fix IfConstraintsIndentCheck linting issue

* Address feedback

* Fix publictests CI

* Fix old (libdparse) D-Scanner linting warn
2024-10-27 01:21:56 -07:00
Nicholas Wilson
ab46287e18
fix long line linter error (#9060)
* fix long line linter error

* Update package.d
2024-10-21 09:44:57 +03:00
Quirin F. Schroll
1ea91e6674
Fix lockstep error message (#9029) 2024-10-18 13:15:34 +08:00
Georgy Markov
706d97171c
Fix issue 24801 - RefRange doesn’t work if range primitives are not const (#9056)
* Fix Bugzilla issue 24801 - `RefRange` doesn’t work if range primitives are not `const`

* Remove trailing whitespaces
2024-10-17 19:59:31 -07:00
Quirin Schroll
0050fb0c0f Address style errors 2024-07-21 15:17:16 +08:00
Quirin Schroll
4d5ba46083 Fix problems with reverse 2024-07-21 15:17:16 +08:00
Quirin Schroll
9a63e1c6b4 Address style errors 2024-07-21 15:17:16 +08:00
Quirin Schroll
0a1735bf15 Fix Lockstep attribute limitation 2024-07-21 15:17:16 +08:00
0-v-0
42e2caa5c0 Improve code readablitity in unittests 2024-06-21 18:35:03 +02:00
Iain Buclaw
ee136a95d8 Merge remote-tracking branch 'upstream/stable' into merge_stable 2024-05-03 17:17:50 +00:00
Jonathan M Davis
ffe00ebdc3 Fix bugzilla issue 24481: retro stopped working
In an attempt make it so that non-copyable types worked with some of the
functions in std/range/package.d, they were made to use moves instead of
assignment, which broke the code for types which work with assignment
but not moves (which affected the folks at Weka).

The code checked for assignment but not whether move could be used, and
that didn't change when the code was changed to use move, meaning that
the checks didn't match what the code was actually doing.

So, to support both the non-copyable types and the ones that can be
assigned to but not moved to, this changes the code to use
core.lifetime.forward which will move the argument if it can and assign
otherwise. So ,the code that worked previously should work again, and
the newer functionality of being able to use non-copyable types with
this code should continue to work.

Discussion here: https://github.com/dlang/phobos/pull/8721
2024-04-29 11:33:30 +02:00
Iain Buclaw
688816eb41 Merge remote-tracking branch 'upstream/stable' into merge_stable 2024-04-25 19:11:41 +00:00
Inkrementator
72832ab8a4 Remove test with bugreport from the online documentation 2024-04-19 17:34:19 +02:00
Inkrementator
7b05ce70cc Correct Link formatting 2024-04-19 17:18:41 +02:00
Inkrementator
ffe309b065 Remove resolved bug from exmaples
https://issues.dlang.org/show_bug.cgi?id=24064 is resolved
2024-04-19 17:16:18 +02:00
Jonathan M Davis
34ff27e58d Work around bugzilla issue 24415 - only doesn't work with elements with a copy constructor.
Since the compiler is treating the auto-generated copy-constructor for
OnlyResult as private (thus rendering it useless outside of
std.range.package), this commit adds an explicit one and makes it
public. Once the dmd bug has been fixed, the explicit copy constructor
should be removed.
2024-04-09 09:08:12 +02:00
Paul Backus
837b7deb7d std.range.choose: call payload postblit correctly
Fixes bugzilla issue 15708
2024-03-04 00:43:59 +01:00
Paul Backus
5478868465 Document range capabilities of only() result 2024-02-16 07:06:31 +08:00
Paul Backus
82da4f114d Allow assignment of std.range.only elements
This allows the ranges returned by only to be used in algorithms that
require assignable elements, such as reverse, sort, and transposed.

Fixes bugzilla issue 24382.
2024-02-14 23:15:18 +01:00
Paul Backus
720ac51ea1 Skip leading empty ranges in roundRobin
Previously, roundRobin would always attempt to fetch its first element
from the first range passed to it, even if that range was empty.

Fixes bugzilla issue 24384.
2024-02-10 11:47:38 -05:00
Atila Neves
64457e8938
Merge pull request #8897 from pbackus/range-element-type
Add optional element type to remaining range predicates
2024-01-22 09:32:50 +01:00
Paul Backus
c4391b2237 Update docs for hasSlicing with inifnite range
The requirement for opSlice on an infinite range to return the result of
take or takeExactly was removed in commit c828a08b64, which was included
in Phobos 2.067.0, released in March 2015. However, the documentation
was never updated to take this change into account.

This change updates the documentation and adds a unit test for the "new"
behavior.

Fixes bugzilla issue 24348.
2024-01-21 00:53:08 +01:00
Paul Backus
c0557d30dc Add optional element type to isRandomAccessRange 2024-01-20 10:42:33 -05:00
Paul Backus
9f8de2b568 Add optional element type to isBidirectionalRange 2024-01-20 10:33:44 -05:00
Paul Backus
68c412316b Document element type parameter for isForwardRange 2024-01-20 10:22:42 -05:00
Mathis Beer
f6ff0f7c37 chain() must tolerate being in the init state. 2023-11-14 09:53:00 +01:00
Atila Neves
886d792d09 Add optional element type to isForwardRange
Similar to #8819
2023-11-07 15:26:52 +01:00
Paul Backus
c4cbe0c21b Use isQualifierConvertible in isInputRange!(R, E)
This replaces the bespoke type comparison that was previously used. All
conversions allowed by the previous version are still allowed after this
change.
2023-10-31 11:38:10 +01:00
Iain Buclaw
078e73e952 Adjust conditions in putChar to avoid declaring static symbol
Moves the declaration into a CTFE-only context so that nothing gets emitted at codegen
2023-10-25 08:04:34 +01:00
Atila Neves
43d52a1f7c Add more tests 2023-10-02 14:38:37 +02:00
Atila Neves
9531c76a4d Address review comments 2023-09-28 08:51:56 +01:00
Atila Neves
6873816349 Add optional element type to isInputRange 2023-09-28 08:51:56 +01:00
FeepingCreature
75372efef2
Fix issue 24064: use consistent types for ResultRanges. (#8791)
`source` is `Unqual!Ranges`, not `Ranges`.
2023-08-03 10:10:12 +03:00
Iain Buclaw
a3526d11dd Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-07-02 02:10:20 +00:00
Mathis Beer
1d2b992c44 Fix issue 23976: std.range.slide fails in dmd-2.104.0
I think possibly `hasShownPartialBefore` is just simply wrongly named in the `withPartial` branch.
2023-06-23 07:27:09 +02:00
Mathis Beer
10601cc046 Add std.typecons.Rebindable2 for internal use.
Rebindable2 is a simplified version of std.typecons.Rebindable that clears up every special case: classes, arrays and structs now have the same struct.
Whichever type you instantiate `Rebindable2` with, you always get the same type out by calling `value.get` on the resulting container.
Also use this type to simplify the parts of Phobos we previously used `Rebindable` for.
2023-06-19 13:24:30 +02:00
Dennis
5cd77a6e32
User hyperlinks to refer to bugzilla issues (#8766) 2023-06-16 14:45:44 +03:00
RazvanN7
5d61a31133 Don't use this in static context in std.range.package 2023-05-31 01:26:21 +02:00
Mathis Beer
b9c6e3ca4b Fix issue 23844: Support ranges with immutable fields (like only with immutable struct) in chain.
`only` is a range that may be *mutable*, but not *assignable*. `chain` falls over here because it assumes it can make a struct with ranges, and reassign them with new values, which isn't necessarily the case even if the ranges are not `const`.
Solved by creating a separate tuple of `Rebindable` ranges for this case.
2023-05-03 13:56:04 +02:00
WebFreak001
d35dafbde8 fix 14478: support non-copyable elements in many range algorithms 2023-05-01 18:17:27 +02:00
FeepingCreature
8a9cfa2677
Fix issue 19642: slide!(No.withPartial): Correctly handle first slide exhausting input range. (#8738) 2023-04-24 12:57:21 +03:00
Ate Eskola
128f75181c
Optimised std.range.chain (#8713)
* Optimised std.range.chain
Chain now remembers which subrange has the first and the last elements,
eliminating needless work on each usage.

* Style fix.

* No longer needless `.empty` calls in the constructor.

* Improvements based on Razvans observations.
2023-04-07 13:41:04 +03:00
WebFreak001
3b3757af6b
fix 22147: allow @disable this(this) T in DList!T 2023-03-12 19:49:11 +01:00
WebFreak001
e2e1bb4c57
fix isBidirectionalRange with no-postblit .back 2023-03-12 19:49:07 +01:00
Nick Treleaven
1c397ee30d Revert back to (R r) to fix inout 2023-02-18 18:46:23 +00:00
Nick Treleaven
c7e1a1ed92 Update isSlicing docs to match code
Use lvalueOf instead of `(R r)` parameter as lvalueOf!R is already
needed for the other tests.
2023-02-18 15:30:14 +00:00
Steven Schveighoffer
bdc75f6c6d
Based on my tests, this should save about 56K of compiler RAM per (#8682)
instantiation of ReturnType, and some amount of compile time.
2023-02-13 07:08:01 +08:00
RazvanN7
67155f04e7 Fix Issue 23319 - std.range.Generator does not work with non-mutable elements 2022-12-05 15:24:34 +01:00