2
votes

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<Class, 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.

1

1 Answers

1
votes

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>
{
  ...
}