Questions tagged [stl]
About the "Standard Template Library", which inspired the major parts C++ Standard Library
28
questions
2
votes
3
answers
3k
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 ...
4
votes
2
answers
1k
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 - ...
30
votes
3
answers
20k
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 ...
17
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
202
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 ...
2
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
760
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
1k
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
963
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
5k
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.
...
2
votes
4
answers
6k
views
Wrapper around C++ STL
Where I work we have our own system library, which pretty much is only wrappers around the STL, such as:
template <typename T>
class HVector {
protected:
std::vector<T> data;
public:
...
1
vote
0
answers
146
views
Why isn't there parallel reduction in the Standard Template Library?
Alexander Stepanov stated in talks and interviews that his realization that eventually lead him to generic programming and the Standard Template Library, was from the case of the parallel reduction ...
7
votes
3
answers
258
views
Are there languages that expand on the STL's iterator types? [closed]
Many languages use the concept of an iterator. The c++ STL expands on this with input iterators, output iterators, forward, bidirectional, random access and others. As far as I know, these ...
2
votes
3
answers
12k
views
Two-Dimensional vector in C++ – inefficient with dynamic-sized sub vectors?
I know that std::vector uses a contiguous block of memory, but I often see people use vectors of vectors, even when they modify the number of elements in these vectors contained within an outer vector....
19
votes
3
answers
18k
views
QT-C++ vs Generic C++ and STL [closed]
Been brushing up on my C++ lately, on Ubuntu QQ. I love the Qt framework for everything, especially building GUI's. I became quite familiar with it when using PyQt over the last few years.
When ...
2
votes
2
answers
1k
views
How do objects fit into modern C++ (stl, policy-classes, functional) style?
I'm a bit confused so the question is a bit confusing. TL;dr: how to mix STL and OOP?
From the comment to Best overview to modern C++ paradigms? and http://www.boost.org/community/generic_programming....
37
votes
10
answers
84k
views
What is the point of using lists over vectors, in C++?
I've run 3 different experiments involving C++ lists and vectors.
Those with vectors proved more efficient, even when a lot of insertions in the middle were involved.
Hence the question: in which ...
4
votes
1
answer
1k
views
How does a priority_queue maintain a heap on a deque efficiently?
In the C++ STL, priority_queue (heap) can be used with any underlying container, such as a deque. How does the implementation stay O(log n) if deques don't swap an item in index a with index b in ...
5
votes
4
answers
13k
views
Why is using classic for loops as iterators in stl considered bad?
I've read a couple of articles (example) that consider the classic
for (int ...... size() .... i++) loop bad practice when iterating through for example vectors in stl. Instead the recommended why ...
21
votes
6
answers
20k
views
Is it practical to abandon STL in C++ development? [closed]
I know in some areas (game industry, for example), STL is not recommended.
So my question is: is it really a good practice not to use STL in some cases? If so, what's the biggest reasons of not using ...
2
votes
4
answers
8k
views
What sorting algorithm does STL use?
I recently started using <vector.h> library and I was wondering, since all the operations are already implemented, IF the method of the sorting algorithm is the most efficient one. Everything ...
4
votes
4
answers
1k
views
What kind of interface should a double container offer?
I want to write a class which offers two sequences of elements to its users. The first one (lets call it "primary") is the main of the class and will be use 80% of the time. The second one (lets call ...
1
vote
4
answers
418
views
Use the terms "vector" or "array" in high level discussion of C++ code
When I write high-level documentation about what an algorithm does, I use the term "array" to refer to the data structure on which the algorithm operates even though the actual data structure is an ...