Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Multiple parameter packs in function parameters

Reply
Thread Tools

Re: Multiple parameter packs in function parameters

 
 
Zhihao Yuan
Guest
Posts: n/a
 
      11-30-2012
On Friday, November 30, 2012 5:28:07 AM UTC-6, Juha Nieminen wrote:
> Is this valid code, or should it even compile?
>
> template<typename... Pack1, typename... Pack2>
> void func(Pack1... pack1, Pack2... pack2) {}


This is valid. However, according to 14.8.2.1/1, for a function
parameter pack that does not occur at the end of the
parameter-declaration-list (Pack1, here), the type of the parameter
pack is a non-deduced context.

Which means, even for

template <typename... Pack>
void func(Pack... pack, int) {}

Pack is not deducible; only a call (w/o an explicitly specified
template argument list) like `func(1)' works.

> With clang if you try to call it directly with "func()" or "func(5)" you
> get strange and conflicting error messages (in the first case it tells


It seems that clang enforces to deduce the parameter pack that occurs
earlier, while gcc can try those occur latter. Gcc's behavior looks
more reasonable to me.

> 0 parameters.) However, if you call it like "func<int>(5)" then it
> compiles (all parameters are passed as 'pack1'.)


Explicitly filling Pack1, leaving Pack2 zero types.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Multiple parameter packs in function parameters Victor Bazarov C++ 7 11-30-2012 04:12 PM
C++0X parameter packs as last arguments only Marc C++ 5 10-17-2010 12:50 PM
Function as parameter of a function with parameters marc C Programming 3 07-07-2009 02:28 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
restriction of a two-parameters function to a one-parameter function Boris Sargos C++ 3 04-23-2004 04:14 PM



Advertisments