I'm on a microcontroller, so in order to avoid the new operator, I reserve some memory to be used in a placement new operator call. I'd like to determine the minimum size of that memory by supplying a number of types to a constexpr function that will return the largest type in the list.
struct A
{
int foo;
int bar[24];
};
struct B
{
int foo;
int bar[126];
};
uint8_t objectMem[max_sizeof<A, B>());
Is there such a thing as a "parameter pack" for typenames? I'd like to be able to append any number of types as template arguments.
Something along these lines:
template <typename... Ts>
constexpr size_t max_sizeof() {
return sizeof(std::aligned_union<0, Ts...>::type);
}