libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gbl::RandomAccessIterator< O, Index, Value, Reverse > Struct Template Reference

Public Types

using object_type = O
 
using iterator_type = RandomAccessIterator< O, Index, Value, Reverse >
 
using const_iterator_type = RandomAccessIterator< std::add_const_t< O >, Index, Value, Reverse >
 
using nonconst_iterator_type = RandomAccessIterator< std::remove_const_t< O >, Index, Value, Reverse >
 
using value_type = Value
 
using index_type = std::make_signed_t< Index >
 
using reference = std::conditional_t< std::is_const_v< O >, std::add_lvalue_reference_t< std::add_const_t< Value > >, std::add_lvalue_reference_t< Value > >
 
using const_reference = std::add_lvalue_reference_t< std::add_const_t< Value > >
 
using pointer = std::conditional_t< std::is_const_v< O >, std::add_pointer_t< std::add_const_t< Value > >, std::add_pointer_t< Value > >
 
using difference_type = std::ptrdiff_t
 
using iterator_concept = std::contiguous_iterator_tag
 
using iterator_category = std::contiguous_iterator_tag
 

Public Member Functions

void checkBounds (Index index) const
 
reference operator* ()
 
const_reference operator* () const
 
pointer operator& ()
 
iterator_typeoperator++ ()
 
iterator_type operator++ (int)
 
iterator_typeoperator-- ()
 
iterator_type operator-- (int)
 
iterator_typeoperator+= (index_type offset)
 
iterator_typeoperator-= (index_type offset)
 
iterator_type operator+ (const iterator_type &rhs) const
 
difference_type operator- (const iterator_type &rhs) const
 
reference operator[] (difference_type offset) const
 
bool operator== (const iterator_type &rhs) const
 
bool operator<= (const iterator_type &rhs) const
 
bool operator< (const iterator_type &rhs) const
 
bool operator> (const iterator_type &rhs) const
 
bool operator>= (const iterator_type &rhs) const
 
bool operator!= (const iterator_type &rhs) const
 
 RandomAccessIterator (const const_iterator_type &rhs)
 
 RandomAccessIterator (O &objType, index_type index=-1)
 
 RandomAccessIterator (const nonconst_iterator_type &rhs)
 

Data Fields

O * pObj_
 
index_type index_
 

Static Public Attributes

static constexpr bool reverse
 

Friends

iterator_type operator+ (const iterator_type &it, index_type offset)
 
iterator_type operator+ (index_type offset, const iterator_type &it)
 
iterator_type operator- (const iterator_type &it, index_type offset)
 

Detailed Description

template<typename O, typename Index, typename Value, bool Reverse>
struct gbl::RandomAccessIterator< O, Index, Value, Reverse >

Definition at line 109 of file gimbal_generics.hpp.

Member Typedef Documentation

◆ object_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::object_type = O

Definition at line 113 of file gimbal_generics.hpp.

◆ iterator_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::iterator_type = RandomAccessIterator<O, Index, Value, Reverse>

Definition at line 114 of file gimbal_generics.hpp.

◆ const_iterator_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::const_iterator_type = RandomAccessIterator<std::add_const_t<O>, Index, Value, Reverse>

Definition at line 115 of file gimbal_generics.hpp.

◆ nonconst_iterator_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::nonconst_iterator_type = RandomAccessIterator<std::remove_const_t<O>, Index, Value, Reverse>

Definition at line 116 of file gimbal_generics.hpp.

◆ value_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::value_type = Value

Definition at line 117 of file gimbal_generics.hpp.

◆ index_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::index_type = std::make_signed_t<Index>

Definition at line 118 of file gimbal_generics.hpp.

◆ reference

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::reference = std::conditional_t<std::is_const_v<O>, std::add_lvalue_reference_t<std::add_const_t<Value> >, std::add_lvalue_reference_t<Value> >

Definition at line 119 of file gimbal_generics.hpp.

◆ const_reference

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::const_reference = std::add_lvalue_reference_t<std::add_const_t<Value> >

Definition at line 122 of file gimbal_generics.hpp.

◆ pointer

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::pointer = std::conditional_t<std::is_const_v<O>, std::add_pointer_t<std::add_const_t<Value> >, std::add_pointer_t<Value> >

