SFML community forums

Help => Network => Topic started by: zihasoo on September 30, 2022, 07:34:56 pm

Title: Can not make std::vector<sf::TcpSocket>
Post by: zihasoo on September 30, 2022, 07:34:56 pm
I figured out that TcpSocket is a non-copyable object, so I used the emplace_back method accordingly.
I know that with this method the copy constructor won't be called, why can't I use this vector?

I get an error saying that I am using the copy constructor. Despite using the emplace_back method!

Title: Re: Can not make std::vector<sf::TcpSocket>
Post by: eXpl0it3r on September 30, 2022, 11:07:54 pm
SFML 2.x doesn't implement move semantics, so the vector can't move the sockets and thus tries to copy it, which it can't. You could use a vector of unique_ptr of sockets or use a different container, depending on what you're trying to achieve.

Also SFML 3 which is currently in development on the master branch which should introduce move sematics.
Title: Re: Can not make std::vector<sf::TcpSocket>
Post by: zihasoo on October 01, 2022, 04:14:13 am
thank you so much. Everything has become clear! :)