Template for extracting types with staticMap?

Justin Whear justin at economicmodeling.com
Wed Jul 31 17:03:15 PDT 2013


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:

private template Extract(string fieldName)
{
	template Extract(T)
	{
		mixin(`alias Extract = T.`~fieldName~`;`);
	}
}

Used like so:
struct Foo(T)
{
    alias Type = T;
}

alias FooTypes = staticMap!(Extract!"Type", TypeTuple!(Foo!int, Foo!
double));


More information about the Digitalmars-d-learn mailing list