Generating members from parameter tuple

Brad Anderson eco at gnuk.net
Mon Aug 19 00:36:29 PDT 2013


On Monday, 19 August 2013 at 06:56:24 UTC, Brad Anderson wrote:
> import std.typetuple;
>
> struct S(T...)
> {
> 	alias Types = T;
> }
>
> alias Si = S!(int, short);
> alias Sf = S!(float, double);
>
> template STypes(STy) { alias STypes = STy.Types; }
>
>
> struct B(Ss...)
> {
> 	alias CombinedTypes =
> 		NoDuplicates!(TypeTuple!(staticMap!(STypes, Ss)));
> 	
> 	// I'd like to create a member here for every type in 
> CombinedTypes
> 	// that is an array of each type. e.g.,
> 	// int[] 	_intArray;
> 	// short[] 	_shortArray;
> 	// float[]	_floatArray;
> 	// double[]	_doubleArray;
> 	//
> 	// I don't believe the names matter because I'd probably want
> 	// to use a templated method that returns the appropriate
> 	// member based on the type supplied (e.g., getArray!int(),
> 	// getArray!short(), etc.)
> }

For got to add a B!(Si, Sf) somewhere (I had a main() but 
stripped it out).


More information about the Digitalmars-d-learn mailing list