Partial member function template specialisation and data member access

后端 未结 3 558
长情又很酷
长情又很酷 2021-01-13 16:22

I have a question regarding partial specialisation of templated member functions.

Background: The goal is to compute descriptive statistics of larg

3条回答
  •  旧巷少年郎
    2021-01-13 16:37

    push_impl can be made either an inner class template (if you use c++11) or a friend class template of your accumulator class (this seems like a good case for using friend declarations, since push_impl is essentially an integral part of your accumulator class implementation, separated purely for language reasons). Then you can use your option #3 (passing this to static methods of push_impl), but without making accumulator members public.

    Option #4 doesn't seem too bad either (since it avoids code duplication), but as you mentioned the performance impacts would need to be measured.

提交回复
热议问题