diff --git a/libvisual/libvisual/lv_buffer.h b/libvisual/libvisual/lv_buffer.h index 8f6a3f72..9eca7b15 100644 --- a/libvisual/libvisual/lv_buffer.h +++ b/libvisual/libvisual/lv_buffer.h @@ -37,6 +37,7 @@ #include #include +#include #include namespace LV { @@ -88,6 +89,24 @@ namespace LV { */ void destroy_content (); + /** + * Returns an std::span that is a view of the entire buffer. + */ + template + std::span as_span () noexcept + { + return {static_cast (get_data ()), get_size () / sizeof (T)}; + } + + /** + * Returns an std::span that is a view of the entire buffer. + */ + template + std::span as_span () const noexcept + { + return {static_cast (get_data ()), get_size () / sizeof (T)}; + } + /** * Sets the data pair (data and its size). *