9 ms·
Is "using namespace std" still considered heresy? I rather liked it. It'd make a lot of these examples a little more readable.
by sillysaurusx 5y ago
Is "using namespace std" still considered heresy? I rather liked it. It'd make a lot of these examples a little more readable.
- riskneutral 5y agoI don't like it, clarity is better in C++. Things are complicated enough as it is.
- kragen 5y agoHow about `using std::find_if`?
- dataflow 5y agoUnqualified calls change the behavior. You end up doing ADL instead of a normal lookup and could potentially end up calling a different function than the one you intended entirely. Sometimes that's intentional (as with swap), but often it's a bug.
- sillysaurusx 5y agoI've been a C++ dev for longer than I care to admit. The idea that you could call the wrong function after putting "using std::string" at the top of your .cpp file doesn't reflect my experience. You might have a point if people are putting that in header files. But even in header files, "using std::string" is often a standard thing to do in e.g. game engines. It's far easier to change out your string implementation if you're writing "string" instead of "std::string".
- dataflow 5y ago> using std::string The question was about find_if, which is a function, not string.
- deleted 5y ago[deleted]
- eska 5y agoDefinitely don't use it in headers, because it pollutes the namespace of files including it. In .cpp files it's more subjective. You can also resort to only using it in functions, to limit it's scope to code where you make heavy use of std.