diff --git a/iceoryx2-ffi/cxx/include/iox/slice.hpp b/iceoryx2-ffi/cxx/include/iox/slice.hpp index 4b7cc4e04..961b9ba7d 100644 --- a/iceoryx2-ffi/cxx/include/iox/slice.hpp +++ b/iceoryx2-ffi/cxx/include/iox/slice.hpp @@ -28,7 +28,9 @@ class Slice { Slice(const T* data, uint64_t number_of_elements); + auto size() const -> uint64_t; auto number_of_elements() const -> uint64_t; + auto operator[](uint64_t n) const -> const T&; auto operator[](uint64_t n) -> T&; @@ -52,6 +54,11 @@ Slice::Slice(const T* data, uint64_t number_of_elements) , m_number_of_elements { number_of_elements } { } +template +auto Slice::size() const -> uint64_t { + return (sizeof(ValueType) * m_number_of_elements + alignof(ValueType) - 1) & ~(alignof(ValueType) - 1); +} + template auto Slice::number_of_elements() const -> uint64_t { return m_number_of_elements;