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



--- Comment #3 from Steven Schveighoffer <schvei...@yahoo.com> 2011-09-20 
08:47:22 PDT ---
void c() const {}

This should work, as mutable and const implicitly cast to immutable.

Two other things (even though the above is the *right* solution to your
problem):

1. You can overload c, you don't need to use a template
2. You *can* get the exact type called with by using a this template parameter:

import std.stdio;

struct b
{
    void c(this T)() const
    {
        writeln(typeid(T));
    }
}

void main()
{
    immutable b b1;
    b b2;
    b1.c();
    b2.c();
}

output:

immutable(testimmutable.b)
testimmutable.b

But please note, the struct a has nothing to do with these issues, it's just
simply a way you have declared an immutable b (which you can easily do on the
stack).

Declaring an immutable struct is the same as applying immutable to all the
members.  Declaring a local immutable variable is the same thing.

Also note that in your attempt to use if constraints, you must use templates
(I'm sure you would have gotten error messages, so I think this is a simple
copy-paste omission)

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

Reply via email to