Type Qualifiers and Wild Cards
Martin Nowak
dawg at dawgfoto.de
Tue Nov 8 11:10:03 PST 2011
On Tue, 08 Nov 2011 02:08:27 +0100, Walter Bright
<newshound2 at digitalmars.com> wrote:
> http://drdobbs.com/blogs/cpp/231902461
>
> Anyone want to do the reddit honors?
I personally find it much more astonishing that inout methods finally work.
All of this with one method definition, without const_cast macros, without
overload ambiguities
but with transitive qualifier safety.
----
import std.stdio;
class C
{
inout(int) foo() inout
{
return a;
}
int a;
}
void printType(T)(T t)
{
writeln(typeid(t.foo()));
}
void main()
{
auto a = new immutable(C)();
auto b = new C();
printType!(immutable C)(a);
printType!(const C)(a);
printType!(const C)(b);
printType!(C)(b);
}
More information about the Digitalmars-d
mailing list