I understand that both deque and vector reserve some space for growth. vector::capacity() is able to get the internal reserved space for a vector. Deque doesn't have such a member in the standard. Is there some way to get this information?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
You'd have to dig into the implementation to figure that out. The version of
std::deque
that comes with gcc 4.1.1 appears to allocate memory in 512 byte chunks. But that's as far as I got after 15 minutes of staring at all the underscores and C-style casts tosize_t
. And then I came across this comment:Not portably. The reason there's no
capacity
member for deque is because it does not use contiguous memory. There's no reason, performance-wise, to consider it.