Answer the question
In order to leave comments, you need to log in
How to convert one variadic template to another variadic template?
How to convert one variadic templates into another, with a different number of parameters, according to a certain rule? (the code illustrates the problem)
struct A{
int i;
std::string s;
unsigned int u;
};
/*функция времени выполнения что задаёт
правило по преобразованию <А> в <int, std::string>
*/
template<typename Arg...>
struct Types;
auto types_new=foo<A,float,A>();//вернёт Types<int,std::string,float,int,std::string>
Answer the question
In order to leave comments, you need to log in
https://en.cppreference.com/w/cpp/utility/tuple/tu...
using this function, and a rule of the form:
//пользовательское
template<> constexpr auto Type_to<>(glm::vec3 vec){
return std::tuple(vec.x,vec.y,vec.z);
//для любого типа
template<typename T>
constexpr auto Type_to(T value){
return value;
}
};
template<typename ...Arg>
constexpr auto foo(){
return std::tuple_cat{std::make_tuple<Arg>...,""};
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question