2
class foo
{
public:
    static void bar();
};

int main()
{
    foo::foo::foo::foo::bar();
}

I am curious as to which part of the C++ Standard allows this code to work. It builds on GCC, Clang and MSVC.

Why would the foo symbol still be accessible if foo:: is no longer at the global scope?

To contrast, the same does not apply to namespaces:

namespace foo
{
    void bar();
};

int main()
{
    foo::foo::foo::foo::bar(); // compiler error
}
seaplusplus
  • 153
  • 3

0 Answers0