'C++ variadic template: typeid of it, way to optimize
So, I learn variadic templates and usage of it. Now I made that code below. The question is does some other methode exist for getting type of "Params" without any arrays or inilialized_list?
template<class Type, class... Params>
void InsertInVector(std::vector<Type>& v, const Params&... params)
{
const auto variadic = {typeid(Params).name()...};
if (typeid(Type).name() != *variadic.begin())
{
throw std::runtime_error("TYPES ARE NOT THE SAME!");
return;
}
v.insert(v.end(), {params...});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
