diff --git a/include/ftp/detail/socket.hpp b/include/ftp/detail/socket.hpp index 36fc597..fc45f92 100644 --- a/include/ftp/detail/socket.hpp +++ b/include/ftp/detail/socket.hpp @@ -41,7 +41,7 @@ class socket : public socket_base void connect(const boost::asio::ip::tcp::endpoint & ep, boost::system::error_code & ec) override; - bool is_connected() const override; + [[nodiscard]] bool is_connected() const override; std::size_t write(const char *buf, std::size_t size, boost::system::error_code & ec) override; @@ -55,13 +55,13 @@ class socket : public socket_base void close(boost::system::error_code & ec) override; - boost::asio::ip::tcp::endpoint local_endpoint(boost::system::error_code & ec) const override; + [[nodiscard]] boost::asio::ip::tcp::endpoint local_endpoint(boost::system::error_code & ec) const override; - boost::asio::ip::tcp::endpoint remote_endpoint(boost::system::error_code & ec) const override; + [[nodiscard]] boost::asio::ip::tcp::endpoint remote_endpoint(boost::system::error_code & ec) const override; - boost::asio::ip::tcp::socket::executor_type get_executor() override; + [[nodiscard]] boost::asio::ip::tcp::socket::executor_type get_executor() override; - boost::asio::ip::tcp::socket & get_socket() override; + [[nodiscard]] boost::asio::ip::tcp::socket & get_socket() override; private: boost::asio::ip::tcp::socket socket_; diff --git a/include/ftp/detail/socket_base.hpp b/include/ftp/detail/socket_base.hpp index 8e9dd50..8e06d02 100644 --- a/include/ftp/detail/socket_base.hpp +++ b/include/ftp/detail/socket_base.hpp @@ -41,7 +41,7 @@ class socket_base virtual void connect(const boost::asio::ip::tcp::endpoint & ep, boost::system::error_code & ec) = 0; - virtual bool is_connected() const = 0; + [[nodiscard]] virtual bool is_connected() const = 0; virtual std::size_t write(const char *buf, std::size_t size, boost::system::error_code & ec) = 0; @@ -55,14 +55,14 @@ class socket_base virtual void close(boost::system::error_code & ec) = 0; - virtual boost::asio::ip::tcp::endpoint local_endpoint(boost::system::error_code & ec) const = 0; + [[nodiscard]] virtual boost::asio::ip::tcp::endpoint local_endpoint(boost::system::error_code & ec) const = 0; - virtual boost::asio::ip::tcp::endpoint remote_endpoint(boost::system::error_code & ec) const = 0; + [[nodiscard]] virtual boost::asio::ip::tcp::endpoint remote_endpoint(boost::system::error_code & ec) const = 0; - virtual boost::asio::ip::tcp::socket::executor_type get_executor() = 0; + [[nodiscard]] virtual boost::asio::ip::tcp::socket::executor_type get_executor() = 0; // TODO: Remove. - virtual boost::asio::ip::tcp::socket & get_socket() = 0; + [[nodiscard]] virtual boost::asio::ip::tcp::socket & get_socket() = 0; virtual ~socket_base() = default; @@ -125,12 +125,14 @@ class socket_base } template + [[nodiscard]] boost::asio::ip::tcp::endpoint local_endpoint(const SocketType & socket, boost::system::error_code & ec) const { return socket.local_endpoint(ec); } template + [[nodiscard]] boost::asio::ip::tcp::endpoint remote_endpoint(const SocketType & socket, boost::system::error_code & ec) const { return socket.remote_endpoint(ec);