Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:52:21+00:00 2026-06-15T14:52:21+00:00

Possible Duplicate: Why would I prefer using vector to deque I am curious why

  • 0

Possible Duplicate:
Why would I prefer using vector to deque

I am curious why is it that std::vector is so much more popular than std::deque. Deque is almost as efficient in lookup, more efficient in insert (without vector::reserve)and allows for inserting/deleting in the front.

Herb Sutter once recommended that if you want to use vector, just prefer deque (I am paraphrasing). However in a recent talk on Writing Modern C++ he again strongly recommends thinking of std::vector as a default container. According to the GOTW I linked earlier, even the standard has similar wording.

Is there a reason for this disparity? Is it just that vector is simpler and more well known, or is there a technical reason? Or is it that vector is just a cooler name .. ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:52:22+00:00Added an answer on June 15, 2026 at 2:52 pm

    I can’t speak for anybody else, but I can for myself.

    When I first read about std::deque, I thought it was cool enough that for a while, I treated it not only as the default container, but as nearly the only container I used.

    Then somebody asked about why, and I expounded at length on its virtues and why it was the best container to use for practically everything, and how it was much more versatile than std::vector.

    Fortunately, the guy questioning my decision on it was persuasive enough that I did some testing. Testing showed that in nearly every case, std::deque was slower than std::vector — often by a substantial factor (e.g., around 2). In fact, of the code I’d written using std::deque, just replacing std::deque with std::vector gave a speedup in all but a handful of cases.

    I have used std::deque in a few cases since then, but definitely don’t treat it as the default any more. The simple fact is that in the usual implementation it’s noticeably slower than std::vector for most purposes.

    I should add, however, that I’m reasonably certain that with the right implementation, it could be nearly equivalent to std::vector in virtually all cases. Most use a representation that’s undoubtedly great from an asymptotic viewpoint, but doesn’t work out quite so wonderfully (for many purposes) in the real world.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What WPF books would you recommend? GUI's written using WPF seem to
Possible Duplicate: Do you prefer explicit namespaces or 'using' in C++? I am a
Possible Duplicate: Draw Circle using css alone I would like to know if there
Possible Duplicate: How would you count occurences of a string within a string (C#)?
Possible Duplicate: Set Locale programatically I would like to create an english/spanish option choice
Possible Duplicate: Create event handler for OnScroll for web browser control I would like
Possible Duplicate: JavaScript library to create div-style window within page I would like to
Possible Duplicate: When to Use Static Classes in C# Questions in the title..........i would
Possible Duplicate: passing in object by ref With the code below, the output would
Possible Duplicate: Maximum length of the textual representation of an IPv6 address? What would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.