Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Diff: Utilities/span.hpp
- Revision:
- 7:471901a04573
- Parent:
- 6:a8c83a2e6fa4
--- a/Utilities/span.hpp Wed Jan 23 13:11:04 2019 -0600 +++ b/Utilities/span.hpp Mon Mar 04 08:10:00 2019 -0600 @@ -77,6 +77,7 @@ public: /// @name Iterators /// @{ + iterator begin() const { return const_cast<iterator>(static_cast<const span_base &>(*this).cbegin()); } @@ -100,19 +101,23 @@ const_reverse_iterator crend() const { return const_reverse_iterator(cbegin()); } + /// @} /// @name Element access /// @{ + reference operator[](index_type idx) const { return data()[idx]; } reference operator()(index_type idx) const { return operator[](idx); } pointer data() const { return data_; } + /// @} /// @name Subviews /// @{ + template <index_type Count> span<element_type, Count> first() const { return subspan<0, Count>(); } @@ -133,6 +138,7 @@ return span<element_type>( data() + Offset, Count == dynamic_extent ? size() - Offset : Count); } + /// @} private: @@ -185,18 +191,22 @@ /// @name Observers /// @{ + static index_type size() { return extent; } static index_type size_bytes() { return size() * sizeof(element_type); } static bool empty() { return size() == 0; } + /// @} /// @name Subviews /// @{ + template <index_type Count> span<element_type, Count> last() const { return this->template subspan<extent - Count, Count>(); } + /// @} }; @@ -246,18 +256,22 @@ /// @name Observers /// @{ + index_type size() const { return size_; } index_type size_bytes() const { return size() * sizeof(element_type); } bool empty() const { return size() == 0; } + /// @} /// @name Subviews /// @{ + template <index_type Count> span<element_type, Count> last() const { return span<element_type, Count>(this->data() + (size() - Count), Count); } + /// @} private: