Standard Template Library in C++

learn more… | top users | synonyms

21
votes
9answers
39k 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 ...
13
votes
6answers
8k 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 ...
13
votes
3answers
8k 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 ...
5
votes
3answers
186 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 ...
4
votes
1answer
522 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 ...
4
votes
2answers
1k 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
4answers
6k 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 ...
2
votes
4answers
1k 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: ...
2
votes
3answers
264 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
2answers
160 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
2answers
916 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....
2
votes
4answers
614 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 ...
2
votes
5answers
522 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 ...
1
vote
3answers
6k 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....
1
vote
4answers
340 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 ...
1
vote
1answer
226 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 ...
1
vote
0answers
132 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 ...
0
votes
4answers
3k 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 ...
-2
votes
3answers
115 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 ...