Re: Multiple parameter packs in function parameters

Discussion in 'C++' started by Zhihao Yuan, Nov 30, 2012.

  1. Zhihao Yuan

    Zhihao Yuan Guest

    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.
     
    Zhihao Yuan, Nov 30, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UU5ndXllbg==?=

    Error loading webform after applying service packs

    =?Utf-8?B?UU5ndXllbg==?=, Oct 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    334
    =?Utf-8?B?UU5ndXllbg==?=
    Oct 21, 2004
  2. Jacob H
    Replies:
    6
    Views:
    444
    Jerry McBride
    May 4, 2004
  3. Great Job
    Replies:
    0
    Views:
    431
    Great Job
    Feb 9, 2008
  4. Marc
    Replies:
    5
    Views:
    437
    Chris Ahlstrom
    Oct 17, 2010
  5. Victor Bazarov
    Replies:
    7
    Views:
    524
    Zhihao Yuan
    Nov 30, 2012
Loading...

Share This Page