Questions tagged as 'stl'

2
answers

In what situations should I allocate a vector dynamically in C ++?

I'm working on a framework code for my work. In one of the functions, it dynamically allocates a std::vector , makes a copy of each node that the object has and returns it to the user: std::vector<Node> *Tree::getAllNodes() {...
asked by 14.12.2013 / 21:31
2
answers

What is Iterator?

Studying STL in C ++, I almost always encounter the term iterator , example: std::vector<int>::iterator it; What is the function of a iterator ?     
asked by 08.11.2016 / 19:44
1
answer

Difference between std :: list, std :: vector and std :: array

All containers used to guard data sequentially, but what are the main differences between them?     
asked by 04.11.2016 / 17:30
1
answer

How to insert dynamically into a std :: array?

I'm migrating from C language to C ++, and I want to stop using traditional C language media as the vector of it. Is it possible to use std::array to insert elements dynamically as in std::vector ?     
asked by 08.11.2016 / 15:52
2
answers

Removing repeated values

I have two vectors , each with (x, y) coordinates. I need to invert the second vector , getting with (y, x) and merge with the first, but I can not get repetition in the first field, so I thought I'd use a set . However, I need the second...
asked by 15.03.2014 / 15:43
1
answer

std :: sort with comparison function

Studying a little about STL I came across the std::sort function that can receive a comparison function. template< class RandomIt, class Compare > void sort( RandomIt first, RandomIt last, Compare comp ); How does this comparis...
asked by 21.04.2017 / 00:15
1
answer

What is the difference between "string_view" for "string" and which one should you prefer?

What's the difference between the new C ++ class and 17 string_view for string ? In what situations is the use of string_view indicated instead of string ?     
asked by 22.08.2018 / 20:22
1
answer

How to create a mapped file with a std :: map

I'm trying to use a std :: map that allocates objects within a mapped file using boost, with a vector worked but with a non map #include <boost/interprocess/managed_mapped_file.hpp> #include <map> #include <iostream> namespac...
asked by 11.07.2017 / 16:17
2
answers

remove data from an object list

I'm having trouble removing an object from the list according to a code. I tried to do this: void turma::removeraluno (int matricula){ // remover o aluno pelo codigo de matricula list<aluno>::iterator it; for (it=lista.b...
asked by 02.08.2017 / 08:46
0
answers

Runtime Error URI1270

I made a code in C ++ to solve the 1270 Fiber Optic URI problem. I did several simulations and the code solves the problem but in the URI environment, the answer is "Runtime Error". Can someone help me figure out where the error is in the code?...
asked by 13.07.2017 / 05:09