File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 3737
3838#include < libvisual/lv_intrusive_ptr.hpp>
3939#include < memory>
40+ #include < span>
4041#include < cstdlib>
4142
4243namespace LV {
@@ -88,6 +89,24 @@ namespace LV {
8889 */
8990 void destroy_content ();
9091
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+ * Returns an std::span that is a view of the entire buffer.
103+ */
104+ template <typename T>
105+ std::span<T const > as_span () const noexcept
106+ {
107+ return {static_cast <T const *> (get_data ()), get_size () / sizeof (T)};
108+ }
109+
91110 /* *
92111 * Sets the data pair (data and its size).
93112 *
You can’t perform that action at this time.
0 commit comments