diff --git a/examples/voip/Client.cpp b/examples/voip/Client.cpp index 6c85ffe2b..e1bacd291 100644 --- a/examples/voip/Client.cpp +++ b/examples/voip/Client.cpp @@ -30,7 +30,7 @@ public: /// \param port Port of the remote host /// //////////////////////////////////////////////////////////// - NetworkRecorder(const sf::IpAddress& host, unsigned short port) : m_host(host), m_port(port) + NetworkRecorder(sf::IpAddress host, unsigned short port) : m_host(host), m_port(port) { } diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp index 30b538a04..fcdc60172 100644 --- a/include/SFML/Network/Ftp.hpp +++ b/include/SFML/Network/Ftp.hpp @@ -290,7 +290,7 @@ public: /// \see disconnect /// //////////////////////////////////////////////////////////// - [[nodiscard]] Response connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero); + [[nodiscard]] Response connect(IpAddress server, unsigned short port = 21, Time timeout = Time::Zero); //////////////////////////////////////////////////////////// /// \brief Close the connection with the server diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp index 2104a77a7..b39790fea 100644 --- a/include/SFML/Network/IpAddress.hpp +++ b/include/SFML/Network/IpAddress.hpp @@ -171,7 +171,7 @@ public: // NOLINTEND(readability-identifier-naming) private: - friend SFML_NETWORK_API bool operator<(const IpAddress& left, const IpAddress& right); + friend SFML_NETWORK_API bool operator<(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// // Member data @@ -188,7 +188,7 @@ private: /// \return True if both addresses are equal /// //////////////////////////////////////////////////////////// -[[nodiscard]] SFML_NETWORK_API bool operator==(const IpAddress& left, const IpAddress& right); +[[nodiscard]] SFML_NETWORK_API bool operator==(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// /// \brief Overload of != operator to compare two IP addresses @@ -199,7 +199,7 @@ private: /// \return True if both addresses are different /// //////////////////////////////////////////////////////////// -[[nodiscard]] SFML_NETWORK_API bool operator!=(const IpAddress& left, const IpAddress& right); +[[nodiscard]] SFML_NETWORK_API bool operator!=(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// /// \brief Overload of < operator to compare two IP addresses @@ -210,7 +210,7 @@ private: /// \return True if \a left is lesser than \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] SFML_NETWORK_API bool operator<(const IpAddress& left, const IpAddress& right); +[[nodiscard]] SFML_NETWORK_API bool operator<(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// /// \brief Overload of > operator to compare two IP addresses @@ -221,7 +221,7 @@ private: /// \return True if \a left is greater than \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] SFML_NETWORK_API bool operator>(const IpAddress& left, const IpAddress& right); +[[nodiscard]] SFML_NETWORK_API bool operator>(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// /// \brief Overload of <= operator to compare two IP addresses @@ -232,7 +232,7 @@ private: /// \return True if \a left is lesser or equal than \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] SFML_NETWORK_API bool operator<=(const IpAddress& left, const IpAddress& right); +[[nodiscard]] SFML_NETWORK_API bool operator<=(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// /// \brief Overload of >= operator to compare two IP addresses @@ -243,7 +243,7 @@ private: /// \return True if \a left is greater or equal than \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] SFML_NETWORK_API bool operator>=(const IpAddress& left, const IpAddress& right); +[[nodiscard]] SFML_NETWORK_API bool operator>=(IpAddress left, IpAddress right); //////////////////////////////////////////////////////////// /// \brief Overload of >> operator to extract an IP address from an input stream @@ -265,7 +265,7 @@ SFML_NETWORK_API std::istream& operator>>(std::istream& stream, std::optional IpAddress::getPublicAddress(Time timeout) //////////////////////////////////////////////////////////// -bool operator==(const IpAddress& left, const IpAddress& right) +bool operator==(IpAddress left, IpAddress right) { return !(left < right) && !(right < left); } //////////////////////////////////////////////////////////// -bool operator!=(const IpAddress& left, const IpAddress& right) +bool operator!=(IpAddress left, IpAddress right) { return !(left == right); } //////////////////////////////////////////////////////////// -bool operator<(const IpAddress& left, const IpAddress& right) +bool operator<(IpAddress left, IpAddress right) { return left.m_address < right.m_address; } //////////////////////////////////////////////////////////// -bool operator>(const IpAddress& left, const IpAddress& right) +bool operator>(IpAddress left, IpAddress right) { return right < left; } //////////////////////////////////////////////////////////// -bool operator<=(const IpAddress& left, const IpAddress& right) +bool operator<=(IpAddress left, IpAddress right) { return !(right < left); } //////////////////////////////////////////////////////////// -bool operator>=(const IpAddress& left, const IpAddress& right) +bool operator>=(IpAddress left, IpAddress right) { return !(left < right); } @@ -243,7 +243,7 @@ std::istream& operator>>(std::istream& stream, std::optional& address //////////////////////////////////////////////////////////// -std::ostream& operator<<(std::ostream& stream, const IpAddress& address) +std::ostream& operator<<(std::ostream& stream, IpAddress address) { return stream << address.toString(); } diff --git a/src/SFML/Network/TcpListener.cpp b/src/SFML/Network/TcpListener.cpp index dcb9c6b56..c670a64b9 100644 --- a/src/SFML/Network/TcpListener.cpp +++ b/src/SFML/Network/TcpListener.cpp @@ -62,7 +62,7 @@ unsigned short TcpListener::getLocalPort() const //////////////////////////////////////////////////////////// -Socket::Status TcpListener::listen(unsigned short port, const IpAddress& address) +Socket::Status TcpListener::listen(unsigned short port, IpAddress address) { // Close the socket if it is already bound close(); diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index dc4eded50..cbaa17187 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -119,7 +119,7 @@ unsigned short TcpSocket::getRemotePort() const //////////////////////////////////////////////////////////// -Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout) +Socket::Status TcpSocket::connect(IpAddress remoteAddress, unsigned short remotePort, Time timeout) { // Disconnect the socket if it is already connected disconnect(); diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp index ca45cace6..850e53ec6 100644 --- a/src/SFML/Network/UdpSocket.cpp +++ b/src/SFML/Network/UdpSocket.cpp @@ -65,7 +65,7 @@ unsigned short UdpSocket::getLocalPort() const //////////////////////////////////////////////////////////// -Socket::Status UdpSocket::bind(unsigned short port, const IpAddress& address) +Socket::Status UdpSocket::bind(unsigned short port, IpAddress address) { // Close the socket if it is already bound close(); @@ -98,7 +98,7 @@ void UdpSocket::unbind() //////////////////////////////////////////////////////////// -Socket::Status UdpSocket::send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort) +Socket::Status UdpSocket::send(const void* data, std::size_t size, IpAddress remoteAddress, unsigned short remotePort) { // Create the internal socket if it doesn't exist create(); @@ -183,7 +183,7 @@ Socket::Status UdpSocket::receive(void* data, //////////////////////////////////////////////////////////// -Socket::Status UdpSocket::send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort) +Socket::Status UdpSocket::send(Packet& packet, IpAddress remoteAddress, unsigned short remotePort) { // UDP is a datagram-oriented protocol (as opposed to TCP which is a stream protocol). // Sending one datagram is almost safe: it may be lost but if it's received, then its data diff --git a/test/Network/IpAddress.test.cpp b/test/Network/IpAddress.test.cpp index 1a57db25d..3400ae32a 100644 --- a/test/Network/IpAddress.test.cpp +++ b/test/Network/IpAddress.test.cpp @@ -17,6 +17,7 @@ TEST_CASE("[Network] sf::IpAddress") STATIC_CHECK(std::is_copy_assignable_v); STATIC_CHECK(std::is_nothrow_move_constructible_v); STATIC_CHECK(std::is_nothrow_move_assignable_v); + STATIC_CHECK(std::is_trivially_copyable_v); } SECTION("Construction")