Nested anonymous namespace?

前端 未结 2 1018
盖世英雄少女心
盖世英雄少女心 2021-02-06 22:54

When using an anonymous namespace are there any issues if it is nested within another namespace? For example, is there any real difference between Foo1.cpp and Foo2.cpp in the

2条回答
  •  醉酒成梦
    2021-02-06 23:17

    Anonymous namespace could be considered as a normal namespace with unique name which you do not know. According to C++ Standard 7.3.1.1:

    An unnamed-namespace-definition behaves as if it were replaced by

      namespace unique { /* empty body */ }
      using namespace unique;
      namespace unique { namespace-body }
    

    where all occurrences of unique in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program.

    There are no additional issues.

提交回复
热议问题