有一个功能:
void some_function(int id,...);
Run Code Online (Sandbox Code Playgroud)
问题:有没有办法包装这个功能?这意味着得到这样的东西:
void wrapped_some_function(int id,...)
{
//do smth
some_function(id,...);
}
Run Code Online (Sandbox Code Playgroud)
因为这也被标记为 C++: C++11 ftw。
#include <utility> // forward
template<class... Args>
void wrapped_some_function(int id, Args&&... args)
{
//do smth
some_function(id, std::forward<Args>(args)...);
}
Run Code Online (Sandbox Code Playgroud)