Hello, thank you for your answer.
I didn't try for vectors actually, only for maps.
My overload operator for vectors seems to work (I don't know how to use templates, I'll try someday) :
inline sf::Packet& operator <<(sf::Packet& packet, const std::vector<Plateforme>& p)
{
packet << p.size();
for(int i = 0; i < p.size(); i++) packet << p.at(i) ;
return packet;
}
inline sf::Packet& operator >>(sf::Packet& packet, std::vector<Plateforme>& p)
{
int n;
Plateforme x;
packet >> n;
p.clear();
for(int i =0; i < n ;i++) { packet >> x; p.push_back(x);}
return packet;
}
But for maps, I get an error whenever I try to use an iterator in the function :
inline sf::Packet& operator <<(sf::Packet& packet, const std::map<std::string,int[20][2]>& a)
{
std::map<std::string,int[20][2]>::iterator it = a.end(); // Get length of the map : ERROR
// Rest of the code
}
Error : conversion from 'std::map<std::__cxx11::basic_string<char>, int [20][2]>::const_iterator {aka std::_Rb_tree_const_iterator<std::pair<const std::__cxx11::basic_string<char>, int [20][2]> >}' to non-scalar type 'std::map<std::__cxx11::basic_string<char>, int [20][2]>::iterator {aka std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, int [20][2]> >}' requested|
Anyway I'm not sure this is related to SFML. But this works normally outside the overload operator.
Anyway, thanks for your help !