std.algorithm issue

Dee Girl deegirl at noreply.com
Thu May 22 12:01:39 PDT 2008


Brian Myers Wrote:

> I think this is exactly what I wanted. I needed to use the address of operator along with the instance reference.
> 
> Wow some of the things you can do in D (like Dee Girl's post) are almost as esoteric and obscure as Felix!

In fact it is simpler. It is just bug in dmd. The following code works.

import std.algorithm;

struct A
{
    int Merge(int) { return 0; }
}

void main(string[] args)
{
    A a;
    auto fun = &a.Merge;
    map!(fun)([1, 2, 3]);
}

It is a problem that compiler can work with fun but not direct with &a.Merge. It is good idea to report bug to Walter. Such bug limits power of higher order functions. Thank you, Dee Girl




More information about the Digitalmars-d mailing list