Definition at line 123 of file gimbal_generics.hpp.

◆ difference_type

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::difference_type = std::ptrdiff_t

Definition at line 126 of file gimbal_generics.hpp.

◆ iterator_concept

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::iterator_concept = std::contiguous_iterator_tag

Definition at line 127 of file gimbal_generics.hpp.

◆ iterator_category

template<typename O , typename Index , typename Value , bool Reverse>
using gbl::RandomAccessIterator< O, Index, Value, Reverse >::iterator_category = std::contiguous_iterator_tag

Definition at line 128 of file gimbal_generics.hpp.

Constructor & Destructor Documentation

◆ RandomAccessIterator() [1/3]

template<typename O , typename Index , typename Value , bool Reverse>
gbl::RandomAccessIterator< O, Index, Value, Reverse >::RandomAccessIterator ( const const_iterator_type rhs)
inline

Definition at line 202 of file gimbal_generics.hpp.

202 :
203 pObj_(rhs.pObj_), index_(rhs.index_) {}

◆ RandomAccessIterator() [2/3]

template<typename O , typename Index , typename Value , bool Reverse>
gbl::RandomAccessIterator< O, Index, Value, Reverse >::RandomAccessIterator ( O objType,
index_type  index = -1 
)
inline

Definition at line 205 of file gimbal_generics.hpp.

205 :
206 pObj_(&objType), index_(index) {}

◆ RandomAccessIterator() [3/3]

template<typename O , typename Index , typename Value , bool Reverse>
gbl::RandomAccessIterator< O, Index, Value, Reverse >::RandomAccessIterator ( const nonconst_iterator_type rhs)
inline

Definition at line 208 of file gimbal_generics.hpp.

208 :
209 RandomAccessIterator(*rhs.pObj_, rhs.index_) {}

Member Function Documentation

◆ checkBounds()

template<typename O , typename Index , typename Value , bool Reverse>
void gbl::RandomAccessIterator< O, Index, Value, Reverse >::checkBounds ( Index  index) const
inline

Definition at line 130 of file gimbal_generics.hpp.

130 {
131 if(index >= pObj_->getElementCount_()) throw std::out_of_range{"Index >= obj.elementCount"};
132 }

◆ operator*() [1/2]

template<typename O , typename Index , typename Value , bool Reverse>
reference gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator* ( )
inline

Definition at line 142 of file gimbal_generics.hpp.

142 {
143 checkBounds(index_);
144 return pObj_->getElement_(index_);
145 }

◆ operator*() [2/2]

template<typename O , typename Index , typename Value , bool Reverse>
const_reference gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator* ( ) const
inline

Definition at line 147 of file gimbal_generics.hpp.

147 {
148 checkBounds(index_);
149 return const_cast<const O*>(pObj_)->getElement_(index_);
150 }

◆ operator&()

template<typename O , typename Index , typename Value , bool Reverse>
pointer gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator& ( )
inline

Definition at line 152 of file gimbal_generics.hpp.

152 {
153 checkBounds(index_);
154 return &pObj_->getElement_(index_);
155 }

◆ operator++() [1/2]

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type & gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator++ ( )
inline

Definition at line 157 of file gimbal_generics.hpp.

157 {
158 if constexpr(Reverse) --index_;
159 else ++index_ ;
160 return *this;
161 }

◆ operator++() [2/2]

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator++ ( int  )
inline

Definition at line 162 of file gimbal_generics.hpp.

162 {
163 const auto temp(*this);
164 if constexpr(Reverse) --*this;
165 else ++*this;
166 return temp;
167 }

◆ operator--() [1/2]

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type & gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator-- ( )
inline

Definition at line 168 of file gimbal_generics.hpp.

168 {
169 if constexpr(Reverse) ++index_;
170 else --index_;
171 return *this;
172 }

◆ operator--() [2/2]

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator-- ( int  )
inline

Definition at line 173 of file gimbal_generics.hpp.

173 {
174 const auto temp(*this);
175 if constexpr(Reverse) ++*this;
176 else --*this;
177 return temp;
178 }

◆ operator+=()

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type & gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator+= ( index_type  offset)
inline

Definition at line 179 of file gimbal_generics.hpp.

