stl

STL C++Iterators

Hello! Please tell me if it is possible to store iterators from vector for a long time, for example, so that it can be derefe ... о листинга cout << *b[*it] << endl; } Instead of char*, the program with the error has a different structure.

C++ stl map

Works:(All in one file ConsoleApplication4.cpp) #include <string> #include <map> using namespace std ... 1169: one or more multiply defined symbols found ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

STL C++ stl random

We need a lambda function that generates a random number of stl by the generator, normal scattering . minimum -50 max 50. the ... = []() { return std::mt19937 gen{std::random_device()()}, std::uniform_int_distribution<int> uid(-50, 50); };

Why std::find returns a pointer?

Why the find() method uses a pointer. That is, in this example #include <iostream> // std::cout #include <algori ... ay. We just need to search for it in the array and that's it. Why can't this be done without a pointer? Thank you in advance!

Array library, entering the size of an array from the keyboard

Is there any way, using array (int, N) name; to enter the size of the array (N)from the keyboard?

The text is given. You need to change the case of the letters after the dot

The source text is typed with errors . Print the source text by replacing the lowercase (small) letters following the dot and ... nce(first.cbegin(), iter) + 1; transform(first.cbegin(), first.cend(), first.cbegin() + position, ::tolower(iter)); } '

Inheritance and use of a static vector in C++

There is a base class in which I need to have a static vector, where I will enter some values in the constructors of the inhe ... allocator@N@std@@@std@@A)" How right organize a vector in the base class so that all the inheritors can enter values in it?

C++vectors don't work

I'm working on a 2D game in SFMl c++. but I think it is not important. There is a World class. It has a string type vector ( ... the code, I specified a possible string due to which occurs error ATTENTION! the error is not the build, but the execution!

c++ stl: intersection of sets

Tell me, is there a standard means in stl or some short optimal way to solve the following problem: There are 2 sets of inte ... struct a third set, which would include only those elements that are present in both the first set1 and the second set2 sets.

Call of overloaded is ambiguous when implementing its copy algorithm

There is a self-written similarity of stl. The essence of the problem is a vector of pairs (also self-written). The problem ... 0; } P.S. This is something like training on cats (to avoid comments like "why all this is necessary, if there is an stl").

C++: converting a simple fraction to a decimal

Please tell me with the algorithm: I have a simple fraction that is stored as a pair of integers using fraction_t = std::pa ... iplier *= 5; } if (value == 1){// десятичная дробь} Is there any the ability to perform such a task in a more optimal way?

map does not save an association by an already existing key

Good afternoon. Solving a problem : "Two words are called synonyms of each other if they have similar meanings. Implement the ... etween c++ and java, and overwrites the first one, changing rust to java. I will be grateful for your help in fixing the bug.

stl: time spent for adding elements to a vector

Please explain where the legs can grow in time costs when working with the addition to the vector: There are the following da ... e else do not occur, then why add empty ones !!! chains for which only 2 reserve() are called for each spending so much time?

C++ stl: sort () via comparator

Why can't I pass parameters to the comparator by reference? What do you need to send there at all, and what is not necessary? ... ) for ( j = 0; j < m; j++ ) scanf( "%d", &M[i][j] ); sort ( M, M + n, cmp ); return 0; }

Why does the container's capacity increase on its own?

Here is a simple code: #include <iostream> #include <vector> using namespace std; int main(){ vector<in ... стоятельно увеличилась до 20? return 0; } Result: Why did the capacity itself increase to 20, I expected it to be 6

Binary"==": no operator found that accepts a left operand of type " xxx"

I don't understand why remove_if works as it should, and remove gives an error. std::list<Element> items; void Remove ... items.remove_if([&](const Element & value) {return item.GetName() == value.GetName(); }); items.remove(item); }

I can't add a smart pointer to the vector

There is a class MyClass, of course, with a constructor, you need to create a vector of smart pointers to objects of this cla ... nique_ptr<MyClass> p1(new MyClass); // до этого момента всё в порядке vectorPtr.push_back(p1); return 0; }

How can I determine the number of words of length k in a string without using loops?

Given a string where the words are separated by spaces and colons. You need to count the number of words with a length less t ... loops, only STL algorithms and containers are allowed. There is no idea how all this can be done. I'd like at least an idea.

List C++ Deleting a specific List element

You need to remove the second element from the list. Everything works as it should. But if I create a function: And call it, ... ut << *it << " "; } return 0; } * * Update: ** Problem solved, the solution is in my answer below.

What is upper bound and lower bound in c++ and how do they differ

Please tell me what upper_bound and lower_bound are in the C++ standard library and how they work.