继承显式构造函数 (Intel C++)
Inheriting an explicit constructor (Intel C++)
英特尔 C++ 编译器(版本 16.0.3.207 Build 20160415)似乎在基 class 的构造函数被 [=13= 继承时删除 explicit 说明符]使用。这是一个错误吗?
struct B
{
explicit B(int) { }
};
struct D : B
{
using B::B;
};
B b = 1; // Not OK, fine
D d = 1; // Not OK with Microsoft C++ and GCC, but OK with Intel C++
我认为标准中的适当措辞如下 (n4296, 12.9 Inheriting constructors):
...
The constructor characteristics of a constructor or constructor template are
(2.1) — the template parameter list (14.1), if any,
(2.2) — the parameter-type-list (8.3.5), and
(2.3) — absence or presence of explicit (12.3.1).
For each non-template constructor in the candidate set of inherited
constructors other than a constructor having no parameters or a
copy/move constructor having a single parameter, a constructor is
implicitly declared with the same constructor characteristics
unless there is a user-declared constructor with the same signature in
the complete class where the using-declaration appears or the
constructor would be a default, copy, or move constructor for that
class.
...
所以很可能是英特尔 C++ 编译器中的错误。
英特尔 C++ 编译器(版本 16.0.3.207 Build 20160415)似乎在基 class 的构造函数被 [=13= 继承时删除 explicit 说明符]使用。这是一个错误吗?
struct B
{
explicit B(int) { }
};
struct D : B
{
using B::B;
};
B b = 1; // Not OK, fine
D d = 1; // Not OK with Microsoft C++ and GCC, but OK with Intel C++
我认为标准中的适当措辞如下 (n4296, 12.9 Inheriting constructors):
...
The constructor characteristics of a constructor or constructor template are
(2.1) — the template parameter list (14.1), if any,
(2.2) — the parameter-type-list (8.3.5), and
(2.3) — absence or presence of explicit (12.3.1).
For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the complete class where the using-declaration appears or the constructor would be a default, copy, or move constructor for that class.
...
所以很可能是英特尔 C++ 编译器中的错误。