mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd:Ⓜ️ Fix ID reconstruction semantics; cleanup.
This commit is contained in:
parent
bc5f429681
commit
55603a3718
1 changed files with 60 additions and 39 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue