[Issue 17835] std.algorithm.findSplit: Documentation example does not compile

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 22 00:33:35 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17835

--- Comment #4 from Jon Degenhardt <jrdemail2000-dlang at yahoo.com> ---
(In reply to Duncan Paterson from comment #3)
> Played with this for a while tonight. It seems like the problem is the empty
> function on a lot of ranges not being defined const. I've written a patch
> but I think the knock on of this is quite severe so it's probably not worth
> pushing.

That does make it harder! Perhaps too hard. For example, it might not be
pragmatic to ask that user defined ranges declare 'empty' as const.

Perhaps the better step for now is to simply change the documentation. This
could be done by changing "const" to "auto" in the example:

------------------
if (const split = haystack.findSplit(needle))
{
     doSomethingWithSplit(split);
}
------------------

--


More information about the Digitalmars-d-bugs mailing list