Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Philippe Sigaud
On Wed, Aug 8, 2012 at 7:01 AM, Philippe Sigaud philippe.sig...@gmail.com wrote: But that doesn't work for variadic templates, which is the OP's case: int foo(T...)(T t) { return 1; } alias expander!foo efoo; // error The template can easily be modified to deal with template functions,

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Andrej Mitrovic
On 8/8/12, Philippe Sigaud philippe.sig...@gmail.com wrote: Like this.. That's really cool. Could you put this in the DT book, along with your previous sample? Good job btw!

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Andrej Mitrovic
On 8/8/12, Philippe Sigaud philippe.sig...@gmail.com wrote: Hey, every time I do something like that, you ask me to put it in my template tutorial ;) Well yeah, we don't want a future Banana(tm) company patenting our codez, we need prior art! :p So maybe it's not book-worthy. Perhaps there

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Philippe Sigaud
On Wed, Aug 8, 2012 at 7:45 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 8/8/12, Philippe Sigaud philippe.sig...@gmail.com wrote: Hey, every time I do something like that, you ask me to put it in my template tutorial ;) Well yeah, we don't want a future Banana(tm) company

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Kenji Hara
On Tuesday, 7 August 2012 at 16:11:05 UTC, Andrej Mitrovic wrote: On 8/7/12, Øivind oivind@gmail.com wrote: How can I call this function with an already-constructed tuple but pass the pule as an expressiontuple? auto v = tuple(1, 2, 3); f(v); Use the .expand property: f(v.expand) You

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Philippe Sigaud
On Thu, Aug 9, 2012 at 1:26 AM, Kenji Hara k.hara...@gmail.com wrote: You can also use slice operator instead of expand property. import std.stdio, std.typecons; void f(T ...)(T t) { writeln(t.length); } void main(){ auto v = tuple(1, 2, 3); f(v[]); // prints 3 I didn't

How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Øivind
Given e.g. a function template void f(T ...)(T t) { writeln(t.length); } How can I call this function with an already-constructed tuple but pass the pule as an expressiontuple? auto v = tuple(1, 2, 3); f(v); In the case above, f will print 1 because 1 tuple is given to the function, but

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Andrej Mitrovic
On 8/7/12, Øivind oivind@gmail.com wrote: How can I call this function with an already-constructed tuple but pass the pule as an expressiontuple? auto v = tuple(1, 2, 3); f(v); Use the .expand property: f(v.expand)

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Øivind
On Tuesday, 7 August 2012 at 16:11:05 UTC, Andrej Mitrovic wrote: On 8/7/12, Øivind oivind@gmail.com wrote: How can I call this function with an already-constructed tuple but pass the pule as an expressiontuple? auto v = tuple(1, 2, 3); f(v); Use the .expand property: f(v.expand) Works

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Andrej Mitrovic
On 8/7/12, Øivind oivind@gmail.com wrote: The last one then becomes f(v0.expand, v1.expand) Yeah. It's somewhat possible to use a helper function for multiple TypeTuples, but the problem is D functions cannot return language tuples (only TypeTuple from std.typecons which is what the tuple()

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Philippe Sigaud
On Tue, Aug 7, 2012 at 7:35 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Yeah. It's somewhat possible to use a helper function for multiple TypeTuples, but the problem is D functions cannot return language tuples (only TypeTuple from std.typecons which is what the tuple() call

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Andrej Mitrovic
On 8/7/12, Philippe Sigaud philippe.sig...@gmail.com wrote: You can also take the 'dual' of your solution and have a template that makes a function automatically expand tuples But that doesn't work for variadic templates, which is the OP's case: int foo(T...)(T t) { return 1; } alias

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-07 Thread Philippe Sigaud
On Tue, Aug 7, 2012 at 11:31 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 8/7/12, Philippe Sigaud philippe.sig...@gmail.com wrote: You can also take the 'dual' of your solution and have a template that makes a function automatically expand tuples But that doesn't work for variadic