We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 836da7b commit 662f7efCopy full SHA for 662f7ef
libvisual/libvisual/lv_buffer.h
@@ -37,6 +37,7 @@
37
38
#include <libvisual/lv_intrusive_ptr.hpp>
39
#include <memory>
40
+#include <span>
41
#include <cstdlib>
42
43
namespace LV {
@@ -88,6 +89,24 @@ namespace LV {
88
89
*/
90
void destroy_content ();
91
92
+ /**
93
+ * Returns an std::span that is a view of the entire buffer.
94
+ */
95
+ template <typename T>
96
+ std::span<T> as_span () noexcept
97
+ {
98
+ return {static_cast<T*> (get_data ()), get_size () / sizeof (T)};
99
+ }
100
+
101
102
103
104
105
+ std::span<T const> as_span () const noexcept
106
107
+ return {static_cast<T const*> (get_data ()), get_size () / sizeof (T)};
108
109
110
/**
111
* Sets the data pair (data and its size).
112
*
0 commit comments