相关疑难解决方法(0)

类声明类头中的全局限定

我们发现类似于以下内容(不要问......):

namespace N {
    struct A { struct B; };
}

struct A { struct B; };

using namespace N;

struct ::A::B {}; // <- point of interest
Run Code Online (Sandbox Code Playgroud)

有趣的是,这与VS2005,icc 11.1和Comeau(在线)编译良好,但与GCC失败:

在'{'标记之前,类名的全局限定无效

从C++ 03,附件A,在我看来,像GCC是对的:

  • class-head可以由nested-name-specifieridentifier
  • nested-name-specifier不能以全球资格开始(::)
  • 显然,两者都不能 identifier

......还是我忽略了什么?

c++ standards class declaration

3
推荐指数
1
解决办法
915
查看次数

标签 统计

c++ ×1

class ×1

declaration ×1

standards ×1