Passing variable number of arguments around

前端 未结 11 781
我寻月下人不归
我寻月下人不归 2020-11-22 07:16

Say I have a C function which takes a variable number of arguments: How can I call another function which expects a variable number of arguments from inside of it, passing a

11条回答
  •  眼角桃花
    2020-11-22 07:30

    In magnificent C++0x you could use variadic templates:

    template 
    void format_string(char *fmt, Ts ... ts) {}
    
    template 
    void debug_print(int dbg_lvl, char *fmt, Ts ... ts)
    {
      format_string(fmt, ts...);
    }
    

提交回复
热议问题