Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can not make std::vector<sf::TcpSocket>  (Read 1309 times)

0 Members and 1 Guest are viewing this topic.

zihasoo

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Can not make std::vector<sf::TcpSocket>
« 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!


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Can not make std::vector<sf::TcpSocket>
« Reply #1 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.
« Last Edit: September 30, 2022, 11:15:01 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zihasoo

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Can not make std::vector<sf::TcpSocket>
« Reply #2 on: October 01, 2022, 04:14:13 am »
thank you so much. Everything has become clear! :)

 

anything