[Issue 12893] New: Cannot create a SortedRange from inout array
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jun 11 14:51:39 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12893
Issue ID: 12893
Summary: Cannot create a SortedRange from inout array
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: David.L.Watkins at gmail.com
import std.algorithm;
import std.array;
import std.range;
struct Data
{
string name;
alias name this;
}
inout(Data) findData(inout(Data)[] arr, string name)
{
auto sorted = assumeSorted(arr);
auto found = sorted.equalRange(name);
return found.empty ? Data.init : found.front;
}
void main()
{
Data[] arr;
arr ~= Data("Alice");
arr ~= Data("Carol");
arr ~= Data("Bob");
sort(arr);
auto data = findData("Bob");
}
Fails with:
\src\phobos\std\range.d(8340): Error: variable
std.range.SortedRange!(inout(Data)[], "a < b").SortedRange._input only
parameters or stack based variables can be inout
\src\phobos\std\range.d(8839): Error: template instance
std.range.SortedRange!(inout(Data)[], "a < b") error instantiating
instantiated from here: assumeSorted!("a < b", inout(Data)[])
--
More information about the Digitalmars-d-bugs
mailing list