Hello everyone,
Here is the quoted section, words from Bjarne and his sample. The reason why I think the sample is wrong, is because, the member function sort accepts empty arguments, so when we call ::sort (v), only the one in global namespace will be matched -- there is no ambiguity to call sort member function of Container from parameter list comparison. I do not know why Bjarne commets "sort (vector<T>&) which calls std::sort() rather than Container::sort()" -- I think it has nothing to do with template -- just a normal function call matching.
Any comments? Do you agree with me and think his sample is wrong?
section 13.8.3 Point of Instantiation Binding
--------------------
unqualified name can not be bound to members of that class
--------------------
Code:template <class T> void sort (vector<T>& v) { sort (v.begin(), v.end()); } class Container { vector<int> v; // elements public: void sort() // sort elements { ::sort (v); // sort (vector<T>&) which calls std::sort() rather than Container::sort() } };
thanks in advance,
George



LinkBack URL
About LinkBacks




CornedBee