Hi,
The following piece of code compiles and runs as expected on Windows, but when I try and compile my program on FreeBSD, the following error occurs (I'm pretty new to STL)
Code:
void removeConnection(cnx_inf_vector::pointer p) {
closesocket(p->sock);
v_clients.erase(p);
}
The following errors are generated by gcc on FreeBSD 5.2:
Code:
main.cpp:258: error: no matching function for call to `std::vector<cnx_inf,
std::allocator<cnx_inf> >::erase(cnx_inf*&)'
/usr/include/c++/3.3/bits/vector.tcc:105: error: candidates are:
__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
std::vector<_Tp, _Alloc> >) [with _Tp = cnx_inf, _Alloc =
std::allocator<cnx_inf>]
/usr/include/c++/3.3/bits/vector.tcc:117: error:
__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<_Tp*,
std::vector<_Tp, _Alloc> >) [with _Tp = cnx_inf, _Alloc =
std::allocator<cnx_inf>]
I realise that erase takes an iterator and not a pointer as a paramater, but this seems to work fine on Windows (Aren't iterators just pointers anyway?)
The reason I'm using pointers is to make the rest of my program a lot simpler, and I had trouble getting my code to run reliably using iterators without exceptions.
Any help greatly appreciated.
Many thanks,
Daniel Briley