Top "Stl" questions

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

How to initialize std::vector from C-style array?

What is the cheapest way to initialize a std::vector from a C-style array? Example: In the following class, I …

c++ arrays vector stl
Erasing elements from a vector

I want to clear a element from a vector using the erase method. But the problem here is that the …

c++ vector stl erase
Why is it OK to return a 'vector' from a function?

Please consider this code. I have seen this type of code several times. words is a local vector. How is …

c++ vector stl scope standard-library
C++ sorting and keeping track of indexes

Using C++, and hopefully the standard library, I want to sort a sequence of samples in ascending order, but I …

c++ sorting stl indexing
How can I create my own comparator for a map?

typedef map<string, string> myMap; When inserting a new pair to myMap, it will use the key string …

c++ stl stdmap
What are the complexity guarantees of the standard containers?

Apparently ;-) the standard containers provide some form of guarantees. What type of guarantees and what exactly are the differences …

c++ stl containers big-o
How can I create Min stl priority_queue?

The default stl priority queue is a Max one (Top function returns the largest element). Say, for simplicity, that it …

c++ stl priority-queue
How do I print the elements of a C++ vector in GDB?

I want to examine the contents of a std::vector in GDB, how do I do it? Let's say it's …

c++ debugging stl vector gdb
What is the preferred/idiomatic way to insert into a map?

I have identified four different ways of inserting elements into a std::map: std::map<int, int> function; …

c++ stl insert stdmap std-pair
what is the difference between const_iterator and iterator?

What is difference between these two regarding implementation inside STL. what is the difference regarding performance? I guess when we …

c++ stl iterator const-iterator