6

What is the difference between:

namespace A { inline namespace B { ... } ... } ... 

and

namespace A { namespace B { ... } using namespace B; ... } ... 

That is, what is the difference between an inline namespace, and a non-inline namespace with a using directive placed in its enclosing namespace?

2
  • 1
    IMO this question should be reopened because is different from the linked "duplicate" in that it specifically asks for the specific difference between the feature and an apparently equivalent construction. Commented Feb 4, 2020 at 16:27
  • 1
    @Catskul: As you wish Commented Feb 5, 2020 at 12:31

1 Answer 1

2

Paraphrased from C++11 7.3.1p8:

  • The inline namespace and its enclosing namespace are both added to the set of associated namespaces used in argument-dependent lookup whenever one of them is.

  • Each member of the inline namespace can subsequently be explicitly instantiated or explicitly specialized as though it were a member of the enclosing namespace.

  • Looking up a name in the enclosing namespace via explicit qualification will include members of the inline namespace brought in by the using-directive even if there are declarations of that name in the enclosing namespace.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.