Visual C ++ compiler giving an invalid string reference for an ambiguous character

The code is as follows:

namespace n1
{
    template <class T>
    void n2();

    template <class T>
    void n2(T);
}

namespace n2 /* line 12 */
{
    class c {};
}

using namespace n1;

namespace n3
{
    void foo(n2::c);
}

void n3::foo(n2::c) /* line 24 */
{

}

When I try to compile it using the latest version of Visual C ++, I get the following error:

1>test.cpp(24): error C2872: 'n2': ambiguous symbol
1>test.cpp(12): note: could be 'n2'
1>test.cpp(24): note: or       'n2'

Lines 12 and 24 are marked in the previous code fragment with comments.

? foo n2:: c , , , , , , - , , n2 n1, , : 12 , n2 ( 24). ?

+4
1

, Microsoft . ++ $7.3.4.6,

, ....

, , :

namespace A {
  class X { };
  extern "C"   int g();
  extern "C++" int h();
}
namespace B {
  void X(int);
  extern "C"   int g();
  extern "C++" int h(int);
}
using namespace A;
using namespace B;

void f() {
  X(1);             // error: name X found in two namespaces
  g();              // OK: name g refers to the same entity
  h();              // OK: overload resolution selects A::h
}

, gcc clang . , .

"... ...".

n2 n1 , . . . $8.3.5.15 ( ):

- , . [: . - end ]

, n2 ...

namespace n1
{
    template <class T>
    void n2();

    template <class T>
    void n2(T);
}

namespace n2 /* line 12 */
{
    class c {};
}

using namespace n1;

namespace n3
{
    void foo(::n2::c);
}

void n3::foo(::n2::c) /* line 24 */
{

}
+2

All Articles