[Issue 6081] New: Function Literal Templates Don't Work when Nested in Templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 31 07:40:55 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6081

           Summary: Function Literal Templates Don't Work when Nested in
                    Templates
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: wfunction at hotmail.com


--- Comment #0 from wfunction at hotmail.com 2011-05-31 07:36:30 PDT ---
The following piece of code, which finds the length of the longest line in a
file,

    pipe!(readText, splitlines, map!((a) { return a.length; }),
reduce!max)("Temp.d");

fails with:

    Error: expression template map(Range) if (isInputRange!(Unqual!(Range))) is
not a valid template value argument



If you try to get around it by saying

    pipe!(readText, splitlines, map!(delegate size_t(string a) { return
a.length; }), reduce!max)("Temp.d");

you then get:

    Error: delegate std.algorithm.__dgliteral1 cannot access frame of function
Temp.main.__dgliteral1

and saying "function" instead of "delegate" doesn't change anything.


You can get around it with using a string instead of a function literal as the
template argument, but that still doesn't really solve the issue.

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


More information about the Digitalmars-d-bugs mailing list