Skip to content

Commit

Permalink
Add low-overhead FixedAppender (internal for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Colvin authored and Oanaa28 committed Dec 13, 2024
1 parent 08638dd commit 53172fb
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 229 deletions.
12 changes: 6 additions & 6 deletions std/algorithm/comparison.d
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ Returns:
*/
T1 clamp(T1, T2, T3)(T1 val, T2 lower, T3 upper)
{
static assert(is(T2 : T1), "T2 of type '", T2.stringof
, "' must be implicitly convertible to type of T1 '"
, T1.stringof, "'");
static assert(is(T3 : T1), "T3 of type '", T3.stringof
, "' must be implicitly convertible to type of T1 '"
, T1.stringof, "'");
static assert(is(T2 : T1), "T2 of type '" ~ T2.stringof
~ "' must be implicitly convertible to type of T1 '"
~ T1.stringof ~ "'");
static assert(is(T3 : T1), "T3 of type '" ~ T3.stringof
~ "' must be implicitly convertible to type of T1 '"
~ T1.stringof ~ "'");

assert(!lower.greaterThan(upper), "Lower can't be greater than upper.");

Expand Down
49 changes: 27 additions & 22 deletions std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -2973,22 +2973,27 @@ front to back, even if it is a bidirectional range too.
*/
auto joiner(RoR, Separator)(RoR r, Separator sep)
{
static assert(isInputRange!RoR, "The type of RoR '", RoR.stringof
, " must be an InputRange (isInputRange!", RoR.stringof, ").");
static assert(isInputRange!(ElementType!RoR), "The ElementyType of RoR '"
, ElementType!(RoR).stringof, "' must be an InputRange "
, "(isInputRange!(ElementType!(", RoR.stringof , "))).");
static assert(isForwardRange!Separator, "The type of the Separator '"
, Separator.stringof, "' must be a ForwardRange (isForwardRange!("
, Separator.stringof, ")).");
static assert(is(ElementType!Separator : ElementType!(ElementType!RoR))
, "The type of the elements of the separator range does not match "
, "the type of the elements that are joined. Separator type '"
, ElementType!(Separator).stringof, "' is not implicitly"
, "convertible to range element type '"
, ElementType!(ElementType!RoR).stringof, "' (is(ElementType!"
, Separator.stringof, " : ElementType!(ElementType!", RoR.stringof
, "))).");
static assert(isInputRange!RoR,
"The type of RoR '" ~ RoR.stringof ~
"' must be an InputRange (isInputRange!" ~ RoR.stringof ~ ").");

static assert(isInputRange!(ElementType!RoR),
"The ElementType of RoR '" ~ ElementType!(RoR).stringof ~
"' must be an InputRange (isInputRange!(ElementType!(" ~ RoR.stringof ~ "))).");

static assert(isForwardRange!Separator,
"The type of the Separator '" ~ Separator.stringof ~
"' must be a ForwardRange (isForwardRange!(" ~ Separator.stringof ~ ")).");

static assert(is(ElementType!Separator : ElementType!(ElementType!RoR)),
"The type of the elements of the separator range does not match " ~
"the type of the elements that are joined. Separator type '" ~
ElementType!(Separator).stringof ~
"' is not implicitly convertible to range element type '" ~
ElementType!(ElementType!RoR).stringof ~
"' (is(ElementType!" ~ Separator.stringof ~
" : ElementType!(ElementType!" ~ RoR.stringof ~ ")))).");


static struct Result
{
Expand Down Expand Up @@ -7959,21 +7964,21 @@ $(REF nextPermutation, std,algorithm,sorting).
*/
Permutations!Range permutations(Range)(Range r)
{
static assert(isRandomAccessRange!Range, Range.stringof,
" must be a RandomAccessRange");
static assert(isRandomAccessRange!Range, Range.stringof
~ " must be a RandomAccessRange");
static assert(hasLength!Range, Range.stringof
, " must have a length");
~ " must have a length");

return typeof(return)(r);
}

/// ditto
struct Permutations(Range)
{
static assert(isRandomAccessRange!Range, Range.stringof,
" must be a RandomAccessRange");
static assert(isRandomAccessRange!Range, Range.stringof
~ " must be a RandomAccessRange");
static assert(hasLength!Range, Range.stringof
, " must have a length");
~ " must have a length");

private size_t[] _indices, _state;
private Range _r;
Expand Down
Loading

0 comments on commit 53172fb

Please sign in to comment.