kblib 0.2.3
General utilities library for modern C++
kblib::counting_back_insert_iterator< Container > Class Template Reference

Like a std::back_insert_iterator, but it keeps track of how many insertions it has made, allowing an end iterator to be created. More...

#include <kblib/iterators.h>

Classes

struct  proxy_iterator
 

Public Types

using value_type = void
 
using difference_type = std::ptrdiff_t
 
using pointer = void
 
using reference = void
 
using iterator_category = std::output_iterator_tag
 

Public Member Functions

 counting_back_insert_iterator () noexcept=default
 
 counting_back_insert_iterator (Container &c, std::size_t n=0)
 
 counting_back_insert_iterator (std::size_t n)
 
auto operator* () noexcept -> proxy_iterator
 
auto operator++ () &noexcept -> counting_back_insert_iterator &
 
auto operator++ (int) noexcept -> counting_back_insert_iterator=delete
 

Protected Attributes

Container * container = nullptr
 
std::size_t count = 0
 
bool dirty = true
 

Friends

auto operator== (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> bool
 
auto operator!= (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> bool
 
auto operator< (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> bool
 
auto operator<= (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> bool
 
auto operator> (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> bool
 
auto operator>= (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> bool
 
auto operator- (const counting_back_insert_iterator &a, const counting_back_insert_iterator &b) noexcept -> std::ptrdiff_t
 

Detailed Description

template<typename Container>
class kblib::counting_back_insert_iterator< Container >

Like a std::back_insert_iterator, but it keeps track of how many insertions it has made, allowing an end iterator to be created.

Attention
This iterator must be incremented and dereferenced exactly once for each assignment, in order to maintain the accuracy of the counter.

Definition at line 107 of file iterators.h.

Member Typedef Documentation

◆ difference_type

template<typename Container >
using kblib::counting_back_insert_iterator< Container >::difference_type = std::ptrdiff_t

Definition at line 110 of file iterators.h.

◆ iterator_category

template<typename Container >
using kblib::counting_back_insert_iterator< Container >::iterator_category = std::output_iterator_tag

Definition at line 113 of file iterators.h.

◆ pointer

template<typename Container >
using kblib::counting_back_insert_iterator< Container >::pointer = void

Definition at line 111 of file iterators.h.

◆ reference

template<typename Container >
using kblib::counting_back_insert_iterator< Container >::reference = void

Definition at line 112 of file iterators.h.

◆ value_type

template<typename Container >
using kblib::counting_back_insert_iterator< Container >::value_type = void

Definition at line 109 of file iterators.h.

Constructor & Destructor Documentation

◆ counting_back_insert_iterator() [1/3]

template<typename Container >
kblib::counting_back_insert_iterator< Container >::counting_back_insert_iterator ( )
defaultnoexcept

◆ counting_back_insert_iterator() [2/3]

template<typename Container >
kblib::counting_back_insert_iterator< Container >::counting_back_insert_iterator ( Container &  c,
std::size_t  n = 0 
)
inlineexplicit

Definition at line 116 of file iterators.h.

◆ counting_back_insert_iterator() [3/3]

template<typename Container >
kblib::counting_back_insert_iterator< Container >::counting_back_insert_iterator ( std::size_t  n)
inlineexplicit

Definition at line 119 of file iterators.h.

Member Function Documentation

◆ operator*()

template<typename Container >
auto kblib::counting_back_insert_iterator< Container >::operator* ( ) -> proxy_iterator
inlinenoexcept

Definition at line 147 of file iterators.h.

◆ operator++() [1/2]

template<typename Container >
auto kblib::counting_back_insert_iterator< Container >::operator++ ( ) & -> counting_back_insert_iterator&
inlinenoexcept

Definition at line 152 of file iterators.h.

◆ operator++() [2/2]

template<typename Container >
auto kblib::counting_back_insert_iterator< Container >::operator++ ( int  ) -> counting_back_insert_iterator=delete
deletenoexcept

Friends And Related Function Documentation

◆ operator!=

template<typename Container >
auto operator!= ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> bool
friend

Definition at line 165 of file iterators.h.

◆ operator-

template<typename Container >
auto operator- ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> std::ptrdiff_t
friend

Definition at line 190 of file iterators.h.

◆ operator<

template<typename Container >
auto operator< ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> bool
friend

Definition at line 170 of file iterators.h.

◆ operator<=

template<typename Container >
auto operator<= ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> bool
friend

Definition at line 175 of file iterators.h.

◆ operator==

template<typename Container >
auto operator== ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> bool
friend

Definition at line 160 of file iterators.h.

◆ operator>

template<typename Container >
auto operator> ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> bool
friend

Definition at line 180 of file iterators.h.

◆ operator>=

template<typename Container >
auto operator>= ( const counting_back_insert_iterator< Container > &  a,
const counting_back_insert_iterator< Container > &  b 
) -> bool
friend

Definition at line 185 of file iterators.h.

Member Data Documentation

◆ container

template<typename Container >
Container* kblib::counting_back_insert_iterator< Container >::container = nullptr
protected

Definition at line 197 of file iterators.h.

◆ count

template<typename Container >
std::size_t kblib::counting_back_insert_iterator< Container >::count = 0
protected

Definition at line 198 of file iterators.h.

◆ dirty

template<typename Container >
bool kblib::counting_back_insert_iterator< Container >::dirty = true
protected

Definition at line 199 of file iterators.h.


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