tuple sumlimation
Bill Baxter
dnewsgroup at billbaxter.com
Fri Feb 16 13:48:42 PST 2007
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;
Nice idea! But do you mean
struct Struct(V...) {
alias V Values;
}
??? Otherwise Struct is just making a Tuple. Or is the trick the fact
that you pass it as an alias to the template that needs two Tuples?
--bb
More information about the Digitalmars-d
mailing list