Commit 55bc8869 authored by Dominik Charousset's avatar Dominik Charousset

use `util::comparable` for message_id_t

parent 2c7f5b80
......@@ -32,23 +32,22 @@
#define CPPA_MESSAGE_ID_HPP
#include "cppa/config.hpp"
#include "cppa/util/comparable.hpp"
namespace cppa {
struct invalid_message_id_flag { constexpr invalid_message_id_flag() { } };
struct invalid_message_id { constexpr invalid_message_id() { } };
/**
* @brief
* @note Asynchronous messages always have an invalid message id.
*/
class message_id_t {
class message_id_t : util::comparable<message_id_t> {
static constexpr std::uint64_t response_flag_mask = 0x8000000000000000;
static constexpr std::uint64_t answered_flag_mask = 0x4000000000000000;
static constexpr std::uint64_t request_id_mask = 0x3FFFFFFFFFFFFFFF;
friend bool operator==(const message_id_t& lhs, const message_id_t& rhs);
public:
constexpr message_id_t() : m_value(0) { }
......@@ -101,9 +100,14 @@ class message_id_t {
return result;
}
static constexpr invalid_message_id_flag invalid = invalid_message_id_flag();
static constexpr invalid_message_id invalid = invalid_message_id{};
constexpr message_id_t(invalid_message_id) : m_value(0) { }
inline message_id_t(invalid_message_id_flag) : m_value(0) { }
long compare(const message_id_t& other) const {
return (m_value == other.m_value)
? 0 : ((m_value < other.m_value) ? -1 : 1);
}
private:
......@@ -113,14 +117,6 @@ class message_id_t {
};
inline bool operator==(const message_id_t& lhs, const message_id_t& rhs) {
return lhs.m_value == rhs.m_value;
}
inline bool operator!=(const message_id_t& lhs, const message_id_t& rhs) {
return !(lhs == rhs);
}
} // namespace cppa
#endif // CPPA_MESSAGE_ID_HPP
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