Partially specialize method pointers inside a template
I'm trying to implement properties with readonly, writeonly and readwrite behaviour. I thought template specialization would be the way to go here, so I tried this:
template<typename Class, typename Type, void (Class::*Set)(Type), Type (Class::*Get)(void)>
class Property;
template <typename Class, typename Type, Type (Class::*Get)(void)>
class Property<Cl开发者_如何学Pythonass, Type, NULL, Get>
{
...
}
This doesn't work and gives an compiler error (VC): a partial specialization cannot have a dependent non-type template parameter.
I'm lost here, is this at all possible?
Thanks for your time, Richard.
you can use less specialized approach like:
template<typename Class, typename Type, typename Get_functor, typename Set_functor>
class Property;
template <typename Class, typename Type, typename Get_functor>
class Property<Class, Type, NULL, Get_functor>
{
...
}
精彩评论