Questions tagged [stl]
About the "Standard Template Library", which inspired the major parts C++ Standard Library
28 questions
3
votes
3
answers
5k
views
High level overview of how printf() works with Windows OS
I asked this question on an IRC channel, sadly I am going around in circles.
I am aiming for a high level overview (but with some technical details if necessary) on how a function such as printf() ...
25
votes
7
answers
12k
views
Should the STL be avoided in large applications?
This might sound as a weird question, but in my department we are having trouble with following situation:
We are working here on a server application, which is growing larger and larger, even at the ...
11
votes
5
answers
2k
views
How to design exceptions
I'm struggling with a very simple question:
I'm now working on a server application, and I need to invent a hierarchy for the exceptions (some exceptions already exist, but a general framework is ...
2
votes
4
answers
1k
views
C++: STL or custom code for data structures?
General question regarding the STL. Do you guys think that the STL should be used for data structures or would you create custom code? In what scenario would you implement your own code for something ...
3
votes
1
answer
2k
views
When was STL formally introduced into C++ standard?
I fail to infer the exact point of historical introduction of STL into actual C++ standard library from the wikipedia article: https://en.wikipedia.org/wiki/Standard_Template_Library
It appears to me ...
5
votes
2
answers
2k
views
Differences between streams and iterators in C++?
I'm working on code which will provide a generic C++ interface to relational datasets. Some of the data will be in tables in memory (e.g. std::set or std::vector), but some of it will be computed - ...
32
votes
3
answers
22k
views
What difference is there between using a struct and a std::pair?
I am a C++ programmer with limited experience.
Supposing I want to use an STL map to store and manipulate some data, I would like to know if there is any meaningful difference (also in performance) ...
0
votes
2
answers
3k
views
Should the getters and setters of a stl container access the container itself or the elements inside it?
Consider I have a vector and map as class members:
class MyClass{
protected:
std::vector<int> myVector;
std::map<int,std::string> myMap;
};
Should the getter and setter access the ...
18
votes
1
answer
3k
views
How did std::vector<bool> come about?
Today, virtually all C++ developers agree that std::vector<bool> was a mistake since it is deceivingly not a container, and its use cases largely overlap with those of std::bitset anyway.
How ...
2
votes
2
answers
253
views
C++ object references vs. lookup
Let's assume there are 2 classes: Country and City. Both of them have names, so a map would suit as conainer
map<std::string, Country> countries;
In the country class there is a similar map ...
3
votes
3
answers
3k
views
Is there any merit for using beginning iterator instead of reference to a std::vector?
I'm working on our company's lib. I see a lot of code like:
std::vector<int>::iterator it = market.vec.begin();
for (size_t i = 0; i < market.vec.size(); ++i)
it[i] = i + 1;
I think a ...
-2
votes
3
answers
834
views
Link to ISO doc? Complexity of unordered_map operations in C++::stl [closed]
In different forums, I have found the statement that in C++::stl, insert and find for unordered_map have guaranteed amortized time complexity O(1). This puzzles me, and I would like to see the ...
2
votes
5
answers
2k
views
std::vector Non-Array Implementation?
I've seen some posts on the StackExchange family of sites talking about std::vector implementations. They all seem to indicate that std::vector is implemented strictly as an array (in practice), and ...
3
votes
1
answer
1k
views
Does Microsoft still have C++ container limitations when passing to DLLs? [duplicate]
Microsoft has had a fair amount of trouble in the past when passing STL containers like string and vector pointers and references to DLLs. See, for example, You may experience an access violation when ...
8
votes
2
answers
6k
views
What's wrong with statically linking the STL into multiple shared libraries?
Here is the scenario:
libA.so and libB.so both statically link to the same STL.
libA.so has a public API that returns a std::string.
libB.so calls this function and receives a copy of the string.
When ...