I have a class
template <typename T> struct Dispatch;
which is used to call a type-specific function. For instance, assume I have dispatchers like
template <> struct Dispatch <MyClass> {
static void Apply (void* a, MyClass& m)
{
::memcpy (a, &m, sizeof (m));
}
};
Now I have a bunch of classes for which I have a type-trait, ArrayTypes
. I would like to do something like:
template <> struct Dispatch <enable_if<IsArrayType>>
{
template <typename ArrayType>
static void Apply (void* a, ArrayType& m)
{
::memcpy (a, &m, ArrayTypeTraits<ArrayType>::GetSize (m));
}
};
Is this possible?
Use boost enable_if.
If boost is unavailable, check out the enable_if idiom.
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