diff --git a/include/SFML/Network/SocketSelector.hpp b/include/SFML/Network/SocketSelector.hpp index 765b7133..43d3dede 100644 --- a/include/SFML/Network/SocketSelector.hpp +++ b/include/SFML/Network/SocketSelector.hpp @@ -65,6 +65,28 @@ public: //////////////////////////////////////////////////////////// SocketSelector(const SocketSelector& copy); + //////////////////////////////////////////////////////////// + /// \brief Overload of assignment operator + /// + /// \param right Instance to assign + /// + /// \return Reference to self + /// + //////////////////////////////////////////////////////////// + SocketSelector& operator=(const SocketSelector& right); + + //////////////////////////////////////////////////////////// + /// \brief Move constructor + /// + //////////////////////////////////////////////////////////// + SocketSelector(SocketSelector&&) noexcept; + + //////////////////////////////////////////////////////////// + /// \brief Move assignment + /// + //////////////////////////////////////////////////////////// + SocketSelector& operator=(SocketSelector&&) noexcept; + //////////////////////////////////////////////////////////// /// \brief Add a new socket to the selector /// @@ -142,16 +164,6 @@ public: //////////////////////////////////////////////////////////// bool isReady(Socket& socket) const; - //////////////////////////////////////////////////////////// - /// \brief Overload of assignment operator - /// - /// \param right Instance to assign - /// - /// \return Reference to self - /// - //////////////////////////////////////////////////////////// - SocketSelector& operator=(const SocketSelector& right); - private: struct SocketSelectorImpl; diff --git a/src/SFML/Network/SocketSelector.cpp b/src/SFML/Network/SocketSelector.cpp index 6c436d86..f42d13a1 100644 --- a/src/SFML/Network/SocketSelector.cpp +++ b/src/SFML/Network/SocketSelector.cpp @@ -60,6 +60,10 @@ SocketSelector::SocketSelector() : m_impl(std::make_unique() } +//////////////////////////////////////////////////////////// +SocketSelector::~SocketSelector() = default; + + //////////////////////////////////////////////////////////// SocketSelector::SocketSelector(const SocketSelector& copy) : m_impl(std::make_unique(*copy.m_impl)) { @@ -67,7 +71,20 @@ SocketSelector::SocketSelector(const SocketSelector& copy) : m_impl(std::make_un //////////////////////////////////////////////////////////// -SocketSelector::~SocketSelector() = default; +SocketSelector& SocketSelector::operator=(const SocketSelector& right) +{ + SocketSelector temp(right); + std::swap(m_impl, temp.m_impl); + return *this; +} + + +//////////////////////////////////////////////////////////// +SocketSelector::SocketSelector(SocketSelector&&) noexcept = default; + + +////////////////////////////////////////////////////////////] +SocketSelector& SocketSelector::operator=(SocketSelector&&) noexcept = default; //////////////////////////////////////////////////////////// @@ -189,15 +206,4 @@ bool SocketSelector::isReady(Socket& socket) const return false; } - -//////////////////////////////////////////////////////////// -SocketSelector& SocketSelector::operator=(const SocketSelector& right) -{ - SocketSelector temp(right); - - std::swap(m_impl, temp.m_impl); - - return *this; -} - } // namespace sf diff --git a/test/Network/SocketSelector.test.cpp b/test/Network/SocketSelector.test.cpp index 0a7eee6c..4d3ea46a 100644 --- a/test/Network/SocketSelector.test.cpp +++ b/test/Network/SocketSelector.test.cpp @@ -1,10 +1,27 @@ #include +// Other 1st party headers +#include + +#include + #include -static_assert(std::is_copy_constructible_v); -static_assert(std::is_copy_assignable_v); -static_assert(std::is_move_constructible_v); -static_assert(!std::is_nothrow_move_constructible_v); -static_assert(std::is_move_assignable_v); -static_assert(!std::is_nothrow_move_assignable_v); +TEST_CASE("[Network] sf::SocketSelector") +{ + SECTION("Type traits") + { + STATIC_CHECK(std::is_copy_constructible_v); + STATIC_CHECK(std::is_copy_assignable_v); + STATIC_CHECK(std::is_nothrow_move_constructible_v); + STATIC_CHECK(std::is_nothrow_move_assignable_v); + } + + sf::UdpSocket socket; + + SECTION("Construction") + { + const sf::SocketSelector socketSelector; + CHECK(!socketSelector.isReady(socket)); + } +}