5

std::deque is rather well documented in CppReference, but boost::deque's documentation seems to be equivalent to that of the standard, with the addition of a few methods such as nth and index_of.

Are there other differences between the two classes that I am missing?

2
  • 4
    [ Boost.Container library implements several well-known containers, including STL containers. The aim of the library is to offers advanced features not present in standard containers or to offer the latest standard draft features for compilers that don't comply with the latest C++ standard.](boost.org/doc/libs/1_60_0/doc/html/…)
    – BoBTFish
    Commented Jan 10, 2016 at 9:57
  • 2
    ... for example, boost deque can be used recursively; whereas using std::deque recursively is undefined; boost::deque offers full move semantics; including an emulation mode for c++03 compilers; but std::deque only supports move semantics in c++11 and higher. boost::deque supports polymorphic allocators, which are a proposal that may or may not be in C++17, etc.boost.org/doc/libs/1_60_0/doc/html/container/…
    – Mankarse
    Commented Jan 10, 2016 at 10:01

1 Answer 1

3

Yes, there are other differences. For example, boost::deque can be instantiated with incomplete types. So you can have this:

struct foo
{
  boost::deque<foo> foos;
};

whereas the following causes undefined behaviour (although it may work well on certain implementations.)

struct foo
{
  std::deque<foo> foos;
};
1
  • Are you sure that it is UB? Unspecified Behavior would make more sense to me.
    – Vincent
    Commented Jan 10, 2016 at 15:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.