Questions tagged [Standard Template Library] (46)

2
answers

As std::initializer_list determines the number of items in {list}?

If the type definition is more or less clear (in the pros RTTI, etc.), how the creators of this class determine the size of this list. In fact, as far as I understand, the list is essentially an array. In pure si its size, the compiler calculates, if to do so:char string[] = "string"; or this:int array[] = {1,2,3,4,5,6,7};
vicenta_Hickle asked April 4th 20 at 12:56
0
answer

Why hangs getline STL?

Good day! I have written a simple neural network in c++ and everything worked great. Today put VS VS 2019 instead of 2015. When you try to run the same code my program hangs on getline. I tried to debug line by line: on the second getline opens the console and hangs. Please tell me what is the problem?int main() { ifstrea...
Emmanuelle83 asked April 1st 20 at 17:35
2
answers

Thread-safe container?

There is a container containing pointers to instances of a custom class. Also, there is 1 stream (let's call it a modifier) that adds and deletes the container elements and N threads doing the bypass elements and producing with them a certain action (let us call them handlers). The challenge was to make the container thread...
violet.Stanton asked April 1st 20 at 15:30
0
answer

How do you implement such a feature?

intersectionInvoke<Position, Velocity>(positions, velocities, [] (EntityID id, Position& pos, const Velocity& vel) { pos.x += vel.x; pos.y += vel.y; } ); The Position and Velocity of the struct and just positions, velocities is STD:: unordered_map<id, Positions/Velocity>
electa85 asked March 31st 20 at 14:00
1
answer

The use of Hash in c++?

Good day! I study unordered_set and read that to use your own classes in the unordered_set(as an option) to specialize a class template hash. By analogy with what I read on the Internet, I have specialized hash and got:template<> class hash<OB> { public: size_t operator() (const OB& obi) const{ return hash...
Cleve_Upt asked March 29th 20 at 19:31
2
answers

How to use the STL algorithms with Qt?

Good evening everyone. How to use the STL algorithms with Qt, for example a QStringList and set_difference , for example? If it is possible, of course.
yazmin_Will asked March 25th 20 at 11:58
0
answer

As Serendipity a lot in C++?

There is a set<string> Myset; there are 3 suggestions I would like sarandipity one of them and bring down the console, and the proposal is to parandamisel - to remove from the set.
jacey_Morissette97 asked March 23rd 20 at 18:44
2
answers

Why own implementation of the linked list performs the add element in the beginning of the forward_list faster?

I'm new to programming, learn the structure of the data, wrote the implementation of linked list to understand how it works, "touch hands". Noticed that when 10ΠΊΠΊ elements of the program consumes 611 MB of memory. Thought where are memory leaks, plugged STL forward_list, added the same number of elements, too, 611 MB. But ...
alek77 asked March 20th 20 at 12:29
1
answer

Why do we need std::unique?

The question is not, what it does, and for what and why it was implemented? Roughly speaking, if there is a set of data, to leave only unique elements, you have to first sort and then use unique. Otherwise the behavior is undefined. Something like that if nothing is messed up:std::vector<int> a = {1, 3, 4, 454, 5454, ...
Vito_Cremin asked March 15th 20 at 22:22
1
answer

Is there a book like "C++ for professionals"?

Maybe someone knows a book that explores issues related to C++ deeper than was common. A great example of such a book is a book of Jeff Alger "C++ for real programmers", but, to be honest, it was released long ago and not affect the modern aspects of the language. There is something similar but more modern?
marge72 asked March 14th 20 at 16:43