Library of Assembled Shared Sources
lass::python::FreeRangeView< SelfType, ValueType, GetIterator > Class Template Reference

View that adapts free iterator accessors to a PyIteratorRange. More...

#include <pyiteratorrange.h>

Related Symbols

(Note that these are not member symbols.)

template<typename T, typename GetIterator>
auto makeMemberRangeViewFactory (GetIterator begin, GetIterator end)
 Returns a callable creating a MemberRangeView iterating over (self->*begin)() to (self->*end)()
 
template<typename T, typename GetIterator>
auto makeFreeRangeView (const ShadoweePtr< T > &self, GetIterator begin, GetIterator end)
 Returns a FreeRangeView iterating over begin(*self) and end(*self)
 
template<typename T, typename GetIterator>
auto makeFreeRangeViewFactory (GetIterator begin, GetIterator end)
 Returns a callable creating a FreeRangeView iterating over begin(*self) and end(*self)
 

Detailed Description

template<typename SelfType, typename ValueType, typename GetIterator>
class lass::python::FreeRangeView< SelfType, ValueType, GetIterator >

View that adapts free iterator accessors to a PyIteratorRange.

FreeRangeView holds a ShadoweePtr to the container, and obtains the iterator pair by calling the supplied free-callable accessors begin(*self) and end(*self) when iter() is invoked.

iter() produces a PyIteratorRange and sets self as its owner, keeping the container alive for the duration of the iteration.

The main benefit of returning a FreeRangeView over a plain PyIteratorRange is that it correctly types the iterator's value type in the generated Python stubs as ValueType, in contrast to the generic Any type used by PyIteratorRange.

Template Parameters
SelfTypeC++ container type
ValueTypeElement type returned by the container's iterators
GetIteratorFunction type of the free-callable iterator accessors; expected to accept a reference to the container as sole argument and return an iterator.

Definition at line 416 of file pyiteratorrange.h.


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