LDMX Software
Public Member Functions | Private Attributes | List of all members
ActsExamples::Range< Iterator > Class Template Reference

A wrapper around a pair of iterators to simplify range-based loops. More...

#include <Range.h>

Public Member Functions

 Range (Iterator b, Iterator e)
 
 Range (Range &&)=default
 
 Range (const Range &)=default
 
Rangeoperator= (Range &&)=default
 
Rangeoperator= (const Range &)=default
 
Iterator begin () const
 
Iterator end () const
 
bool empty () const
 
std::size_t size () const
 

Private Attributes

Iterator m_begin
 
Iterator m_end
 

Detailed Description

template<typename Iterator>
class ActsExamples::Range< Iterator >

A wrapper around a pair of iterators to simplify range-based loops.

Some standard library algorithms return pairs of iterators to identify a sub-range. This wrapper simplifies the iteration and should be used as follows:

for (auto x : makeRange(std::equal_range(...)) {
    ...
}

Definition at line 27 of file Range.h.

Constructor & Destructor Documentation

◆ Range()

template<typename Iterator >
ActsExamples::Range< Iterator >::Range ( Iterator  b,
Iterator  e 
)
inline

Definition at line 29 of file Range.h.

29: m_begin(b), m_end(e) {}

Member Function Documentation

◆ begin()

template<typename Iterator >
Iterator ActsExamples::Range< Iterator >::begin ( ) const
inline

Definition at line 36 of file Range.h.

36{ return m_begin; }

◆ empty()

template<typename Iterator >
bool ActsExamples::Range< Iterator >::empty ( ) const
inline

Definition at line 38 of file Range.h.

38{ return m_begin == m_end; }

◆ end()

template<typename Iterator >
Iterator ActsExamples::Range< Iterator >::end ( ) const
inline

Definition at line 37 of file Range.h.

37{ return m_end; }

◆ size()

template<typename Iterator >
std::size_t ActsExamples::Range< Iterator >::size ( ) const
inline

Definition at line 39 of file Range.h.

39{ return std::distance(m_begin, m_end); }

Member Data Documentation

◆ m_begin

template<typename Iterator >
Iterator ActsExamples::Range< Iterator >::m_begin
private

Definition at line 42 of file Range.h.

◆ m_end

template<typename Iterator >
Iterator ActsExamples::Range< Iterator >::m_end
private

Definition at line 43 of file Range.h.


The documentation for this class was generated from the following file: