Template for extracting types with staticMap?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Wed Jul 31 19:10:18 PDT 2013
On 8/1/13, Justin Whear <justin at economicmodeling.com> wrote:
> I find this template to be really handy for use with staticMap, and I'm
> wondering if it exists in Phobos in some form so that I can stop
> rewriting it:
Try this:
import std.typetuple;
template ExtractTypes(T)
{
static if (is(T : T!Y, Y...))
alias ExtractTypes = Y;
else
static assert(0);
}
struct Foo(T)
{
}
void main()
{
alias FooTypes = staticMap!(ExtractTypes, TypeTuple!(Foo!int, Foo!double));
pragma(msg, FooTypes);
}
More information about the Digitalmars-d-learn
mailing list