Two variadic templates for a single function?

后端 未结 1 1376
温柔的废话
温柔的废话 2021-01-11 19:45

In C++11 is it possible to have two variadic templates for a single function ?

If not, is there a trick to write something like that :

template 

        
相关标签:
1条回答
  • 2021-01-11 20:24

    That's perfectly legal:

    #include <tuple>
    
    using namespace std;
    
    template <class... Types, class... Args>
    void f(const std::tuple<Types...>& t, Args&&... args)
    {
        // Whatever...
    }
    
    int main()
    {
        std::tuple<int, double, bool> t(42, 3.14, false);
        f(t, "hello", true, 42, 1.0);
    
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题