tuple sumlimation

Kevin Bealer kevinbealer at gmail.com
Fri Feb 16 23:11:19 PST 2007


Thanks - I didn't realize you could do this.

Kevin

Pragma wrote:
> Kevin Bealer wrote:
>> Currently, Tuples are sublimated into argument lists.  What do people 
>> think of using an operator (say, *) to prevent this?  The reason I ask 
>> is that the current technique makes it hard to pass multiple tuples on 
>> the same function call.
>>
>> I think it's not absolutely required; currently you can pass the tuple 
>> lengths, let the tuples melt together, and then split them with slicing.
>>
>> Kevin
> 
> The only workaround I have used for this is to turn a tuple into a 
> compile-time "struct" to pass it to another template:
> 
> import std.metastrings;
> 
> // use whatever name you want, and add whatever 'member' aliases you 
> need here
> template Struct(V...){
>     alias V Values;
> }
> 
> template MyExample(alias Arr1,alias Arr2){
>     pragma(msg,Format!("%s",Arr1.Values[0]));
>     pragma(msg,Format!("%s",Arr2.Values[0]));
> }
> 
> alias MyExample!(Struct!(1,2,3),Struct!("x","y","z")) Foobar;
> 



More information about the Digitalmars-d mailing list