Abseil C++

An open-source collection of C++ library code designed to augment the C++ standard library

  • Tip of the Week #153: Don’t use using-directives
    https://abseil.io/tips/153

    Originally posted as TotW #153 on July 17, 2018

    by Roman Perepelitsa (roman.perepelitsa@gmail.com) and Ashley Hedberg (ahedberg@google.com)

    I view using-directives as time-bombs, both for the parties that deal in them and the language system. – Ashley Hedberg with apologies to Warren Buffett

    tl;dr

    Using-directives (using namespace foo) are dangerous enough to be banned by the Google style guide. Don’t use them in code that will ever need to be upgraded.

    These are not to be confused with using-declarations (using ::foo::SomeName), which are permitted in *.cc files.

    Using-directives at Function Scope

    What do you think this code does?

    namespace totw namespace example namespace

    TEST(MyTest, UsesUsingDirectives) using namespace ::testing; Sequence seq; // ::testing::Sequence (...)