开发者

Partially specialize method pointers inside a template

开发者 https://www.devze.com 2023-02-01 16:10 出处:网络
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:

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

精彩评论

暂无评论...
验证码 换一张
取 消