aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/span.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee/include/span.h')
-rw-r--r--contrib/epee/include/span.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/epee/include/span.h b/contrib/epee/include/span.h
index b1296a0b7..cfb5b1a17 100644
--- a/contrib/epee/include/span.h
+++ b/contrib/epee/include/span.h
@@ -163,4 +163,12 @@ namespace epee
static_assert(!has_padding<T>(), "source type may have padding");
return {reinterpret_cast<std::uint8_t*>(std::addressof(src)), sizeof(T)};
}
+
+ //! make a span from a std::string
+ template<typename T>
+ span<const T> strspan(const std::string &s) noexcept
+ {
+ static_assert(std::is_same<T, char>() || std::is_same<T, unsigned char>() || std::is_same<T, int8_t>() || std::is_same<T, uint8_t>(), "Unexpected type");
+ return {reinterpret_cast<const T*>(s.data()), s.size()};
+ }
}