www.digitalmars.com         C & C++   DMDScript  
Archives

D Programming
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
D.gnu
D

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics


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?

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