179{ if constexpr(Reverse) index_ -= offset; else index_ += offset; return *this; }

◆ operator-=()

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type & gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator-= ( index_type  offset)
inline

Definition at line 180 of file gimbal_generics.hpp.

180{ if constexpr(Reverse) index_ += offset; else index_ -= offset; return *this; }

◆ operator+()

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator+ ( const iterator_type rhs) const
inline

Definition at line 185 of file gimbal_generics.hpp.

185{ if constexpr(!Reverse) return *this + rhs.index_; else return *this - rhs.index_; }

◆ operator-()

template<typename O , typename Index , typename Value , bool Reverse>
difference_type gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator- ( const iterator_type rhs) const
inline

Definition at line 187 of file gimbal_generics.hpp.

187{ auto temp(*this); temp.index_ -= rhs.index_; return temp.index_; }

◆ operator[]()

template<typename O , typename Index , typename Value , bool Reverse>
reference gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator[] ( difference_type  offset) const
inline

Definition at line 189 of file gimbal_generics.hpp.

189 {
190 return pObj_->getElement_(index_ + offset);
191 }

◆ operator==()

template<typename O , typename Index , typename Value , bool Reverse>
bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator== ( const iterator_type rhs) const
inline

Definition at line 193 of file gimbal_generics.hpp.

193{ return pObj_ == pObj_ && index_ == rhs.index_; }

◆ operator<=()

template<typename O , typename Index , typename Value , bool Reverse>
bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator<= ( const iterator_type rhs) const
inline

Definition at line 194 of file gimbal_generics.hpp.

194{ return pObj_ == rhs.pObj_ && index_ <= rhs.index_; }

◆ operator<()

template<typename O , typename Index , typename Value , bool Reverse>
bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator< ( const iterator_type rhs) const
inline

Definition at line 195 of file gimbal_generics.hpp.

195{ return pObj_ == rhs.pObj_ && index_ < rhs.index_; }

◆ operator>()

template<typename O , typename Index , typename Value , bool Reverse>
bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator> ( const iterator_type rhs) const
inline

Definition at line 196 of file gimbal_generics.hpp.

196{ return pObj_ == rhs.pObj_ && index_ > rhs.index_; }

◆ operator>=()

template<typename O , typename Index , typename Value , bool Reverse>
bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator>= ( const iterator_type rhs) const
inline

Definition at line 197 of file gimbal_generics.hpp.

197{ return pObj_ == rhs.pObj_ && index_ >= rhs.index_; }

◆ operator!=()

template<typename O , typename Index , typename Value , bool Reverse>
bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::operator!= ( const iterator_type rhs) const
inline

Definition at line 198 of file gimbal_generics.hpp.

198{ return !(*this == rhs); }

Friends And Related Symbol Documentation

◆ operator+ [1/2]

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type operator+ ( const iterator_type it,
index_type  offset 
)
friend

Definition at line 182 of file gimbal_generics.hpp.

182{ auto temp(it); if constexpr(Reverse) temp.index_ -= offset; else temp.index_ += offset; return temp; }

◆ operator+ [2/2]

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type operator+ ( index_type  offset,
const iterator_type it 
)
friend

Definition at line 183 of file gimbal_generics.hpp.

183{ if constexpr(!Reverse) return it + offset; else return it - offset; }

◆ operator-

template<typename O , typename Index , typename Value , bool Reverse>
iterator_type operator- ( const iterator_type it,
index_type  offset 
)
friend

Definition at line 184 of file gimbal_generics.hpp.

184{ auto temp(it); if constexpr(Reverse) temp.index_ += offset; else temp.index_ -= offset; return temp; }

Field Documentation

◆ reverse

template<typename O , typename Index , typename Value , bool Reverse>
constexpr bool gbl::RandomAccessIterator< O, Index, Value, Reverse >::reverse
inlinestaticconstexpr

Definition at line 112 of file gimbal_generics.hpp.

◆ pObj_

Definition at line 211 of file gimbal_generics.hpp.

◆ index_

template<typename O , typename Index , typename Value , bool Reverse>
index_type gbl::RandomAccessIterator< O, Index, Value, Reverse >::index_

Definition at line 212 of file gimbal_generics.hpp.


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