LDMX Software
acts_examples::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 acts_examples::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 indx : makeRange(std::equal_range(...)) {
    ...
}

Definition at line 27 of file Range.h.

Constructor & Destructor Documentation

◆ Range()

template<typename Iterator >
acts_examples::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 acts_examples::Range< Iterator >::begin ( ) const
inline

Definition at line 36 of file Range.h.

36{ return m_begin_; }

◆ empty()

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

Definition at line 38 of file Range.h.

38{ return m_begin_ == m_end_; }

◆ end()

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

Definition at line 37 of file Range.h.

37{ return m_end_; }

◆ size()

template<typename Iterator >
std::size_t acts_examples::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 acts_examples::Range< Iterator >::m_begin_
private

Definition at line 42 of file Range.h.

◆ m_end_

template<typename Iterator >
Iterator acts_examples::Range< Iterator >::m_end_
private

Definition at line 43 of file Range.h.


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