Gang Of Coders
Home
About Us
Contact Us
All Stl Solutions on Gang of Coders
Total of 263 Stl Solutions
What is the best way to use two keys with a std::map?
C++
Dictionary
Stl
Key
Stdmap
How to update an existing element of std::set?
C++
Stl
Set
std::string length() and size() member functions
C++
String
Stl
Size
How can currying be done in C++?
C++
Stl
Functional Programming
Currying
Binders
Is it safe to assume that STL vector storage is always contiguous?
C++
Stl
Vector
C++ Erase vector element by value rather than by position?
C++
Vector
Stl
Erase
Erase Remove-Idiom
How to sum up elements of a C++ vector?
C++
Stl
Vector
Why no emplacement iterators in C++11 or C++14?
C++
C++11
Stl
Iterator
C++14
Using std::map<K,V> where V has no usable default constructor
C++
Stl
Map
Compile Time
Sorting a vector of custom objects
C++
Stl
Sorting
How to retrieve all keys (or values) from a std::map and put them into a vector?
C++
Dictionary
Stl
Stdmap
How to remove constness of const_iterator?
C++
Stl
Iterator
Const Iterator
Extending the C++ Standard Library by inheritance?
C++
Stl
C++ How to find the biggest key in a std::map?
C++
Stl
Map
How can I sort an STL map by value?
C++
Algorithm
Sorting
Dictionary
Stl
std::vector, default construction, C++11 and breaking changes
C++
Stl
Vector
C++11
Backwards Compatibility
Determine if map contains a value for a key?
C++
Stl
Map
Pointers as keys in map C++ STL
C++
Pointers
Map
Stl
Relative performance of std::vector vs. std::list vs. std::slist?
C++
Data Structures
Stl
Performance
Linked List
Does vector::erase() on a vector of object pointers destroy the object itself?
C++
Stl
Vector
Can I initialize an STL vector with 10 of the same integer in an initializer list?
C++
Stl
Constructor
Initializer List
Why can't simple initialize (with braces) 2D std::array?
C++
Stl
C++11
Initialization
Can the 'type' of a lambda expression be expressed?
C++
Stl
Lambda
C++11
Is the std::set iteration order always ascending according to the C++ specification?
C++
Stl
Set
How to remove element not at top from priority_queue?
C++
Stl
Priority Queue
Binary Heap
Why does std::pair expose member variables?
C++
Stl
Encapsulation
STL vectors with uninitialized storage?
C++
Optimization
Stl
Vector
Cleaning up an STL list/vector of pointers
C++
List
Vector
Stl
What is the point of make_heap?
C++
Stl
Language Design
Why are C++ STL iostreams not "exception friendly"?
C++
Exception
Stl
Iostream
What is the difference between std::list<std::pair> and std::map in C++ STL?
C++
Stl
Stdmap
Std Pair
Stdlist
What does the standard library guarantee about self move assignment?
C++
Stl
C++11
Move Semantics
Is std::unique_ptr<T> required to know the full definition of T?
C++
Visual Studio-2010
C++11
Stl
Unique Ptr
Generic vector of vectors in C++
C++
Stl
initializing std::string from char* without copy
C++
String
Memory Management
Stl
Using local classes with STL algorithms
C++
Stl
Stl Algorithm
How can I make the map::find operation case insensitive?
C++
String
Dictionary
Stl
Case Insensitive
array vs vector vs list
C++
Arrays
List
Stl
Vector
Checking whether a vector is empty
C++
Stl
Vector
What are Containers/Adapters? C++
C++
Stl
Containers
Adapter
Reverse map lookup
C++
Stl
Map
Resizing a C++ std::vector<char> without initializing data
C++
Stl
Vector
Resize
C++ vector that *doesn't* initialize its members?
C++
Stl
Vector
Why vector access operators are not specified as noexcept?
C++
Exception
C++11
Stl
Noexcept
vector vs. list in STL
C++
List
Vector
Stl
Why use iterators instead of array indices?
C++
For Loop
Stl
Iterator
Containers
Why can I not push_back a unique_ptr into a vector?
C++
Stl
C++11
Smart Pointers
Unique Ptr
C++ sorting and keeping track of indexes
C++
Sorting
Stl
Indexing
Remove spaces from std::string in C++
C++
String
Stl
Whitespace
How to convert wstring into string?
C++
Unicode
Stl
Wstring
Is std::vector so much slower than plain arrays?
C++
Arrays
Performance
Stl
Vector
push_back vs emplace_back
C++
Visual Studio-2010
Stl
C++11
Move Semantics
C++ STL Vectors: Get iterator from index?
C++
Stl
Vector
Iterator
C++ equivalent of StringBuffer/StringBuilder?
C++
Stl
String Concatenation
How do I print the elements of a C++ vector in GDB?
C++
Debugging
Stl
Vector
Gdb
What really is a deque in STL?
C++
Stl
Deque
Why is it wrong to use std::auto_ptr<> with standard containers?
C++
Stl
Raii
Auto Ptr
C++ Faq
Why is the C++ STL is so heavily based on templates? (and not on *interfaces*)
C++
Oop
Templates
Stl
Thou shalt not inherit from std::vector
C++
Oop
Inheritance
Stl
Vector
What is the purpose of std::make_pair vs the constructor of std::pair?
C++
Stl
Std Pair
Why is std::map implemented as a red-black tree?
C++
Dictionary
Data Structures
Stl
Binary Search-Tree
Why use non-member begin and end functions in C++11?
C++
C++11
Stl
Iterator
Container Data-Type
Why are Standard iterator ranges [begin, end) instead of [begin, end]?
C++
Stl
Iterator
Standards
In STL maps, is it better to use map::insert than []?
C++
Dictionary
Stl
Insert
Stdmap
How to initialize std::vector from C-style array?
C++
Arrays
Vector
Stl
Is std::vector copying the objects with a push_back?
C++
Stl
Stdvector
In which scenario do I use a particular STL container?
C++
Stl
Container Data-Type
Throwing the fattest people off of an overloaded airplane.
C++
Algorithm
Sorting
Stl
C++ Double Address Operator? (&&)
C++
Stl
Operator Keyword
Memory Address
Concatenating two std::vectors
C++
Vector
Stl
Concatenation
Stdvector
How do I clear the std::queue efficiently?
C++
Data Structures
Stl
Queue
When vectors are allocated, do they use memory on the heap or the stack?
C++
Vector
Stl
Heap Memory
Stack Memory
STL or Qt containers?
C++
Qt
Stl
maximum value of int
C++
C
Stl
Limits
Numeric Limits
Why does std::list::reverse have O(n) complexity?
C++
C++11
Stl
Linked List
How do I reverse a C++ vector?
C++
Vector
Stl
Std
Advantages of std::for_each over for loop
C++
Stl
Foreach
Coding Style
Is the order of iterating through std::map known (and guaranteed by the standard)?
C++
Dictionary
Stl
Standards
Why is a C++ Vector called a Vector?
C++
Stl
Vector
What does iterator->second mean?
C++
Stl
Iterator
C++ valarray vs. vector
C++
Stl
Stdvector
C++ Standard-Library
Valarray
What are the complexity guarantees of the standard containers?
C++
Stl
Containers
Big O
Appending a vector to a vector
C++
Stl
Vector
How to get std::vector pointer to the raw data?
C++
Stl
Vector
How to check if std::map contains a key without doing insert?
C++
Stl
Map
What is the difference between const_iterator and non-const iterator in the C++ STL?
C++
Stl
Iterator
Constants
Is it more efficient to copy a vector by reserving and copying, or by creating and swapping?
C++
Algorithm
Vector
Stl
Should I store entire objects, or pointers to objects in containers?
C++
Stl
Pointers
Using custom std::set comparator
C++
Stl
Why doesn't std::queue::pop return value.?
C++
Stl
How do I remove an item from a stl vector with a certain value?
C++
Stl
How to set initial size of std::vector?
C++
Stl
Parsing a comma-delimited std::string
C++
String
Parsing
Stl
Csv
Iterate keys in a C++ map
C++
Stl
How do I specify a pointer to an overloaded function?
C++
Stl
What is the easiest way to initialize a std::vector with hardcoded elements?
C++
Vector
Stl
Initialization
What is the preferred/idiomatic way to insert into a map?
C++
Stl
Insert
Stdmap
Std Pair
How do I sort a vector of pairs based on the second element of the pair?
C++
Stl
Stdvector
what is the difference between const_iterator and iterator?
C++
Stl
Iterator
Const Iterator
How do I erase an element from std::vector<> by index?
C++
Stl
Vector
Erase
How do you copy the contents of an array to a std::vector in C++ without looping?
C++
Stl
Vector
Copy
What happens if you call erase() on a map element while iterating from begin to end?
C++
Stl
Iterator
remove_if equivalent for std::map
C++
Stl
Map
Writing your own STL Container
C++
Stl
C++ Standard-Library
Modern way to filter STL container?
C++
C++11
Stl
string c_str() vs. data()
C++
Stl
C Str
How to remove all the occurrences of a char in c++ string
C++
Stl
C++ map access discards qualifiers (const)
C++
Stl
Constants
Maps
How can I create Min stl priority_queue?
C++
Stl
Priority Queue
Why isn't vector<bool> a STL container?
C++
Vector
Stl
Containers
Bitvector
How to overload std::swap()
C++
Performance
Optimization
Stl
C++ Faq
Const map element access
C++
Dictionary
Stl
Constants
vector::at vs. vector::operator[]
C++
Stl
Stdvector
What's the difference between deque and list STL containers?
C++
List
Stl
Deque
How to reuse an ostringstream?
C++
Stl
Reset
Ostringstream
Where can I get a "useful" C++ binary search algorithm?
C++
Algorithm
Stl
Binary Search
How do I safely pass objects, especially STL objects, to and from a DLL?
C++
Windows
Dll
Stl
Abi
How to find if a given key exists in a C++ std::map
C++
Dictionary
Stl
std::back_inserter for a std::set?
C++
Algorithm
Stl
Erasing elements from a vector
C++
Vector
Stl
Erase
C++ convert vector<int> to vector<double>
C++
Stl
Vector
Type Conversion
What exception classes are in the standard C++ library
C++
Exception
C++11
Stl
Why is it OK to return a 'vector' from a function?
C++
Vector
Stl
Scope
Standard Library
Recommended way to insert elements into map
C++
Stl
Stdmap
Why is std::ssize() introduced in C++20?
C++
Stl
Unsigned
Signed
C++20
What's the difference between std::string and std::basic_string? And why are both needed?
C++
Stl
Why does std::set not have a "contains" member function?
C++
Stl
Stdset
how to append a list<T> object to another
C++
List
Stl
Initial capacity of vector in C++
C++
Memory Management
Stl
Vector
use std::fill to populate vector with increasing numbers
C++
Stl
Why does std::stack use std::deque by default?
C++
Stl
Containers
Which STL container should I use for a FIFO?
C++
Stl
Fifo
How can I create my own comparator for a map?
C++
Stl
Stdmap
How to get a certain element in a list, given the position?
C++
List
Stl
Initializing a static std::map<int, int> in C++
C++
Stl
Stdmap
std::map insert or std::map find?
C++
Optimization
Stl
Stdmap
Inspecting standard container (std::map) contents with gdb
C++
Stl
Map
Gdb
How to update std::map after using the find method?
C++
Map
Stl
Stdmap
Is gcc std::unordered_map implementation slow? If so - why?
C++
Stl
C++11
Hashmap
Concurrenthashmap
Alternative to vector<bool>
C++
Stl
Vector
Boolean
Why can't we declare a std::vector<AbstractClass>?
C++
Stl
Abstract Class
How to implode a vector of strings into a string (the elegant way)
C++
String
Stl
Stdstring
Implode
In std::multiset is there a function or algorithm to erase just one sample (unicate or duplicate) if an element is found
C++
Stl
Multiset
Iteration over std::vector: unsigned vs signed index variable
C++
Stl
Unsigned
Signed
What's the difference between "STL" and "C++ Standard Library"?
C++
Stl
Std
C++ Standard-Library
C++ Faq
How to choose between map and unordered_map?
C++
Dictionary
Data Structures
Stl
Unordered Map
Copy map values to vector in STL
C++
Stl
Containers
how to provide a swap function for my class?
C++
Stl
Swap
Why would I prefer using vector to deque
C++
Stl
Vector
Deque
std::string comparison (check whether string begins with another string)
C++
String
Stl
Compare
std::vector::resize() vs. std::vector::reserve()
C++
Stl
Vector
Is there a production ready lock-free queue or hash implementation in C++
C++
Stl
Lock Free
Why do I need std::get_temporary_buffer?
C++
Memory Management
Stl
Buffer
Temporary
What is the point of STL Character Traits?
C++
String
Stl
Stdstring
Char Traits
char* vs std::string in c++
C++
Stl
Stdstring
Arrays
What's the advantage of multimap over map of vectors?
C++
Stl
Map
Multimap
Why is the C++ initializer_list behavior for std::vector and std::array different?
C++
Stl
C++11
Can't include C++ headers like vector in Android NDK
Android
Stl
Vector
Android Ndk
Merge multiple sets elements in a single set
C++
Stl
Set
Is it okay to inherit implementation from STL containers, rather than delegate?
C++
Stl
What requirements must std::map key classes meet to be valid keys?
C++
Stl
Map
Key
c++ exception : throwing std::string
C++
Exception
Stl
How can I use std::maps with user-defined types as key?
C++
Dictionary
Stl
Containers
Stdmap
How can I merge two STL maps?
C++
Merge
Stl
Maps
Stdmap
How to check that an element is in a std::set?
C++
Stl
Set
Contains
Multidimensional std::array
C++
Stl
How to use the priority queue STL for objects?
C++
Stl
How to iterate through a list of objects in C++?
C++
For Loop
C++11
Stl
Iterator
How to increment an iterator by 2?
C++
Visual C++
Stl
Iterator
Why can't I make a vector of references?
C++
Vector
Reference
Stl
Container Data-Type
Why does the C++ STL not provide any "tree" containers?
C++
Data Structures
Tree
Stl
Does the range-based 'for' loop deprecate many simple algorithms?
C++
Algorithm
Stl
C++11
Foreach
C++11 std::set lambda comparison function
C++
Stl
C++11
Lambda
Std Function
UTF8 to/from wide char conversion in STL
C++
Unicode
Stl
Utf 8
Character Encoding
how-to initialize 'const std::vector<T>' like a c array
C++
Stl
Performance of qsort vs std::sort?
C++
Performance
Sorting
Stl
Copying std::vector: prefer assignment or std::copy?
C++
Stl
Copy
vector or map, which one to use?
C++
Performance
Stl
How to sort an STL vector?
C++
Sorting
Stl
What is the difference between std::set and std::vector?
C++
Stl
c++ STL set difference
C++
Stl
Set
Stdset
Set Difference
C++ std::set update is tedious: I can't change an element in place
C++
Stl
Set
Case insensitive std::string.find()
C++
String
Stl
Case Insensitive
Wstring
Initialize a vector array of strings
C++
Stl
Embedded C++ : to use STL or not?
C++
Stl
Embedded
What C++ pitfalls should I avoid?
C++
Stl
How to iterate over a priority_queue?
C++
Stl
Queue
rationale for std::lower_bound and std::upper_bound?
C++
Stl
Lower Bound
Upperbound
What happens if you increment an iterator that is equal to the end iterator of an STL container
C++
Stl
Vector
Iterator
How to avoid memory leaks when using a vector of pointers to dynamically allocated objects in C++?
C++
Stl
Pointers
Vector
Derived
What is an iterator's default value?
C++
Stl
Default
Containers
Iterator
Converting ostream into standard string
C++
Stl
Iostream
Why is the code in most STL implementations so convoluted?
C++
Stl
Readability
Why is value taking setter member functions not recommended in Herb Sutter's CppCon 2014 talk (Back to Basics: Modern C++ Style)?
C++
C++11
Stl
Looking for C++ STL-like vector class but using stack storage
C++
Data Structures
Stl
Vector
Checking if an iterator is valid
C++
Stl
Iterator
Dereference
C++11 std::to_string(double) - No trailing zeros
C++
Stl
C++11
Convert a vector<T> to initializer_list<T>
C++
C++11
Stl
Initializer List
When does Endianness become a factor?
C++
Networking
Stl
Endianness
What is the default hash function used in C++ std::unordered_map?
C++
C++11
Hash
Stl
Unordered Map
What is the difference between cbegin and begin for vector?
C++
Vector
Stl
Iterator
Google C++ style guide's No-exceptions rule; STL?
C++
Exception
Stl
Should I switch from using boost::shared_ptr to std::shared_ptr?
C++
Boost
Stl
C++11
Shared Ptr
Why do I get the same sequence for every run with std::random_device with mingw gcc4.8.1?
C++
C++11
Random
Stl
How does C++ STL unordered_map resolve collisions?
C++
Stl
Unordered Map
What's the benefit of std::back_inserter over std::inserter?
C++
Vector
Stl
Iterator
Containers
How to change a particular element of a C++ STL vector
C++
Stl
Vector
Constant-sized vector
C++
Stl
Vector
Are lambdas inlined like functions in C++?
C++
C++11
Lambda
Stl
How can I get the penultimate element in a list?
C++
Stl
Stdlist
How do I find the largest int in a std::set<int>?
C++
Stl
Stdset
C++ std::vector emplace vs insert
C++
Vector
Stl
Sorting a vector in descending order
C++
Sorting
Stl
Vector
Iterator
Iterator to last element in std::list
C++
Stl
Why should one not derive from c++ std string class?
C++
String
Inheritance
Stl
How to get a random element from a C++ container?
C++
Algorithm
Stl
C++ inserting unique_ptr in map
C++
Pointers
Map
Stl
Unique Ptr
Best way to extract a subvector from a vector?
C++
Stl
Vector
Range
Missing C++ header <__debug> after updating OSX Command Line Tools 6.3
C++
Xcode
Macos
Stl
Clang
I want to convert std::string into a const wchar_t *
C++
Stl
Wchar T
Stdstring
Is there a sorted_vector class, which supports insert() etc.?
C++
Stl
Vector
Sorting
Set
Removing item from vector while iterating?
C++
Stl
Iterator
One liner to convert from list<T> to vector<T>
C++
Stl
How can I use Standard Library (STL) classes in my dll interface or ABI?
C++
Dll
C++11
Stl
Std
Template Specialization VS Function Overloading
C++
Stl
Template Specialization
Standard Library
Overloading
std::transform() and toupper(), no matching function
C++
Algorithm
Stl
std::string::c_str() and temporaries
C++
Stl
Stdstring
Is list::size() really O(n)?
C++
List
Stl
Complexity Theory
Big O
std::endl is of unknown type when overloading operator<<
C++
Stl
Operator Overloading
Delete all items from a c++ std::vector
C++
Stl
Vector
Replace an element into a specific position of a vector
C++
Visual C++
Vector
Stl
Insert
Checking for existence in std::map - count vs find
C++
Dictionary
Stl
Stdmap
Why there is no std::copy_if algorithm?
C++
Algorithm
Stl
Using C++ vector::insert() to add to end of vector
C++
Stl
Vector
Iterator
Writing stringstream contents into ofstream
C++
Stl
Parameters
Stringstream
Ofstream
What's faster, iterating an STL vector with vector::iterator or with at()?
C++
Performance
Stl
Vector
Iterator
Converting between C++ std::vector and C array without copying
C++
C
Arrays
Stl
Stdvector
C++ priority_queue with lambda comparator error
C++
Stl
Lambda
C++11
Priority Queue
Why do std::string operations perform poorly?
C++
Python
Performance
node.js
Stl
What's the most efficient way to erase duplicates and sort a vector?
C++
Sorting
Vector
Stl
Duplicates
Is hash_map part of the STL?
C++
Stl
Hashmap
STL vector: Moving all elements of a vector
C++
Stl
Stdvector
std::map emplace without copying value
C++
C++11
Dictionary
Stl
Emplace
How do I sort a std::vector by the values of a different std::vector?
C++
Stl
Boost
Vector
Sorting
Convert iterator to pointer?
C++
Stl
Pointers
Vector
Iterator
Can I use const in vectors to allow adding elements, but not modifications to the already added?
C++
Stl
Constants
Is there a nice way to assign std::minmax(a, b) to std::tie(a, b)?
C++
Algorithm
Reference
Stl
C++17
What do I get from front() of empty std container?
C++
Stl
C++ STL map::erase a non-existing key
C++
Stl
Map
Key
Erase
Difference between erase and remove
C++
Stl
Reading a password from std::cin
C++
Stl
Password Protection
What is the right approach when using STL container for median calculation?
C++
Algorithm
Stl
Containers
Median
How to search for an element in an stl list?
C++
Stl
how portable is end iterator decrement?
C++
Stl
Iterator
Portability
Why use functors over functions?
C++
Stl
Functor
Why is "!=" used with iterators instead of "<"?
C++
Stl
Iterator
Comparison Operators
How to pretty-print STL containers in GDB?
C++
Linux
Debugging
Stl
Gdb
Comparing STL strings that use different allocators
C++
String
Memory Management
Stl
How to construct a std::string from a std::vector<string>?
C++
Stl
String Concatenation
Stringstream
Stdstring
how do you insert the value in a sorted vector?
C++
Sorting
Vector
Stl
Insertion Sort
What is the most efficient way to append one std::vector to the end of another?
C++
Performance
Stl
Vector
Use of for_each on map elements
C++
Algorithm
Stl
Stdmap
Std Pair
Concise explanation of reference collapsing rules requested: (1) A& & -> A& , (2) A& && -> A& , (3) A&& & -> A& , and (4) A&& && -> A&&
C++
Stl