www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Type.stringof is removing alias and bitmanip

reply "deadalnix" <deadalnix gmail.com> writes:
As a result, it is impossible to use thing like bitfields in 
templates.

I'm trying to do something like

struct MySuperStruct(E) {
	enum DataSize = ulong.sizeof * 8 - EnumSize!E;
	
	import std.bitmanip;
	mixin(bitfields!(
		E, "kind", EnumSize!E,
		ulong, "data", DataSize,
	));
	
         // More stuuuuuuufffffff \o/
}

But obviously, that won't work as mixins are using the real type 
of E, and not E. I ran into that problem on other forms, and 
always was able to work around it, but on that one, there is no 
way around it.
Dec 08 2014
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Monday, 8 December 2014 at 08:25:36 UTC, deadalnix wrote:
 As a result, it is impossible to use thing like bitfields in 
 templates.

 I'm trying to do something like

 struct MySuperStruct(E) {
 	enum DataSize = ulong.sizeof * 8 - EnumSize!E;
 	
 	import std.bitmanip;
 	mixin(bitfields!(
 		E, "kind", EnumSize!E,
 		ulong, "data", DataSize,
 	));
 	
         // More stuuuuuuufffffff \o/
 }

 But obviously, that won't work as mixins are using the real 
 type of E, and not E. I ran into that problem on other forms, 
 and always was able to work around it, but on that one, there 
 is no way around it.
We need a way to actually rename types. Personally I would like a resurrection of typedef to *only* opaquely rename types and to be identical to alias in all other ways. Everything else important can be dealt with by one or more library types, renaming is the missing piece.
Dec 08 2014