splitter string/char different behavior
WhatMeWorry
kheaser at gmail.com
Sat Sep 30 19:18:12 UTC 2017
On Saturday, 30 September 2017 at 18:21:11 UTC, Jon Degenhardt
wrote:
> On Saturday, 30 September 2017 at 17:17:17 UTC, SrMordred wrote:
>> [...]
>
> It's easy to overlook, but documentation for splitter starts
> out:
>
> Lazily splits a range using an element as a separator.
>
> An element of a string is a char, not a string. It needs to be
> read somewhat literally, but it is correct.
>
> It's also part of template constraint, useful once you've
> become accustomed to reading them:
>
> auto splitter(alias pred = "a == b", Range,
> Separator)(Range r, Separator s)
> if (is(typeof(binaryFun!pred(r.front, s)) : bool) &&
> ....
>
> For "a.b.c"splitter(x), Range r is a string, r.front is a char.
> The template can only be instantiated if the predicate function
> is valid. The predicate function is "a == b". Since r.front is
> a char, then s must be a type that can be compared with '=='. A
> string and char cannot be compared with '==', which is why the
> a valid template instantiation could not be found.
Would it be correct to just update the documentation to say
"Lazily splits a range using an char as a separator" ? what is
it; wchar and dchar too?
I notice the example that is there has ' ' as the element.
More information about the Digitalmars-d-learn
mailing list