add: [imp] comments

This commit is contained in:
mutouyun 2022-10-29 19:46:39 +08:00
parent 0e66c9a9bd
commit 2dd85adc52

View File

@ -217,12 +217,19 @@ bool operator==(span<T> a, span<U> b) noexcept {
return true;
}
/// @brief Converts a span into a view of its underlying bytes.
/// @see https://en.cppreference.com/w/cpp/container/span/as_bytes
template <typename T,
typename Byte = typename std::conditional<std::is_const<T>::value, std::uint8_t const, std::uint8_t>::type>
auto as_bytes(span<T> s) noexcept -> span<Byte> {
return {reinterpret_cast<Byte *>(s.data()), s.size_bytes()};
}
/// @brief Constructs an object of type T and wraps it in a span.
/// Before C++17, template argument deduction for class templates was not supported.
/// @see https://en.cppreference.com/w/cpp/language/template_argument_deduction
template <typename T>
auto make_span(T *arr, std::size_t count) noexcept -> span<T> {
return {arr, count};