TypedefType

Get the underlying type which a Typedef wraps. If T is not a Typedef it will alias itself to T.

template TypedefType (
T
) {}

Examples

1 import std.conv : to;
2 
3 alias MyInt = Typedef!int;
4 static assert(is(TypedefType!MyInt == int));
5 
6 /// Instantiating with a non-Typedef will return that type
7 static assert(is(TypedefType!int == int));
8 
9 string num = "5";
10 
11 // extract the needed type
12 MyInt myInt = MyInt( num.to!(TypedefType!MyInt) );
13 assert(myInt == 5);
14 
15 // cast to the underlying type to get the value that's being wrapped
16 int x = cast(TypedefType!MyInt) myInt;
17 
18 alias MyIntInit = Typedef!(int, 42);
19 static assert(is(TypedefType!MyIntInit == int));
20 static assert(MyIntInit() == 42);

Meta

Suggestion Box / Bug Report