Obtain Argument Index while Unpacking Argument List with Variadic Templates

后端 未结 2 1925
生来不讨喜
生来不讨喜 2020-12-18 11:57

I need to obtain the index of an argument while unpacking and converting argument list. Is there any solution for the following problem:



        
2条回答
  •  鱼传尺愫
    2020-12-18 12:13

    The simplest solution is surely to not use a vector of void*; just use the values directly:

    template
    void call_test(Arg const&...arg) {
      test(arg...);
    }
    

    (Or some variant on that theme.) But I suppose you wanted to do something other than just call test.

    If you really want the indices, use what's called here the "indices trick". You should be able to search for that.

提交回复
热议问题