Suggesting an addition to std.traits for arrays and pointers
Markus Dangl
danglm at in.tum.de
Mon Aug 13 20:22:21 PDT 2007
I think these two simple templates could be added to std.traits. Afaik
there is no way around defining templates for this:
/***
* Get the referenced type of an array.
* Example:
* ---
* import std.traits;
* int[] foo;
* ValueType!(foo) x; // x is declared as int
* ---
*/
template ValueType(T : T*)
{
alias T ValueType;
}
/***
* Get the referenced type of an pointer.
* Example:
* ---
* import std.traits;
* int* foo;
* ValueType!(foo) x; // x is declared as int
* ---
*/
template ValueType(T : T[])
{
alias T ValueType;
}
More information about the Digitalmars-d-announce
mailing list