c++ 11在类的完整作用域中命名重求值
C++11 name re-evaluation in completed scope of a class?
在c++ 3.3.7.2中说[basic.scope.class]
在类
S
中使用的名称N
应在其上下文中以及在S
的完整范围内重新计算时引用相同的声明。
在类S
中使用的名称N
在其上下文中引用的声明与在S
的完整作用域中重新求值时引用的声明不同的翻译单元的例子是什么?
struct X {};
struct Y {};
typedef X N;
struct S
{
N n;
typedef Y N;
};
$ g++ test.cpp
9:15: error: declaration of ‘typedef struct Y S::N’ [-fpermissive]
4:11: error: changes meaning of ‘N’ from ‘typedef struct X N’ [-fpermissive]
相关文章:
- 未在作用域中声明unordered_map
- 有没有一种方法可以在编译时获得作用域类名
- C++quit()函数中可能存在作用域问题
- 未在此作用域OpenCV3.4中声明cvSaveImage
- 全局作用域中函数指针的赋值
- 在类函数中初始化外部作用域变量
- 不同作用域中的静态变量和全局变量
- 是同一作用域的函数部分中的函数调用
- 未在此作用域中声明的函数和变量 (C++)
- 类作用域的类型别名"using":[何时]方法中的用法可以先于类型别名?
- 将作用域枚举转换为基础类型
- 表达式必须具有完整或无作用域的枚举图
- 在构造函数中输入对象时C++类成员作用域
- 无法让"std::enable_if"适用于无作用域枚举
- 为什么不能直接引用作用域枚举类成员,而不能为无作用域枚举生成类成员?
- 函数未在作用域中声明 / 如何结合使用 header.h、header.cpp 和 main.cpp?
- 错误:表达式必须具有算术、无作用域枚举或带有运算符重载的指针类型
- 如何在C++中访问作用域的变量输出?
- 重载时未在 C++ 的作用域错误中声明
- 作用域枚举和标准::get