mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
ircd::byte_view: Rearrange class definition order for clang.
This commit is contained in:
parent
a8ebcbcbe0
commit
a5a267dcd5
1 changed files with 21 additions and 21 deletions
|
@ -17,6 +17,27 @@ namespace ircd
|
|||
template<> struct byte_view<string_view>;
|
||||
}
|
||||
|
||||
/// bytes -> string_view. A byte_view<string_view> is raw data of byte_view<T>.
|
||||
///
|
||||
/// This is an important specialization to take note of. When you see
|
||||
/// byte_view<string_view> know that another type's bytes are being represented
|
||||
/// by the string_view if that type is not string_view family itself.
|
||||
template<>
|
||||
struct ircd::byte_view<ircd::string_view>
|
||||
:string_view
|
||||
{
|
||||
template<class T,
|
||||
typename std::enable_if<!std::is_base_of<std::string_view, T>::value, int *>::type = nullptr>
|
||||
byte_view(const T &t)
|
||||
:string_view{reinterpret_cast<const char *>(&t), sizeof(T)}
|
||||
{}
|
||||
|
||||
/// string_view -> string_view (completeness)
|
||||
byte_view(const string_view &t = {})
|
||||
:string_view{t}
|
||||
{}
|
||||
};
|
||||
|
||||
/// string_view -> bytes
|
||||
template<class T>
|
||||
struct ircd::byte_view
|
||||
|
@ -41,24 +62,3 @@ struct ircd::byte_view
|
|||
:s{byte_view<string_view>{t}}
|
||||
{}
|
||||
};
|
||||
|
||||
/// bytes -> string_view. A byte_view<string_view> is raw data of byte_view<T>.
|
||||
///
|
||||
/// This is an important specialization to take note of. When you see
|
||||
/// byte_view<string_view> know that another type's bytes are being represented
|
||||
/// by the string_view if that type is not string_view family itself.
|
||||
template<>
|
||||
struct ircd::byte_view<ircd::string_view>
|
||||
:string_view
|
||||
{
|
||||
template<class T,
|
||||
typename std::enable_if<!std::is_base_of<std::string_view, T>::value, int *>::type = nullptr>
|
||||
byte_view(const T &t)
|
||||
:string_view{reinterpret_cast<const char *>(&t), sizeof(T)}
|
||||
{}
|
||||
|
||||
/// string_view -> string_view (completeness)
|
||||
byte_view(const string_view &t = {})
|
||||
:string_view{t}
|
||||
{}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue