vector::max_size 的实际使用 [英] Practical use of vector::max_size

查看:32
本文介绍了vector::max_size 的实际使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题 让我想到了 vector 类中的 max_size 方法.很明显,实际上向量中包含的元素数量将远小于 max_size 返回的数量.所以我想知道这将在哪里有用?有什么线索吗?

This question got me thinking about the max_size method in vector class. It is quite apparent that practically the number of elements contained in the vector will be much lesser than what max_size returns. So I was wondering where this will be useful? Any clues?

推荐答案

这真的不是很有用.

唯一的理论用法是检查是否需要一个大于 max_size() 的容器,您有麻烦了.但在考虑将数据库服务器端口连接到微波炉时,您可能已经意识到这一点.

The only theoretical usage would be to check that if you need a container larger than max_size(), you are in trouble. But you would probably realize that already when considering a port of your database server to a microwave oven.

委员会曾经考虑过改进该功能,但认为它的用处不足以值得进行更改:

The committee once considered improving the function, but didn't find it useful enough to be worth a change:

max_size() 对很多事情都没有用处,现有的措辞对于 max_size() 可以用于的少数情况来说已经足够清楚了.任何改变现有措辞的尝试都没有改善.

max_size() isn't useful for very many things, and the existing wording is sufficiently clear for the few cases that max_size() can be used for. None of the attempts to change the existing wording were an improvement.

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#197

这篇关于vector::max_size 的实际使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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