0

How to acces each parameter in parameter pack?

I have a function delcaration in my main executable, but the function body is in other library

template<class ... Types>
some_class* foo (Types ... args){
   //cast args to var1, var2, var3 somehow
   return new some_class(var1, var2, var3); //var1 - int, var2 string, var3 - vector<int>
}

I have multiple implementation of foo one for each library and each time i know how what type of data I expect. The thing is that when using one library i have for example 2 argument - int, float, and second library needs int, string, vector.

The question is: how to access this data if I know how many parameters there are and what are the types of these parameters?

I know I could implement this use case in many different ways (i will propably move parameters to init function for each class), but now I am just curious how to make this work. Let say i can't change initializer of some_class.

0 Answers0