www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16034] New: map should be possible with a reference only

https://issues.dlang.org/show_bug.cgi?id=16034

          Issue ID: 16034
           Summary: map should be possible with a reference only
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

the following doesn't work:

void main()
{
    struct One
    {
        int entry = 1;
         disable this(this);
    }
    One[] ones = [One(), One()];

    import std.algorithm.iteration: map;
    import std.algorithm.comparison: equal;
    assert(ones.map!`a.entry + 1`.equal([2, 2]));
}

foo.d(12): Error: template std.algorithm.iteration.map!"a.entry + 1".map cannot
deduce function from argument types !()(One[]), candidates are:
/usr/include/dlang/dmd/std/algorithm/iteration.d(450):       
std.algorithm.iteration.map!"a.entry + 1".map(Range)(Range r) if
(isInputRange!(Unqual!Range))

(It doesn't matter whether string or real lambda are used)

--
May 17 2016