A
A
Alexander2020-04-17 18:52:59
C++ / C#
Alexander, 2020-04-17 18:52:59

What do the inscriptions Ty, Alloc, Allocator mean in the error?

I'm trying to remove a class object from a vector and a tooltip pops up. It has this entry. What does she mean?
missing instances overloaded function "std::vector<_Ty, _Alloc>::erase [with _Ty=A *, _Alloc=std::allocator ]"
Explain what _Ty_Alloc, c_Ty, _Alloc, allocator is.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2020-04-17
@Shemapp

You tried to run a function vector<A*>::erasewith unusual parameters. What - the error does not say, here are all the overloads.
https://ru.cppreference.com/w/cpp/container/vector...
That is, the function takes one or two iterators.
For example, if you want to delete a value but don't know where, you can't just erase it. But you must…

// Спрессовать без перевыделения памяти, получить новый конец
std::vector<A*>::iterator newEnd = std::remove(v.begin(), v.end(), whatToDelete);
// Удалить освободившийся хвост скопом!
v.erase(newEnd, v.end());

If you want to delete by index...
v.erase(v.begin() + indexToDelete);

A
Alexander Ananiev, 2020-04-17
@SaNNy32

https://ru.cppreference.com/w/cpp/container/vector

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question