std::deque
是相當有據可查CppReference,但boost::deque
的documentation似乎等同於標準的,增加的一些方法,如nth
和index_of
。std :: deque和boost:deque有什麼區別?
我缺少兩個類別之間還有其他區別嗎?
std::deque
是相當有據可查CppReference,但boost::deque
的documentation似乎等同於標準的,增加的一些方法,如nth
和index_of
。std :: deque和boost:deque有什麼區別?
我缺少兩個類別之間還有其他區別嗎?
是的,還有其他的區別。例如,boost::deque
可以用不完整的類型實例化。所以,你可以有這樣的:
struct foo
{
boost::deque<foo> foos;
};
而以下原因未定義行爲(儘管它可能在某些實現正常工作)
struct foo
{
std::deque<foo> foos;
};
你確定它是UB嗎?未說明的行爲對我來說會更有意義。 – Vincent
@Vincent是的,當然。 – juanchopanza
[Boost.Container庫實現了幾個知名的容器, *包括STL容器*。該庫的目標是提供*標準容器中沒有的高級功能*或爲不符合最新C++標準的編譯器提供*最新標準草案功能。](http://www.boost。 org/doc/libs/1_60_0/doc/html/container.html#container.intro) – BoBTFish
...例如,boost deque可以遞歸使用;而遞歸使用std :: deque是未定義的; boost :: deque提供了完整的移動語義;包括C++ 03編譯器的仿真模式;但std :: deque只支持C++ 11和更高版本中的移動語義。 boost :: deque支持多態分配器,這是一種可能或不可能在C++ 17中提出的提議,等等.http://www.boost.org/doc/libs/1_60_0/doc/html/container/history_and_reasons。 html#container.history_and_reasons.Why_boost_container – Mankarse