www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: std.string will get the boot

Lionello Lunesu Wrote:

 On 31-1-2010 16:34, Simen kjaeraas wrote:
 Lionello Lunesu <lio lunesu.remove.com> wrote:
 I miss typedef. I think this is exactly what typedef was intended
 for. Perhaps we can reintroduce it as a 'short hand' for such a

struct Typedef( T ) { T payload; alias payload this; } Usage: alias Typedef!( int ) myInt; Is this what you want?

Using alias you loose all type safety. I remember Andrei mentioned that he and Walter couldn't agree whether typedef should behave as a sub or super class. I think it should not be looked at from a inheritance perspective, but just consider it as wrapper struct with a ctor that takes the underlying type.

I think you may misunderstand what the "alias this" construct does. It does exactly what you ask for: http://www.digitalmars.com/d/2.0/class.html#AliasThis
Feb 02 2010