mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 06:00:35 +03:00
Fix Issue 23319 - std.range.Generator does not work with non-mutable elements
This commit is contained in:
parent
09275da681
commit
67155f04e7
1 changed files with 17 additions and 3 deletions
|
@ -3774,10 +3774,17 @@ private:
|
|||
alias fun = Fun[0];
|
||||
|
||||
enum returnByRef_ = (functionAttributes!fun & FunctionAttribute.ref_) ? true : false;
|
||||
static if (returnByRef_)
|
||||
ReturnType!fun *elem_;
|
||||
|
||||
import std.traits : hasIndirections;
|
||||
static if (!hasIndirections!(ReturnType!fun))
|
||||
alias RetType = Unqual!(ReturnType!fun);
|
||||
else
|
||||
ReturnType!fun elem_;
|
||||
alias RetType = ReturnType!fun;
|
||||
|
||||
static if (returnByRef_)
|
||||
RetType *elem_;
|
||||
else
|
||||
RetType elem_;
|
||||
public:
|
||||
/// Range primitives
|
||||
enum empty = false;
|
||||
|
@ -3866,6 +3873,13 @@ public:
|
|||
assert(g.front == f + 5);
|
||||
}
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=23319
|
||||
@safe pure nothrow unittest
|
||||
{
|
||||
auto b = generate!(() => const(int)(42));
|
||||
assert(b.front == 42);
|
||||
}
|
||||
|
||||
/**
|
||||
Repeats the given forward range ad infinitum. If the original range is
|
||||
infinite (fact that would make `Cycle` the identity application),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue