Simple class with a begin and an end. More...
#include <span.h>
Public Types | |
using | begin_iterator = BIter |
Type of begin iterator. More... | |
using | end_iterator = EIter |
Type of end iterator. More... | |
using | span_t = span< begin_iterator, end_iterator > |
Type of this class. More... | |
using | pair_t = std::pair< begin_iterator, end_iterator > |
Type of iterator pair. More... | |
using | value_type = typename begin_iterator::value_type |
Type of values pointed by the iterators. More... | |
using | reference = typename begin_iterator::reference |
Type of reference pointed by the iterators. More... | |
Public Types inherited from util::span_base | |
template<typename Cont > | |
using | get_begin_iterator = std::decay_t< decltype(get_begin(std::declval< Cont >()))> |
Type of begin iterator of Cont type. More... | |
template<typename Cont > | |
using | get_end_iterator = std::decay_t< decltype(get_end(std::declval< Cont >()))> |
Type of end iterator of Cont type. More... | |
template<typename Cont > | |
using | get_cbegin_iterator = std::decay_t< decltype(get_cbegin(std::declval< Cont >()))> |
Type of constant begin iterator of Cont type. More... | |
template<typename Cont > | |
using | get_cend_iterator = std::decay_t< decltype(get_cend(std::declval< Cont >()))> |
Type of constant end iterator of Cont type. More... | |
Public Member Functions | |
span (begin_iterator b, end_iterator e) | |
Constructor: specifies the begin and end iterator. More... | |
template<typename SrcIterB , typename SrcIterE , typename Adaptor > | |
span (SrcIterB &&b, SrcIterE &&e, Adaptor &&adaptor) | |
Constructor: specifies the begin and end iterator and an adapter. More... | |
template<typename OBIter , typename OEIter > | |
span (span< OBIter, OEIter > const &from) | |
Constructor: copies from another span (possibly with different types). More... | |
span (span_t const &)=default | |
span (span_t &&)=default | |
span_t & | operator= (span_t const &)=default |
span_t & | operator= (span_t &&)=default |
begin_iterator | begin () const |
Returns a copy of the begin iterator. More... | |
end_iterator | end () const |
Returns a copy of the end iterator. More... | |
std::size_t | size () const |
Returns the size between begin and end, converted to std::size_t . More... | |
bool | empty () const |
Returns whether the span is empty (that is, no steps between them). More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from util::span_base | |
template<typename Cont > | |
static decltype(auto) | get_begin (Cont &cont) |
Returns the begin iterator of the specified container. More... | |
template<typename Cont > | |
static decltype(auto) | get_end (Cont &cont) |
Returns the end iterator of the specified container. More... | |
template<typename Cont > | |
static decltype(auto) | get_cbegin (Cont &cont) |
Returns the constant begin iterator of the specified container. More... | |
template<typename Cont > | |
static decltype(auto) | get_cend (Cont &cont) |
Returns the constant end iterator of the specified container. More... | |
Simple class with a begin and an end.
BITER | type of begin iterator |
EITER | type of end iterator (default: as BITER ) |
This class is a glorified pair of iterators which can be used in a range-for loop. All input iterators are accepted.
It is probably going to be redundant with the advent of C++20 and its span and/or range libraries (if the latter is ever going to happen).
The call to analyse()
will produce output like:
The convenience of this class, not evident from the example, is the beginning and end of the span can be passed around as a single object, with the added bonus of a (very reduced) collection interface.
const span
object does not guarantee unmutable access to the iterated data. using util::span< BIter, EIter >::begin_iterator = BIter |
using util::span< BIter, EIter >::end_iterator = EIter |
using util::span< BIter, EIter >::pair_t = std::pair<begin_iterator, end_iterator> |
using util::span< BIter, EIter >::reference = typename begin_iterator::reference |
using util::span< BIter, EIter >::span_t = span<begin_iterator, end_iterator> |
using util::span< BIter, EIter >::value_type = typename begin_iterator::value_type |
|
inline |
Constructor: specifies the begin and end iterator.
Definition at line 143 of file span.h.
|
inline |
Constructor: specifies the begin and end iterator and an adapter.
Definition at line 147 of file span.h.
|
inline |
Constructor: copies from another span (possibly with different types).
Definition at line 154 of file span.h.
|
default |
|
default |
|
inline |
|
inline |
Returns whether the span is empty (that is, no steps between them).
Definition at line 173 of file span.h.
|
inline |
Returns a copy of the end iterator.
Definition at line 167 of file span.h.
|
default |
|
default |
|
inline |
Returns the size between begin and end, converted to std::size_t
.
Definition at line 170 of file span.h.