On Saturday, 7 December 2013 at 23:02:18 UTC, Ellery Newcomer wrote:
On Saturday, 7 December 2013 at 19:36:50 UTC, Jesse Phillips wrote:

This declaration doesn't make sense to me:

   string a() immutable {
       return " 1";
   }

http://dlang.org/class.html#member-functions

That isn't really the type of a delegate though. Outside of a class that usage has no meaning or value. Even so, I don't actually understand what value it brings over declaring the function const (maybe only callable by an immutable instance?).

What is wrong with the current template which returns an immutable delegate type? It still store you're immutable member function.

class Z {
    string a() immutable {
        return " 1";
    }
}

template F(t) {
    alias immutable(t) F;
}
alias typeof(&Z.init.a) Texpected;
alias typeof(&Z.init.a) T;

static assert(is(F!(T) : Texpected));
static assert(is(Texpected : F!(T) ));

void main() {}

Reply via email to