是C ++ 11标准容器“final”吗? [英] Are C++11 standard containers "final"?

查看:104
本文介绍了是C ++ 11标准容器“final”吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们(应该)知道C ++标准库容器,包括std :: string,不是意味着继承。

We (should) know that C++ standard library containers, including std::string, are not meant to be inherited from. But still, C++98/03 did allow us to do it even if it was leading to bugs.

现在, final

Now that the final keyword is available, are those standard library container marked final to prevent bad use of inheritance with them?

如果没有,为什么?

推荐答案

LWG最近在Kona 2月6日的会议上讨论了这个问题, 10,2012.这是LWG 问题2113

The LWG discussed this issue at the recent meeting in Kona Feb. 6-10, 2012. This is LWG issue 2113.

LWG决定将LWG 2113标记为NAD(不是缺陷),理由是该标准已经清楚了现有的类如容器和 std ::

The LWG decided to mark LWG 2113 as NAD (not a defect), with the rationale that the standard is already clear that existing classes such as containers and std::string can not be marked final by the implementation.

讨论包括这样一个事实,虽然它可能被皱眉的从这样的类派生,在C ++ 98/03中这样做是显而易见的。

The discussion included the fact that while it may be frowned on to derive from such classes, it is clearly legal to do so in C++98/03. And making it illegal in C++11 would break far too much code.

更新

目前,在当前工作草案标记为 final

这篇关于是C ++ 11标准容器“final”吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