Commit c82647ff authored by Dominik Charousset's avatar Dominik Charousset

Fix node_id object size on MSVC

parent 4ebdeba7
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
namespace caf { namespace caf {
/// A node ID is an opaque value for representing CAF instances in the network. /// A node ID is an opaque value for representing CAF instances in the network.
class node_id : detail::comparable<node_id>, class node_id {
detail::comparable<node_id, none_t> {
public: public:
// -- member types ----------------------------------------------------------- // -- member types -----------------------------------------------------------
...@@ -195,11 +194,6 @@ public: ...@@ -195,11 +194,6 @@ public:
/// @returns -1 if `*this < other`, 0 if `*this == other`, and 1 otherwise. /// @returns -1 if `*this < other`, 0 if `*this == other`, and 1 otherwise.
int compare(const node_id& other) const noexcept; int compare(const node_id& other) const noexcept;
/// Compares this instance as if comparing to a default-constructed
/// `node_id`.
/// @returns `compare(node_id{})`.
int compare(const none_t&) const;
/// Exchanges the value of this object with `other`. /// Exchanges the value of this object with `other`.
void swap(node_id& other); void swap(node_id& other);
...@@ -231,6 +225,56 @@ private: ...@@ -231,6 +225,56 @@ private:
intrusive_ptr<data> data_; intrusive_ptr<data> data_;
}; };
/// @relates node_id
inline bool operator==(const node_id& x, const node_id& y) noexcept {
return x.compare(y) == 0;
}
/// @relates node_id
inline bool operator!=(const node_id& x, const node_id& y) noexcept {
return x.compare(y) != 0;
}
/// @relates node_id
inline bool operator<(const node_id& x, const node_id& y) noexcept {
return x.compare(y) < 0;
}
/// @relates node_id
inline bool operator<=(const node_id& x, const node_id& y) noexcept {
return x.compare(y) <= 0;
}
/// @relates node_id
inline bool operator>(const node_id& x, const node_id& y) noexcept {
return x.compare(y) > 0;
}
/// @relates node_id
inline bool operator>=(const node_id& x, const node_id& y) noexcept {
return x.compare(y) >= 0;
}
/// @relates node_id
inline bool operator==(const node_id& x, const none_t&) noexcept {
return !x;
}
/// @relates node_id
inline bool operator==(const none_t&, const node_id& x) noexcept {
return !x;
}
/// @relates node_id
inline bool operator!=(const node_id& x, const none_t&) noexcept {
return static_cast<bool>(x);
}
/// @relates node_id
inline bool operator!=(const none_t&, const node_id& x) noexcept {
return static_cast<bool>(x);
}
/// @relates node_id /// @relates node_id
error inspect(serializer& sink, const node_id& x); error inspect(serializer& sink, const node_id& x);
......
...@@ -182,11 +182,6 @@ node_id::operator bool() const { ...@@ -182,11 +182,6 @@ node_id::operator bool() const {
return static_cast<bool>(data_); return static_cast<bool>(data_);
} }
int node_id::compare(const none_t&) const {
// Invalid instances are always smaller.
return data_ ? 1 : 0;
}
int node_id::compare(const node_id& other) const noexcept { int node_id::compare(const node_id& other) const noexcept {
if (this == &other || data_ == other.data_) if (this == &other || data_ == other.data_)
return 0; return 0;
......
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