|
| TfSpan () noexcept=default |
|
| TfSpan (pointer ptr, index_type count) |
|
| TfSpan (pointer first, pointer last) |
| Construct a span over the range [first, last). More...
|
|
template<class Container > |
| TfSpan (Container &cont, typename std::enable_if< !std::is_const< element_type >::value &&std::is_same< typename Container::value_type, value_type >::value, Container >::type *=0) |
|
template<class Container > |
| TfSpan (const Container &cont, typename std::enable_if< std::is_same< typename Container::value_type, value_type >::value, Container >::type *=0) |
|
pointer | data () const noexcept |
| Return a pointer to the first element of the span. More...
|
|
index_type | size () const noexcept |
| Return the total number of elements in the span. More...
|
|
bool | empty () const noexcept |
| Returns true if this span contains no elements, false otherwise. More...
|
|
reference | operator[] (index_type idx) const |
|
reference | front () const |
| Return a reference to the first element in the span. More...
|
|
reference | back () const |
| Return a reference to the last element in the span. More...
|
|
iterator | begin () const noexcept |
| Returns a non-const iterator the start of the span. More...
|
|
const_iterator | cbegin () const noexcept |
| Returns a cons iterator to the start of the span. More...
|
|
iterator | end () const noexcept |
| Returns a non-const iterator to the end of the span. More...
|
|
const_iterator | cend () const noexcept |
| Returns a const iterator to the end of the span. More...
|
|
reverse_iterator | rbegin () const noexcept |
| Returns a non-const reverse iterator the start of the span. More...
|
|
const_reverse_iterator | crbegin () const noexcept |
| Returns a cons reverse iterator to the start of the span. More...
|
|
reverse_iterator | rend () const noexcept |
| Returns a non-const reverse iterator to the end of the span. More...
|
|
const_reverse_iterator | crend () const noexcept |
| Returns a const reverse iterator to the end of the span. More...
|
|
TfSpan< T > | subspan (difference_type offset, difference_type count=-1) const |
|
TfSpan< T > | first (size_t count) const |
| Return a subspan consisting of the first count elements of this span. More...
|
|
TfSpan< T > | last (size_t count) const |
| Return a subspan consisting of the last count elements of this span. More...
|
|
template<typename T>
class TfSpan< T >
Represents a range of contiguous elements.
This simply pairs a pointer with a size, while adding a common array interface.
A span allows ranges of elements to be referenced in a container-neutral manner. While it is possible to achieve that effect by simply passing around raw pointers, a span has the advantage of carrying around additional size information, both enabling use of common array patterns, as well as providing sufficient information to perform boundary tests.
A TfSpan is implicitly convertible from common array types, as well as from other spans, but preserves const-ness:
const std::vector<int>
data;
const std::vector<int>
data;
Helper methods TfMakeSpan and TfMakeConstSpan are also provided to enable auto-typing when constructing spans:
Spans do not own the data they reference. It is up to the user of the span to ensure that the underlying data is not destructed while the span is in use.
This is modelled after std::span (C++20), but does not currently include any specialization for static extents.
Definition at line 87 of file span.h.