usm*_*man 33 c++ templates c++11
我想为我的应用程序使用可变参数模板功能,但我不希望通过值传递对象(因为对象在我的情况下非常复杂).我想通过引用传递它们(而不是作为指针).
void func()
{
}
template<typename Function1, typename... FurtherFunctions>
void func(Function1 f1, FurtherFunctions... further_functions)
{
// doing some processing here...
}
Run Code Online (Sandbox Code Playgroud)
我如何通过引用传递参数并确保它们不被复制?
Ker*_* SB 37
说啊:
template <typename ...Args>
int myfunction(Args & ... args)
{
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
同样的const Args & ... args
,Args && ... args
等等