SFCGAL  2.3.0
Public Types | Public Member Functions | List of all members
SFCGAL::DereferenceIterator< BaseIterator > Class Template Reference

Iterator adapter that dereferences unique_ptr elements automatically. More...

#include <DereferenceIterator.h>

Inheritance diagram for SFCGAL::DereferenceIterator< BaseIterator >:

Public Types

using value_type = typename BaseIterator::value_type::element_type
 Dereferenced. More...
 
using pointer = value_type *
 Pointer to value type. More...
 
using reference = value_type &
 Reference to value type. More...
 

Public Member Functions

 DereferenceIterator ()=default
 Default constructor. More...
 
 DereferenceIterator (BaseIterator other)
 Construct from a base iterator. More...
 
template<typename OtherIterator , typename = std::enable_if_t< std::is_convertible_v<OtherIterator, BaseIterator>>>
 DereferenceIterator (const DereferenceIterator< OtherIterator > &other)
 Conversion constructor from another compatible DereferenceIterator. More...
 
auto operator* () const -> reference
 Dereference operator returning a reference to the pointed value. More...
 
auto operator-> () const -> pointer
 Member access operator returning a pointer to the pointed value. More...
 
auto operator[] (size_t idx) const -> reference
 Random access operator returning a reference to the nth value. More...
 

Detailed Description

template<class BaseIterator>
class SFCGAL::DereferenceIterator< BaseIterator >

Iterator adapter that dereferences unique_ptr elements automatically.

This class wraps a base iterator (e.g., std::vector<std::unique_ptr<T>>::iterator) and returns references to the pointed objects instead of unique_ptrs.

Template Parameters
BaseIteratorthe underlying iterator type

Member Typedef Documentation

template<class BaseIterator >
using SFCGAL::DereferenceIterator< BaseIterator >::pointer = value_type *

Pointer to value type.

template<class BaseIterator >
using SFCGAL::DereferenceIterator< BaseIterator >::reference = value_type &

Reference to value type.

template<class BaseIterator >
using SFCGAL::DereferenceIterator< BaseIterator >::value_type = typename BaseIterator::value_type::element_type

Dereferenced.

Constructor & Destructor Documentation

template<class BaseIterator >
SFCGAL::DereferenceIterator< BaseIterator >::DereferenceIterator ( )
default

Default constructor.

template<class BaseIterator >
SFCGAL::DereferenceIterator< BaseIterator >::DereferenceIterator ( BaseIterator  other)
inlineexplicit

Construct from a base iterator.

Parameters
otherThe underlying base iterator.
template<class BaseIterator >
template<typename OtherIterator , typename = std::enable_if_t< std::is_convertible_v<OtherIterator, BaseIterator>>>
SFCGAL::DereferenceIterator< BaseIterator >::DereferenceIterator ( const DereferenceIterator< OtherIterator > &  other)
inline

Conversion constructor from another compatible DereferenceIterator.

Allows implicit conversion from DereferenceIterator<iterator> to DereferenceIterator<const_iterator>.

Template Parameters
OtherIteratorAnother iterator type convertible to BaseIterator.
Parameters
otherThe other DereferenceIterator to copy.

Member Function Documentation

template<class BaseIterator >
auto SFCGAL::DereferenceIterator< BaseIterator >::operator* ( ) const -> reference
inline

Dereference operator returning a reference to the pointed value.

Returns
Reference to the object pointed by the current iterator.
template<class BaseIterator >
auto SFCGAL::DereferenceIterator< BaseIterator >::operator-> ( ) const -> pointer
inline

Member access operator returning a pointer to the pointed value.

Returns
Pointer to the object pointed by the current iterator.
template<class BaseIterator >
auto SFCGAL::DereferenceIterator< BaseIterator >::operator[] ( size_t  idx) const -> reference
inline

Random access operator returning a reference to the nth value.

Parameters
idxThe offset from the current iterator position.
Returns
Reference to the nth object from the current iterator.