VC15中属性的使用
Usage of attributes in VC15
根据本文http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf class 和方法属性应声明如下
struct B {
virtual void f [[ final ]] () {};
};
此示例来自第 11.3 段。但是编译这段代码给了我一个警告
warning C5030: attribute 'final' is not recognized
但是如果我写
struct B {
virtual void f () final {};
};
编译在没有警告的情况下进行,一切正常。
我正在使用 visual studio 15 和工具集 v140。
我的问题是,我是不是没有正确使用标准的第一种形式,还是 VC15 在此功能中被破坏了?
'final' 用法的第二个示例是视觉特定的还是它也适用于 gcc?
是旧文档,final
是the virt-specifier
,第二个代码是正确的。
N4296 10.3/4
If a virtual function f in some class B is marked with the
virt-specifier final and in a class D derived from B a function D::f
overrides B::f, the program is ill-formed.
struct B {
virtual void f() const final;
};
struct D : B {
void f() const; // error: D::f attempts to override final B::f
};
根据本文http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf class 和方法属性应声明如下
struct B {
virtual void f [[ final ]] () {};
};
此示例来自第 11.3 段。但是编译这段代码给了我一个警告
warning C5030: attribute 'final' is not recognized
但是如果我写
struct B {
virtual void f () final {};
};
编译在没有警告的情况下进行,一切正常。
我正在使用 visual studio 15 和工具集 v140。
我的问题是,我是不是没有正确使用标准的第一种形式,还是 VC15 在此功能中被破坏了?
'final' 用法的第二个示例是视觉特定的还是它也适用于 gcc?
是旧文档,final
是the virt-specifier
,第二个代码是正确的。
N4296 10.3/4
If a virtual function f in some class B is marked with the virt-specifier final and in a class D derived from B a function D::f overrides B::f, the program is ill-formed.
struct B {
virtual void f() const final;
};
struct D : B {
void f() const; // error: D::f attempts to override final B::f
};