by usefulcat · 9y ago · 0 comments
using std::string;
It's not cool to impose that decision on clients of the library.
This should almost always be ok since no sane programmer should ever name their class string in the namespace of std.
As a developer, I wouldn't feel too bad about causing namespace conflicts in this manner because hopefully it will suggest to the maintainer that their class name is a poor choice.
He really shouldn't do that in a header, but if he at least moved it down a couple of lines so it's inside his private namespace, it at least wouldn't affect anyone else. There is no good reason to do it globally.
As to why a program would have two classes called string... well, there's a funny thing there, because it didn't, at least not until it started using this library that does "using std::string" in its header...
(Anyway, why is it the library author's concern? They're writing a library! Not only is this the tail wagging the dog, but they're actually making it harder to use, and easier to say no to. Exactly the wrong thing.)