MyStruct
那叫
Foo<int>
关于建筑:
struct MyStruct {
MyStruct() {
Foo<int>();
}
template<typename T>
void Foo() {
[]() {
struct Base {
Base(int n) {}
};
struct Derived : Base {
// using Base=Base; // needs to be uncommented for Apple LLVM version 9.1.0 (clang-902.0.39.2)
Derived() :
Base(0) // problematic line
{}
} derived;
};
}
};
我试着用叮当声(通过
godbolt
,命令行参数
--std=c++1y
):
-
3.6:
error: type 'Base' is not a direct or virtual base of 'Derived'
(见
problematic line
(在上面的代码中)
-
3.7及更新版本:编译(带有未使用表达式的警告)
according to this
,使用Clang4.0(
clang --version
给予
Apple LLVM version 9.1.0 (clang-902.0.39.2)
)),我从clang 3.6发布的同一行中得到一个错误:
error: member initializer 'Base' does not name a non-static data member or base class
作为解决办法,我试着介绍
using Base=Base
在内部
struct Derived
下面是我的问题:
-
这是一个编译器错误吗?如果是:是否有文件记录?
-
有效的,定义良好的C++?