Implicit cast to const of result returned from findSplit()

Per Nordlöw per.nordlow at gmail.com
Mon Nov 5 13:26:18 UTC 2018


Why does

@safe pure unittest
{
     import std.algorithm.searching : findSplit;
     if (const split = "a b".findSplit(" "))
     {
     }
}

error as

f.d(4,5): Error: mutable method 
`std.algorithm.searching.findSplit!("a == b", string, 
string).findSplit.Result!(string, 
string).Result.opCast!bool.opCast` is not callable using a 
`const` object
f.d(4,5):        Consider adding `const` or `inout` to 
std.algorithm.searching.findSplit!("a == b", string, 
string).findSplit.Result!(string, 
string).Result.opCast!bool.opCast

when

@safe pure unittest
{
     import std.algorithm.searching : findSplit;
     if (auto split = "a b".findSplit(" "))
     {
     }
}

doesn't?

AFAICT, it looks like a missing bool qualifier on `opCast!bool`, 
right?


More information about the Digitalmars-d-learn mailing list