Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 18:43:05 UTC, Steven Schveighoffer wrote: If parse can do it, to should as well. I think it's a question of how the template constraints are done. Please file an issue. Found this: https://issues.dlang.org/show_bug.cgi?id=15800

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 2:23 PM, Jack Stouffer wrote: On Wednesday, 25 May 2016 at 16:53:30 UTC, Steven Schveighoffer wrote: to should work wherever parse works (in fact, whenever you call to!someType(someString), I believe it just forwards to parse). This is not the case; to doesn't work with ranges:

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 16:53:30 UTC, Steven Schveighoffer wrote: to should work wherever parse works (in fact, whenever you call to!someType(someString), I believe it just forwards to parse). This is not the case; to doesn't work with ranges: auto str = "1234567".byCodeUnit;

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 12:10 PM, Jack Stouffer wrote: On Wednesday, 25 May 2016 at 15:34:45 UTC, Steven Schveighoffer wrote: parse consumes data from the string as it goes. I know that, I'm asking why. This disallows the natural range chaining and forces you to save to a variable before calling parse

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 15:34:45 UTC, Steven Schveighoffer wrote: parse consumes data from the string as it goes. I know that, I'm asking why. This disallows the natural range chaining and forces you to save to a variable before calling parse even though the function works just as well

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 11:15 AM, Jack Stouffer wrote: On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote: You're missing that `parse`'s parameter is `ref`. Do you what the rationale behind this is? I just removed the ref from the floating point from input range overload and it works fine for

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote: You're missing that `parse`'s parameter is `ref`. Do you what the rationale behind this is? I just removed the ref from the floating point from input range overload and it works fine for strings.

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-24 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote: You're missing that `parse`'s parameter is `ref`. `splitValue.front` is not an lvalue, so it can't be passed in a ref parameter. This works: auto f = splitValue.front; parse!int(f); Thanks. DMD desperately needs

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-23 Thread ag0aep6g via Digitalmars-d-learn
On 05/24/2016 03:59 AM, Jack Stouffer wrote: parse!int(splitValue.front); [...] std.conv.parse(Target, Source)(ref Source s) if ( isSomeChar!(ElementType!Source) && isIntegral!Target && !is(Target == enum)) You're missing that `parse`'s parameter is `ref`. `splitValue.front` is

std.conv.parse not accepting ByCodeUnitImpl

2016-05-23 Thread Jack Stouffer via Digitalmars-d-learn
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