Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/133.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在一个变量函数中前进一个特定的参数范围_C++_Variadic Templates_Variadic Functions_Variadic - Fatal编程技术网

C++ 在一个变量函数中前进一个特定的参数范围

C++ 在一个变量函数中前进一个特定的参数范围,c++,variadic-templates,variadic-functions,variadic,C++,Variadic Templates,Variadic Functions,Variadic,有没有一种方法可以在变量函数中转发特定范围的参数?例如: #include <iostream> template<typename T> void test_simple(T v0,T v1) { std::cout<<v0<<","<<v1<<std::endl; } template<typename... TARGS> void test_variadic(TARGS ...a

有没有一种方法可以在变量函数中转发特定范围的参数?例如:

#include <iostream>

template<typename T>
    void test_simple(T v0,T v1)
{
    std::cout<<v0<<","<<v1<<std::endl;
}

template<typename... TARGS>
    void test_variadic(TARGS ...args)
{
    test_simple(std::forward<TARGS>(args)...); // Forward all arguments except for the first one?
}

int main(int argc,char *argv[])
{
    test_variadic(5.f,2.f,7.f);
    return EXIT_SUCCESS;
}
#包括
模板
无效试验(T v0,T v1)
{

std::cout使用额外的模板参数:

template <typename T, typename... Ts>
void test_variadic(T&& arg, Ts&&... args) {
    test_simple(std::forward<Ts>(args)...);
}
模板
无效测试变量(T&&arg,Ts&&args){
简单测试(标准:正向(args)…);
}

这样一来,第一个参数就不是变量的一部分。

您是要删除第一个参数,还是要转发2个lasts?(与3个参数相同,但与其他数字不同)。