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,
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!
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
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
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
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
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
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)
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
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()
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
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
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
13 matches
Mail list logo