[Issue 11921] New: dmd doesn't like expressions in templates, only values

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 13 12:20:40 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11921

           Summary: dmd doesn't like expressions in templates, only values
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: apennebaker at 42six.com


--- Comment #0 from Andrew Pennebaker <apennebaker at 42six.com> 2014-01-13 12:20:39 PST ---
I want to parse a substring into an integer. I try:

ios7crypt.d:

...
string hash = "104306170e120b";
auto seed = parse!(int)(hash[0..2]);
...

But dmd complains:

ios7crypt.d(68): Error: template std.conv.parse does not match any function
template declaration.

To get around this, I can separate parsing into two steps.

ios7crypt.d:

...
string hash = "104306170e120b";
string seed_str = hash[0..2];
auto seed = parse!(int)(seed_str);
...

The second snippet compiles and runs. I just wish I didn't have to do this;
that the template syntax could handle nested expressions.

Full source, in case anyone would like more context:

https://github.com/mcandre/ios7crypt/tree/master/d

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list