LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
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... | |
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... | |
Static Public Member Functions | |
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).
Example:
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 |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
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 147 of file span.h.
|
inline |
Constructor: specifies the begin and end iterator and an adapter.
Definition at line 151 of file span.h.
|
inline |
Constructor: copies from another span (possibly with different types).
Definition at line 157 of file span.h.
References util::span().
|
default |
|
default |
|
inline |
|
inline |
Returns whether the span is empty (that is, no steps between them).
Definition at line 176 of file span.h.
References util::begin(), e, util::end(), and util::span().
|
inline |
Returns a copy of the end iterator.
Definition at line 170 of file span.h.
|
inlinestaticinherited |
Returns the begin iterator of the specified container.
Definition at line 28 of file span.h.
References util::begin().
Referenced by util::make_adapted_span(), util::make_span(), and util::make_transformed_span().
|
inlinestaticinherited |
Returns the constant begin iterator of the specified container.
Definition at line 52 of file span.h.
References util::cbegin().
Referenced by util::make_adapted_const_span(), and util::make_const_span().
|
inlinestaticinherited |
Returns the constant end iterator of the specified container.
Definition at line 60 of file span.h.
References util::cend().
Referenced by util::make_adapted_const_span(), and util::make_const_span().
|
inlinestaticinherited |
Returns the end iterator of the specified container.
Definition at line 36 of file span.h.
References util::end().
Referenced by util::make_adapted_span(), util::make_span(), and util::make_transformed_span().
|
default |
|
default |
|
inline |
Returns the size between begin and end, converted to std::size_t
.
Definition at line 173 of file span.h.
References util::begin(), and util::end().