"Arkadiy Vertleyb"
wrote | "Thorsten Ottosen" wrote | > "Arkadiy Vertleyb" wrote in message | > I don't get this. Surely one of the functions would be a better match
"Thorsten Ottosen"
| > the others and hence called. | | How is | | namespace MyNamespace | { | template<class T> end(const T&); | } | | is better match than | | namespace YourNamespace | { | template<class T> end(const T&); | } | ? | | And now: | | MyNamespace::FooYourNamespace::Bar obj; | end(obj); // ?????
Why would any function but the primary template be taking a const T& param, that is, why don't your YourNamespace::end() refer to some class in YourNamespace?
Because one may have many unrelated templates that support the same concept. Consider your range library. What if one wants to write end() that is good for any std container? I am not saying that taking "const T&" is a good thing to do. All that I am saying -- it is legal C++. And one should be OK doing this in their own namespace. The worst thing about this is that your library can clash with not a user code, but with some other library that user has no control about... Regards, Arkadiy