0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 22:48:56 +02:00

ircd::byte_view: Rearrange class definition order for clang.

This commit is contained in:
Jason Volk 2019-06-21 03:37:53 -06:00
parent a8ebcbcbe0
commit a5a267dcd5

View file

@ -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}
{}
};