www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Multiple template variadic list not working

reply bastien penavayre <swac31 gmail.com> writes:
I've been trying to translate the following idea expressed here 
in c++:

template <auto... UserArgs, class... Arguments>
void func(Arguments... args) {}

so I tried

void func(UserArgs..., Arguments...)(Arguments args) {}

and then

void func(Args...)(Filter!(isType, Args) args) {}

but nothing works.
This seems like something simple to handle, why is it not then ?
May 21
next sibling parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Sunday, 21 May 2017 at 15:13:55 UTC, bastien penavayre wrote:
 I've been trying to translate the following idea expressed here 
 in c++:

 template <auto... UserArgs, class... Arguments>
 void func(Arguments... args) {}

 so I tried

 void func(UserArgs..., Arguments...)(Arguments args) {}

 and then

 void func(Args...)(Filter!(isType, Args) args) {}

 but nothing works.
 This seems like something simple to handle, why is it not then ?
How would that work ? How would I know where UserArgs end, and Arguments begin ?
May 21
parent bastien penavayre <swac31 gmail.com> writes:
On Sunday, 21 May 2017 at 15:16:55 UTC, Stefan Koch wrote:
 How would that work ?
 How would I know where UserArgs end, and Arguments begin ?
func!(UserArgs here)(Arguments values here); C++ does it without any problem. I don't see what prevent D from doing it.
May 21
prev sibling parent reply Stanislav Blinov <stanislav.blinov gmail.com> writes:
On Sunday, 21 May 2017 at 15:13:55 UTC, bastien penavayre wrote:
 I've been trying to translate the following idea expressed here 
 in c++:

 template <auto... UserArgs, class... Arguments>
 void func(Arguments... args) {}

 so I tried

 void func(UserArgs..., Arguments...)(Arguments args) {}

 and then

 void func(Args...)(Filter!(isType, Args) args) {}

 but nothing works.
 This seems like something simple to handle, why is it not then ?
In this case, eponymous template should do the trick: template func(UserArgs...) { void func(Arguments...)(Arguments args) {} }
May 21
parent bastien penavayre <swac31 gmail.com> writes:
On Sunday, 21 May 2017 at 15:30:38 UTC, Stanislav Blinov wrote:
 In this case, eponymous template should do the trick:

 template func(UserArgs...) {
     void func(Arguments...)(Arguments args) {}
 }
Ah I see, I didn't know of this technique. Thanks.
May 21