Here you go:
std::endl(std::operator<<(std::cout, "Hello world!"));
By writing it this way, we avoid error-prone ADL along with using directives and declarations.
This is meant to be a sarcastic answer. :-D
I'm with Herb Sutter over Google on this one. From C++ Coding Standards:
You can and should use namespace using declarations and directives liberally in your implementation files after #include directives and feel good about it. Despite repeated assertions to the contrary, namespace using declarations and directives are not evil and they do not defeat the purpose of namespaces. Rather, they are what make namespaces usable.
You can obsess about potential namespace conflicts that will probably never manifest and probably won't be difficult to fix in such an astronomically rare event by carefully avoiding
using directives and explicitly specifying each and every thing you use (down to the operators) with
using declarations, or just go ahead and start
using namespace std. I recommend the latter from a productivity standpoint.
Most c++ text books teach beginners with using namespace std; are they
propagating poor coding practice?
The opposite if you ask me, and I believe Sutter above agrees.
Now, over the course of my career, I have encountered around 3 namespace conflicts total as a direct result of
using directives in codebases spanning tens of millions of LOC. However, in all 3 cases, they were in source files that spanned over 50,000 lines of legacy code, originally written in C and then bastardized to C++, performing a massive eclectic list of disparate functions, including headers from a dozen different libraries, and having an epic list of
#includes that spanned over a page. In spite of the epic mess, they weren't too difficult to fix since they caused build errors on OSX (the one OS where the code failed to build), not runtime bugs. Don't organize your code this nightmarish way and you should be fine.
That said, avoid both
using directives and declarations in header files. That's just plain retarded. But for source files, and especially ones that don't have a whole page filled with
#include directives, I'd say don't sweat it if you aren't working for Google.