【发布时间】:2020-07-23 08:35:44
【问题描述】:
我通过参考以下信息来学习 C++ 序列容器 - https://en.cppreference.com/w/cpp/container [Member function table - functions present in C++03 ,- functions present since C++11, - functions present since C++17, - functions present since C++20]
可在页面末尾找到。
我无法理解为什么所有序列容器至少支持所有基本方法,例如:
forward_list does not supports size()
vectors does not support emplace_front()
arrays does not support capacity()
deque does not supports reserve()
list does not supports emplace_hint()
同样还有其他所有可用的功能?基本上是什么特性或功能决定了哪种方法可用于一个容器而不是其他容器?
【问题讨论】:
-
emplace_hint会在列表中做什么? -
我不清楚这个问题,因为您似乎暗示“不支持”是可能的。我认为他们不是,其中一些“显然”。因此,请添加有关您为什么/如何认为它们可以为相关容器实施的信息。或者您是否在询问它们无法实施的原因?那么你应该在问题中澄清这一点。
-
"Container" 在这个上下文中只是一个描述包含某些东西的结构的词。没有“容器”接口。每个结构都有自己的方法。