SFCGAL 2.3.0
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
 Dereferenced.
using pointer = value_type *
 Pointer to value type.
using reference = value_type &
 Reference to value type.

Public Member Functions

 DereferenceIterator ()=default
 Default constructor.
 DereferenceIterator (BaseIterator other)
 Construct from a base iterator.
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.
auto operator* () const -> reference
 Dereference operator returning a reference to the pointed value.
auto operator-> () const -> pointer
 Member access operator returning a pointer to the pointed value.
auto operator[] (size_t idx) const -> reference
 Random access operator returning a reference to the nth value.

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

◆ pointer

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

Pointer to value type.

◆ reference

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

Reference to value type.

◆ value_type

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

Dereferenced.

Constructor & Destructor Documentation

◆ DereferenceIterator() [1/3]

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

Default constructor.

◆ DereferenceIterator() [2/3]

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

Construct from a base iterator.

Parameters
otherThe underlying base iterator.

◆ DereferenceIterator() [3/3]

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

◆ operator*()

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.

◆ operator->()

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.

◆ operator[]()

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.