I currently have a variadic function which takes an arbitrary number of arguments of arbitrary types (duh), however, I want to restrict the types to ones which are POD only, and also the same size or smaller than that of a void*.
The void* check was easy, I just did this:
static_assert(sizeof...(Args) <= sizeof(PVOID), "Size of types must be <= memsize.");
However I can't work out how to do the same for std::is_pod.
Is this possible to do?
You can write a meta-function to determine if all are POD types:
template <typename... Ts>
struct all_pod;
template <typename Head, typename... Tail>
struct all_pod<Head, Tail...>
{
static const bool value = std::is_pod<Head>::value && all_pod<Tail...>::value;
};
template <typename T>
struct all_pod<T>
{
static const bool value = std::is_pod<T>::value;
};
then
static_assert( all_pod<Args...>::value, "All types must be POD" );
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