0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-12 15:08:55 +02:00

ircd:Ⓜ️ Fix ID reconstruction semantics; cleanup.

This commit is contained in:
Jason Volk 2017-10-28 12:26:47 -07:00
parent bc5f429681
commit 55603a3718

View file

@ -95,45 +95,6 @@ namespace ircd::m
const char *reflect(const enum id::sigil &);
}
/// ID object backed by an internal buffer of wost-case size.
///
template<class T,
size_t MAX = 256>
struct ircd::m::id::buf
:T
{
static constexpr const size_t SIZE
{
MAX
};
private:
fixed_buffer<mutable_buffer, SIZE> b;
public:
operator const fixed_buffer<mutable_buffer, SIZE> &() const
{
return b;
}
operator mutable_buffer()
{
return b;
}
template<class... args>
buf(args&&... a)
:T{b, std::forward<args>(a)...}
{}
buf() = default;
buf &operator=(const string_view &s)
{
static_cast<T &>(*this) = T{b, s};
return *this;
}
};
//
// convenience typedefs
//
@ -166,6 +127,66 @@ struct ircd::m::id::alias
template<class... args> alias(args&&... a) :m::id{ALIAS, std::forward<args>(a)...} {}
};
/// ID object backed by an internal buffer of wost-case size.
///
template<class T,
size_t MAX = 256>
struct ircd::m::id::buf
:T
{
static constexpr const size_t SIZE
{
MAX
};
private:
fixed_buffer<mutable_buffer, SIZE> b;
public:
operator const fixed_buffer<mutable_buffer, SIZE> &() const
{
return b;
}
operator mutable_buffer()
{
return b;
}
template<class... args>
buf(args&&... a)
:T{b, std::forward<args>(a)...}
{}
buf() = default;
buf(buf &&other) noexcept
:T{b, std::move(other)}
{}
buf(const buf &other)
:T{b, other}
{}
buf &operator=(const buf &other)
{
static_cast<T &>(*this) = T{b, other};
return *this;
}
buf &operator=(buf &&other) noexcept
{
static_cast<T &>(*this) = T{b, std::move(other)};
return *this;
}
buf &operator=(const string_view &s)
{
static_cast<T &>(*this) = T{b, s};
return *this;
}
};
inline uint16_t
ircd::m::id::hostport()
const try