On 25.10.2011 18:35, Gor Gyolchanyan wrote:
What? Are you sure? It's supposed to be! Sharedness of the method is
the sharedness of the _this_ parameter, which must cause overloading,
since shared-ness of a type is part of the type.
If so, it's definitely a bug.

On Tue, Oct 25, 2011 at 8:24 PM, Andrew Wiley<[email protected]>  wrote:


On Tue, Oct 25, 2011 at 8:06 AM, Gor Gyolchanyan
<[email protected]>  wrote:

And so you can have both thread-safe synchronized heavy-duty container
and a fast and small container all in one just by overloading the
appropriate methods and adding appropriate synchronization blocks in
the shared ones.
This is one of those "little" advantages of D over C++, that make my
life _SO_ much easier.


Except that overloading shared and non-shared methods is not allowed.

It works for simple cases at least:

class C {
    int i() shared {
        return 1;
    }

    int i() {
        return 2;
    }
}

void main() {
    auto c1 = new C();
    assert(c1.i() == 2);
    auto c2 = cast(shared)new C();
    assert(c2.i() == 1);
}

Reply via email to