Splitting Ranges using Lambda Predicates
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 9 15:01:29 PDT 2014
On Thursday, 9 October 2014 at 21:55:03 UTC, Nordlöw wrote:
> On Wednesday, 11 June 2014 at 08:58:58 UTC, monarch_dodra wrote:
>> auto slicer(alias isTerminator, Range)(Range input)
>> if (((isRandomAccessRange!Range && hasSlicing!Range) ||
>> isSomeString!Range)
>> && is(typeof(unaryFun!isTerminator(input.front))))
>> {
>> return SlicerResult!(unaryFun!isTerminator, Range)(input);
>> }
>> ...
>
> Your solution copied here
>
> https://github.com/nordlow/justd/blob/master/slicer.d
>
> errors as
> /home/per/opt/x86_64-unknown-linux-gnu/dmd/linux/bin64/src/phobos/std/algorithm.d(5752,24):
> Error: template std.functional.not!(isUpper).not cannot deduce
> function from argument types !()(dchar), candidates are:
> /home/per/opt/x86_64-unknown-linux-gnu/dmd/linux/bin64/src/phobos/std/functional.d(393,10):
> std.functional.not!(isUpper).not(T...)(T args) if
> (is(typeof(!unaryFun!pred(args))) ||
> is(typeof(!binaryFun!pred(args))))
> slicer.d(29,31): Error: template instance
> std.algorithm.find!(not, string) error instantiating
> slicer.d(16,12): instantiated from here:
> Slicer!(isUpper, string)
> slicer.d(85,30): instantiated from here:
> slicer!(isUpper, string)
>
> What's wrong?
My quick guess is you are missing the *global* imports for the
restraints. The compiler doesn't complain because the constraint
is in a "is(typeof(...))" test. The reason the typeof fails is
simply cause the compiler has no idea what unaryFun is.
More information about the Digitalmars-d-learn
mailing list