Considering the following function :
template<typename... List>
inline unsigned int myFunction(const List&... list)
{
return /* SOMETHING */;
}
What is the most simple thing to put instead of /* SOMETHING */
in order to return the sum of sizeof
all arguments ?
For example myFunction(int, char, double) = 4+1+8 = 13
In C++17, use a fold expression:
template<typename... List>
inline constexpr unsigned int myFunction(const List&... list)
{
return (0 + ... + sizeof(List));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With