stl引用C ++ 11的容器 [英] stl container of references C++11

查看:114
本文介绍了stl引用C ++ 11的容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题被问了一百万遍。大多数答案只是说该对象应该是CopyAssignable和CopyConstructible。但是文档明确指出,这是规则(直到C ++ 11 )!但是,它仍然行不通。为什么?

I know this question was asked a million of times. And most of answers just says that object should be CopyAssignable and CopyConstructible. But documentation clearly says this is the rule (until C++11)! But still it doesn't work. Why?

推荐答案

是的,现在的要求不再那么严格了。但是,在您要引用的部分的正下方,链接的文档明确指出

Yes, the requirements are less strict now. However, right below the part you're referencing, the linked documentation clearly states that:


对元素的强加取决于在容器上执行的实际操作。通常,要求元素类型是完整类型并满足Erasable的要求,但是许多成员函数提出了更严格的要求。 (自C ++ 11起)

引用不符合Erasable的要求,因此它们仍然无法工作。

References don't meet the requirements of Erasable, therefore they still can't work.

这篇关于stl引用C ++ 11的容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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