什么时候在构造函数的类定义中通过普通查找找不到 mem-initializer-id?
When is it the case that a mem-initializer-id is not found by ordinary lookup in the constructor's class definition?
给定这个片段
class Base
{
public:
Base(){};
};
class Derived : public Base
{
public:
Derived();
};
Derived::Derived() :Base() {}
并考虑到§12.6.2/2(我的重点)中的这一声明
在mem初始值设定项id中,会查找一个初始的非限定标识符在构造函数类的范围内,如果在scope,在包含构造函数释义
我认为在Derived
构造函数的定义中查找名称Base
是在Derived
类定义中找到的。
我只是想知道,除了12.6.2/3中给出的例子之外,是否还有其他更具体的例子,其中在构造函数的类中找不到mem初始值设定项id。
mem初始值设定项id必须命名构造函数的类,该类是构造函数的类,或者该类的直接或虚拟基。如果它是一个实际的类名(无论是派生类还是基类),它将在类的作用域内被发现为注入的类名。如果它是一个数据成员,那么名称查找显然会在类的范围内找到它。这就留下了一个typedef,但这也是12.6.2/3:中给出的例子
class Base { };
class Derived : public Base
{
public:
Derived();
};
using BaseAlias = Base;
Derived::Derived() : BaseAlias() {}
我只是想知道,除了12.6.2/3中给出的例子之外,是否还有其他更具体的例子,其中在构造函数的类中找不到mem初始值设定项id
一个比使用简单别名typedef
/using
作为§12.6.2/p3:基类的例子更实用的例子
#include <type_traits>
struct Base {};
struct Base2 {};
struct Derived : Base, Base2
{
Derived();
};
using namespace std;
Derived::Derived() : conditional_t<true, Base, Base2>{} {}
// ~~~~~~~~~~~~^
相关文章:
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 为什么野牛仍在使用"int yylex(void)",却找不到"int yylex(YYS
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 奇怪的(对我来说)返回声明 - 在谷歌上找不到任何关于它的信息
- 找不到QtResource文件中的文件
- VC++本机单元测试,找不到调试符号
- RegGetValue在当前用户下找不到名称
- 带有 -stdlib=libc++ 的 clang++ 9.0.1 找不到<optional>
- c++找不到具有相同哈希的无序集合元素
- 找不到以下加速库:boost_fiber
- 查找窗口找不到进程
- 字符串查找方法找不到第一字母
- cmake 找不到提升库,因为它查找了错误的文件名
- Linux 查找 glxext.h 函数的对象 -> 找不到正确的 .so -> "undefined reference"
- 编译C++mac,查找找不到的头文件
- 什么时候在构造函数的类定义中通过普通查找找不到 mem-initializer-id?
- 找不到标识符,即使使用依赖于参数的查找和运算符<<也不明确
- C++ 映射查找找不到特定键
- 设置::查找() 找不到