Specialize member function template of a class template?

Template class Thing { // 5 public: Thing() : data(A) { } template Thing &operator=(const Thing &other) { printf("operator=: A = %d; B = %d\n", A, B); printf("this->data = %d\n", data); } Thing &operator=(const Thing &other) { printf("operator overload called"); printf("this->data = %d\n", data); } private: int data; } IIRC there are some lookup gotchas if you try to combine overloads with specializations, but that doesn't look necessary here.

Template class Thing { // 5 public: Thing() : data(A) { } template Thing &operator=(const Thing &other) { printf("operator=: A = %d; B = %d\n", A, B); printf("this->data = %d\n", data); } Thing &operator=(const Thing &other) { printf("operator overload called"); printf("this->data = %d\n", data); } private: int data; }; IIRC there are some lookup gotchas if you try to combine overloads with specializations, but that doesn't look necessary here.

I am ashamed I overlooked this completely. Many thanks! – strager Jul 15 '09 at 18:13.

Yes, I think an overload should work fine, though there are some strange things that can happen due to the order in which parameters and templates are matched. Just for completeness, here's how to make your original example compile: template class Thing { // 5 ... template Thing &operator=(const Thing &); }; template template Thing &Thing::operator=(const Thing &other) { // 23 ...

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions