Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between std::deque and boost::deque?

Tags:

c++

boost

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?

like image 806
Afiefh Avatar asked Oct 19 '22 18:10

Afiefh


1 Answers

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;
};
like image 93
juanchopanza Avatar answered Nov 15 '22 10:11

juanchopanza