Skip to content

Commit

Permalink
core: add missing [[nodiscard]] attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskovalchuk committed Apr 6, 2024
1 parent 523874b commit 27937a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions include/ftp/detail/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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_;
Expand Down
12 changes: 7 additions & 5 deletions include/ftp/detail/socket_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -125,12 +125,14 @@ class socket_base
}

template<typename SocketType>
[[nodiscard]]
boost::asio::ip::tcp::endpoint local_endpoint(const SocketType & socket, boost::system::error_code & ec) const
{
return socket.local_endpoint(ec);
}

template<typename SocketType>
[[nodiscard]]
boost::asio::ip::tcp::endpoint remote_endpoint(const SocketType & socket, boost::system::error_code & ec) const
{
return socket.remote_endpoint(ec);
Expand Down

0 comments on commit 27937a5

Please sign in to comment.