list iterator erase error

0

Mam problem z następującym kodem:

class gameObject 
{
// (...)
};
class spaceship : gameObject 
{
// (...)
}
std::list<std::unique_ptr<gameObject>> objects;
objects.push_back(std::unique_ptr<gameObject>(new spaceship);

   auto test = objects.begin();
   objects.erase(test);
error: no matching function for call to 'std::list<std::unique_ptr<gameObject> >::erase(gameObject&) const'|
note: candidates are:|
note: std::list<_Tp, _Alloc>::iterator std::list<_Tp, _Alloc>::erase(std::list<_Tp, _Alloc>::iterator) 

Czy ktoś wie co jest nie tak? próbowałem *erase(test) lub **erase(test) ale ciągle otrzymuje ten sam problem.

0
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <set>
#include <list>
#include <memory>

struct A
{
	
};

int main()
{
	std::list<std::unique_ptr<A>> l;
	l.push_back(std::make_unique<A>());
	std::cout << l.size();
	l.erase(std::begin(l));
	std::cout << l.size();

	return 0;
}

http://melpon.org/wandbox/permlink/Ec131ZSnkR4WR6Xa

jesteś pewien, że masz nagłówek listy zaincludowany?

zresztą używaj vectora

0

W wierszu:

objects.push_back(std::unique_ptr<gameObject>(new spaceship);

brakuje nawiasu okrągłego.

1 użytkowników online, w tym zalogowanych: 0, gości: 1