Reputation: 6998
I have Client* objects stored in my game. I want to pass a list to a Client. The Client object stores a list of Client pointers, and so the list I pass in I want to overwrite the stored list, but std::copy() is giving errors.
void Client::SetClientList(list<Client*> c)
{ _clients.clear(); std::copy(c.begin(), c.end(), _clients); }
It gives strange errors pointing to the xutility file. If I comment out the copy statement then it compiles fine so that's the statement that it doesn't like.
The idea is that each client stores a list of clients that are within range and therefore need to send data too.
Upvotes: 2
Views: 879
Reputation: 53047
std::copy
takes 3 iterators, not 2 and a container:
std::copy(c.begin(), c.end(), _clients.begin());
Also, if they are the same list type then just do this:
_clients = c;
Upvotes: 7