Top "Stl" questions

The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects.

push_back vs emplace_back

I'm a bit confused regarding the difference between push_back and emplace_back. void emplace_back(Type&& _Val); …

c++ visual-studio-2010 stl c++11 move-semantics
What's the most efficient way to erase duplicates and sort a vector?

I need to take a C++ vector with potentially a lot of elements, erase duplicates, and sort it. I currently …

c++ sorting vector stl duplicates
How to retrieve all keys (or values) from a std::map and put them into a vector?

This is one of the possible ways I come out: struct RetrieveKey { template <typename T> typename T::first_…

c++ dictionary stl stdmap
Is it more efficient to copy a vector by reserving and copying, or by creating and swapping?

I am trying to efficiently make a copy of a vector. I see two possible approaches: std::vector<int&…

c++ algorithm vector stl
Best way to extract a subvector from a vector?

Suppose I have a std::vector (let's call it myVec) of size N. What's the simplest way to construct a …

c++ stl vector range
C++ Erase vector element by value rather than by position?

vector<int> myVector; and lets say the values in the vector are this (in this order): 5 9 2 8 0 7 If I …

c++ vector stl erase erase-remove-idiom
How to sum up elements of a C++ vector?

What are the good ways of finding the sum of all the elements in a std::vector? Suppose I have …

c++ stl vector
How to check that an element is in a std::set?

How do you check that an element is in a set? Is there a simpler equivalent of the following code: …

c++ stl set contains
Parsing a comma-delimited std::string

If I have a std::string containing a comma-separated list of numbers, what's the simplest way to parse out the …

c++ string parsing stl csv
vector vs. list in STL

I noticed in Effective STL that vector is the type of sequence that should be used by default. What's does …

c++ list vector stl