Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [stl]

Do NOT use for questions about 3D CAD model. Use [stl-format] instead. The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects. Use in conjunction with [c++]. When C++ was standardised, large parts of the STL were adopted into the Standard Library, and these parts in the Standard Library are also sometimes erroneously referred to collectively as "the STL".

stl
2 votes
0 answers
58 views

How to deal with a third party DLL exporting STL symbols?

I am working on a project that is dependent on a third-party DLL. For reasons unknown, this DLL exports (most but not all) of the symbols for std::vector<unsigned char>: $ dumpbin.exe -exports ...
Parker Coates's user avatar
4 votes
0 answers
67 views

What exception guarantee level does std::vector::operator=() have? [duplicate]

When I assign one std::vector to another std::vector, and std::bad_alloc raises internally, does the C++ specification guarantee that my vector will be left in the correct state? Does it have a basic ...
Andreev Gregory's user avatar
-3 votes
1 answer
98 views

Getting error when trying to overload << operator in C++ [closed]

I am trying to print a vector for logging purposes in C++. I have made a function but it's throwing an error. Can anyone please help me explain why and suggest a possible fix. Here's the code snippet #...
Ved Timbadiya's user avatar
0 votes
1 answer
62 views

Allowing STL algorithms to swap when iterators dereference to a wrapper class (i.e. an rvalue)

I am implementing a C++ wrapper for a C library that has a "vector of vectors" container. In the C++ interface, I would like iterators to dereference not to a raw C pointer, but to a ...
Szabolcs's user avatar
  • 25.4k
0 votes
0 answers
81 views

C++ Rule of Zero with guaranteed/C ABI

I love and often use C++ Rule of Zero, but now there's a use case where I find it challenging to use. I have 2 libraries, both maintained separately and even compiled with different compilers to ...
Paul's user avatar
  • 6,589
2 votes
2 answers
80 views

Unclear behaviour of std::next_permutation with std::wstring

Given this program to play around with Unicode, I found results that don't make sense to me: #include <iostream> #include <algorithm> #include <cassert> int main() { std::locale:...
user26340612's user avatar
-2 votes
0 answers
46 views

Replacing direct usage of std::_Dist_type from old msvc100 code for msvc142

I'm working on upgrading some old c++ code from msvc100 to msvc142. My problem is I am not a C++ developer, but come from C#, and I'm running into a problem with a specific type that was used directly ...
Capsup's user avatar
  • 83
0 votes
1 answer
83 views

reference_wrapper in c++ containers

Consider following snippet: #include <bits/stdc++.h> using namespace std; int main() { int x=3; int y=1; int z=2; cout<<(&x)<<' '<<(&y)<<' '<&...
Rupa's user avatar
  • 110
1 vote
1 answer
71 views

Using an initializer list to init a vector

I can not figure out why it does not allow me to directly initialize a vector using the following syntax: stl::vector<int> v{1, 2, 3}; I have implemented from scratch both the vector and the ...
Sorin Tudose's user avatar
0 votes
0 answers
57 views

set c++ own comparator function find could not find an already inserted element [duplicate]

I wrote an comparator function for my set which will store an vector of 3 elememts. Those 3 elements will be sorted always. Now i insert the 2 elements in the set. But when i try to find the 2nd ...
lotus airtel300's user avatar
0 votes
1 answer
92 views

Memory error when running multiset.erase(std::prev(multiset.end()));

#include <iostream> #include <set> #include <iterator> using std::cout, std::endl; using std::multiset; int main() { multiset<int> m; m.insert(1); m.insert(2); ...
Couchcap's user avatar
-2 votes
1 answer
67 views

is it mandatory to specify size of the vector when we using vector of vector? [duplicate]

vector<vector<int>>res(size); I was working on some problem when I run the code with size its gave correct result but without size it throws seg-fault vector<vector<int>> ...
ullas G's user avatar
2 votes
0 answers
95 views

Efficient nested parallelism

I am transitioning to parallel STL from my own thread pool. One thing in need is efficient nested parallelism. Consider the following code std::for_each(std::execution::par_unseq, begin, end, f(i)); ...
user2961927's user avatar
  • 1,654
0 votes
0 answers
191 views

Why does each Block in the MSVC implementation of std::deque have only 16 bytes? Can I modify it?

I learned this fact after reading Inside STL: The deque, implementation, and I am very shocked by it. 16 bytes!? That’s only twice the size of a pointer! I know that the major implementations of the ...
許恩嘉's user avatar
3 votes
2 answers
103 views

How to inplace initialize std::array<std::pair<const Key, Val>>?

I am trying to create a static map for where the type of the key is an enum, and the values and keys are stored inside an std::array. The below code works nicely for trivially copiable types, but ...
valikund's user avatar

15 30 50 per page
1
2 3 4 5
1032