Skip to content

Commit

Permalink
Add specific bytes::make_span for GSL 3.0.0
Browse files Browse the repository at this point in the history
Because it is no longer possible to call gsl::make_span on gsl::span.
  • Loading branch information
mymedia2 authored and john-preston committed Apr 28, 2020
1 parent b61b9d2 commit d27c3e3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions base/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ template <gsl::index Size>
using array = std::array<type, Size>;

inline span make_detached_span(QByteArray &container) {
return gsl::as_writeable_bytes(gsl::make_span(container));
return gsl::as_writable_bytes(gsl::make_span(container));
}

template <
Expand All @@ -32,17 +32,26 @@ template <
!std::is_const_v<Container>
&& !std::is_same_v<Container, QByteArray>>>
inline span make_span(Container &container) {
return gsl::as_writeable_bytes(gsl::make_span(container));
return gsl::as_writable_bytes(gsl::make_span(container));
}

template<>
inline span make_span<span, void>(span &container) {
return container;
}

template <typename Container>
inline const_span make_span(const Container &container) {
return gsl::as_bytes(gsl::make_span(container));
}

inline const_span make_span(const_span &container) {
return container;
}

template <typename Type, std::ptrdiff_t Extent>
inline span make_span(gsl::span<Type, Extent> container) {
return gsl::as_writeable_bytes(container);
return gsl::as_writable_bytes(container);
}

template <typename Type, std::ptrdiff_t Extent>
Expand All @@ -52,7 +61,7 @@ inline const_span make_span(gsl::span<const Type, Extent> container) {

template <typename Type>
inline span make_span(Type *value, std::size_t count) {
return gsl::as_writeable_bytes(gsl::make_span(value, count));
return gsl::as_writable_bytes(gsl::make_span(value, count));
}

template <typename Type>
Expand Down

0 comments on commit d27c3e3

Please sign in to comment.