Commit 240bb073 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

parent fb51d49b
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <type_traits> #include <type_traits>
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/detail/comparable.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/socket_id.hpp" #include "caf/net/socket_id.hpp"
...@@ -31,24 +32,24 @@ namespace net { ...@@ -31,24 +32,24 @@ namespace net {
/// An internal endpoint for sending or receiving data. Can be either a /// An internal endpoint for sending or receiving data. Can be either a
/// ::network_socket, ::pipe_socket, ::stream_socket, or ::datagram_socket. /// ::network_socket, ::pipe_socket, ::stream_socket, or ::datagram_socket.
struct socket { struct socket : detail::comparable<socket> {
socket_id id; socket_id id;
constexpr socket() : id(invalid_socket_id) { constexpr socket() noexcept : id(invalid_socket_id) {
// nop // nop
} }
constexpr explicit socket(socket_id id) : id(id) { constexpr explicit socket(socket_id id) noexcept : id(id) {
// nop // nop
} }
constexpr socket(const socket& other) : id(other.id) { constexpr socket(const socket& other) noexcept = default;
// nop
} socket& operator=(const socket& other) noexcept = default;
socket& operator=(const socket& other) { constexpr signed_socket_id compare(socket other) const noexcept {
id = other.id; return static_cast<signed_socket_id>(id)
return *this; - static_cast<signed_socket_id>(other.id);
} }
}; };
...@@ -58,21 +59,6 @@ typename Inspector::result_type inspect(Inspector& f, socket& x) { ...@@ -58,21 +59,6 @@ typename Inspector::result_type inspect(Inspector& f, socket& x) {
return f(x.id); return f(x.id);
} }
/// @relates socket
constexpr bool operator==(socket x, socket y) {
return x.id == y.id;
}
/// @relates socket
constexpr bool operator!=(socket x, socket y) {
return x.id != y.id;
}
/// @relates socket
constexpr bool operator<(socket x, socket y) {
return x.id < y.id;
}
/// Denotes the invalid socket. /// Denotes the invalid socket.
constexpr auto invalid_socket = socket{invalid_socket_id}; constexpr auto invalid_socket = socket{invalid_socket_id};
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <type_traits>
#include "caf/config.hpp" #include "caf/config.hpp"
...@@ -46,5 +47,9 @@ constexpr socket_id invalid_socket_id = -1; ...@@ -46,5 +47,9 @@ constexpr socket_id invalid_socket_id = -1;
#endif // CAF_WINDOWS #endif // CAF_WINDOWS
/// Signed counterpart of `socket_id`.
/// @relates socket
using signed_socket_id = std::make_signed<socket_id>::type;
} // namespace net } // namespace net
} // namespace caf } // namespace caf
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment