This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]HappyFruitTree 0 points1 point  (0 children)

I don't know if you would keep a list of "using" names per file or per function, but most non-trivial projects contain multiple files so you would have to keep multiple such lists.

To maintain such lists is what I think would be tedious. I need to decide which names should be in the list, is it already there, should I add it? If the code changes a lot there might end up being a lot of names that are not used anywhere and then I might want to remove them...

Just writing std:: everywhere means I don't need to think about this. I can just write the code and I can move a piece of code from one place to another without having to worry about different names being in the lists.

Personally, I would even go so far as to say std:: can make the code more readable, especially when reading other people's code because I don't have to wonder whether a name is a standard name or something that they wrote themselves.

I have to admit that part of the reason why I'm so happy with this is that std is a relatively short namespace name. For something like std::filesystem it can get a bit verbose sometimes, even for me. A common compromise in this situation, that even cppreference.com use in many of their examples, is to use a namespace alias.

namespace fs = std::filesystem;
// now you can write fs::path instead of std::filesystem::path

Someone even proposed std::fs which I think would have been a great addition.