c++ - Template specialization for types providing a traits class -


i have class

template <typename t> struct dispatch; 

which used call type-specific function. instance, assume have dispatchers like

template <> struct dispatch <myclass> {   static void apply (void* a, myclass& m)   {       ::memcpy (a, &m, sizeof (m));   } }; 

now have bunch of classes have type-trait, arraytypes. 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 possible?

use boost enable_if.

if boost unavailable, check out enable_if idiom.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -