[Issue 5003] New: regex(replace with delegate) sample doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 6 10:54:34 PDT 2010


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

           Summary: regex(replace with delegate) sample doesn't work
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: zan77137 at nifty.com
        Depends on: 1904


--- Comment #0 from SHOO <zan77137 at nifty.com> 2010-10-06 10:54:09 PDT ---
This code doesn't work!


import std.regex, std.string;

void main()
{
    string baz(RegexMatch!(string) m)
    {
        return std.string.toupper(m.hit);
    }
    auto s = replace!(baz)("Strap a rocket engine on a chicken.",
        regex("[ar]", "g"));
}


RESULT:
    std/regex.d(2840): Error: struct std.regex.RegexMatch!(string).RegexMatch
member test is not accessible


See also:
    http://ideone.com/7pGAm


Workaround:
Define the dummy free function for RegexMatch!(string).test.

private bool _dummyTest(Engine)(Engine r, size_t idx)
{
    return r.test(idx);
}


Note:
This issue is maybe related with bug 1904.
- Template function's alias parameter takes delegate.
- Template function uses same module's structs or classes and calls their
private function.

-- 
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