How can I have multiple parameter packs in a variadic template?

后端 未结 4 1584
情书的邮戳
情书的邮戳 2020-11-27 12:55

Function one() accepts one parameter pack. Function two() accepts two. Each pack is constrained to be wrapped in types A and B. Why is it

4条回答
  •  广开言路
    2020-11-27 13:22

    Here is another way to have several parameters packs using template template parameters:

    #include 
    
    template 
    struct foo {};
    
    template < typename... Types1, template  class T
             , typename... Types2, template  class V
             , typename U >
    void
    bar(const T&, const V&, const U& u)
    {
      std::cout << sizeof...(Types1) << std::endl;
      std::cout << sizeof...(Types2) << std::endl;
      std::cout << u << std::endl;
    }
    
    int
    main()
    {
      foo f1;
      foo f2;
      bar(f1, f2, 9);
      return 0;
    }
    

提交回复
热议问题