Answer the question
In order to leave comments, you need to log in
How to find out the size of each element of the variable templates separately?
The variables float a, float a 2, MyClass a3, bool a4 were passed to the function instead of the parameter package. How can I find out the size of each of these variables in the function itself?
Answer the question
In order to leave comments, you need to log in
C++17 is required, for C++11 this is possible through template recursion. If necessary, I will explain how to do it.
template<typename ...Arg>
auto foo(){
std::vector<unsigned int> _sizeofs;// массив с размерами каждого элемента
((_sizeofs.push_back(sizeof(Arg))),...);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question