explicit specialization of template class member function

狂风中的少年 提交于 2019-12-04 05:14:05

Unfortunately a template method inside a template class cannot be specialized just based on template argument of method.

You need to specialize the template class also. In other words, the member method specialization should be a complete specialization with respect to class template (i.e. <T,U>) params as well as the member template params (i.e. <size_t>).

For example, you may have to specialize something like this (demo):

template<>  // <------ you have to specialize class also
template<>
inline void A<int, double>::BindValues<1>()  // <-------- see A<T,U>
{
    ...
}

What you are trying to do is partial template specialization for a function, which is not allowed.

You can define the template function on N for a template specialization of A (e.g. A<int, int>::BindValues<N>()) but the other way around is not allowed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!