std.conv.parse not accepting ByCodeUnitImpl

Jack Stouffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 23 18:59:34 PDT 2016


Consider the following code

---------
import std.range;
import std.conv;
import std.utf;
import std.algorithm;

auto test(R)(R s)
{
     auto value = s.byCodeUnit;
     auto splitValue = value.splitter('.');
     parse!int(splitValue.front);
}

void main()
{
     test("1.8");
}
---------

This fails to compile and I can't for the life of me understand 
why. The std.conv.parse call doesn't match any parse overload 
when it should match the second one:

---------
std.conv.parse(Target, Source)(ref Source s) if (
     isSomeChar!(ElementType!Source) && isIntegral!Target && 
!is(Target == enum))
---------

Manually verifying the template constraints proves that it should 
work,

---------
pragma(msg, isSomeChar!(ElementType!(typeof(splitValue.front))), 
isIntegral!int, !is(int == enum));

truetruetrue
---------

Any help here would be appreciated.


More information about the Digitalmars-d-learn mailing list