【问题标题】:Why is there no boost::container::queue?为什么没有 boost::container::queue?
【发布时间】:2013-08-22 16:40:31
【问题描述】:

我开始使用 Boost,并且正在查看它拥有的几个库。

我注意到 boost::container 定义了几乎所有的标准容器,但不是 queue。

我没有找到任何关于它的参考;所以我想知道为什么只有deque。我想测试用 boost 容器替换 STL 容器,我被告知这是可能的......

提前感谢您对此主题的任何解释。

【问题讨论】:

  • 很多提升的东西都去std库,如果他们在那里使用std::whatever(似乎:在队列的情况下std更快)

标签: c++ boost queue


【解决方案1】:

std::queue 不是容器,而是包装器。它使用一个容器并提供一个非容器(简化)接口。

std::queue<T> 的 Boost 版本(实际上意味着 std::queue<T, std::deque<T> >,通过默认模板参数)是 std::queue<T, boost::container::deque<T> >。

【讨论】:

  • 仍然:没有提升队列,不过,提示适配器很好。但是,为什么 boost 没有那个适配器呢?
  • @Dieter:当规范需要适配器的特定实现时,无法提供更好/更好的适配器实现。正如我所展示的,这些改进来自使用不同的底层容器。你怎么说std::queue<T, boost::container::deque<T> >“不是一个Boost队列”?
  • @Ben Voigt 除了 boost::lockfree::queue 之外没有 boost:::queue (这是另一回事)。 std::whatever_template<:whatever> 不是提升,虽然
  • @Dieter:我从来没有说过boost::queue。我说相当于std::queue&lt;T, std::deque&lt;T&gt; &gt; 的Boost 是std::queue&lt;T, boost::containers::dequeue&lt;T&gt; &gt;。你不同意吗?说 std::queue&lt;T, boost::containers::dequeue&lt;T&gt; &gt; 不是 Boost 就像说 boost::containers::dequeue&lt;std::string&gt; 不是 Boost。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-30
  • 2011-01-21
  • 1970-01-01
  • 1970-01-01
  • 2019-06-14
  • 2011-03-10
  • 2014-07-01
相关资源
最近更新 更多