1

My original question was partially answered here

I still have to insist on one specific point. I try to specialize the following snippet with respect to U:

   template <class T, Location L>
    template <class U>
    Type Buffer<T, L>::getType(){
        return Type::INT;
    }

After reading some threads, I come to the following statemets:

  • So there's absolutely no way to specialize with respect to U only, right?

  • I can NOT specialize a member without specializing the class, no matter whether I specialize with respect to a class template parameter (T, L) or the function template parameter (U), right?

Experienced programmers may think that the question was already answered many times, but as a beginner in templates I could not confirm these statements absolutely certain.

Community
  • 1
  • 1
Michael
  • 7,407
  • 8
  • 41
  • 84
  • 1
    See the following questions: [C++ template specialization on functions](http://stackoverflow.com/questions/6623375/c-template-specialization-on-functions) and [A workaround for partial specialization of function template?](http://stackoverflow.com/questions/12237126/a-workaround-for-partial-specialization-of-function-template). – Constructor Jul 11 '14 at 13:27
  • I'm getting more and more confused, but in my eyes it's not a partial specialization of getType, but a full specialization. The member function will be specialized for all its template parameters (U). – Michael Jul 11 '14 at 14:26
  • 1
    It would be a full specialization if both template parameters of a class template and template parameters of a class template member were fixed. – Constructor Jul 12 '14 at 16:18
  • Ah...I begin to understand the reason behind this, thank you! – Michael Jul 12 '14 at 17:32

0 Answers0