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

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

#include <pyiteratorrange.h>

Related Symbols

(Note that these are not member symbols.)

template<typename T, typename GetIterator>
auto makeMemberRangeView (const ShadoweePtr< T > &self, GetIterator begin, GetIterator end)
 Returns a MemberRangeView iterating over (self->*begin)() and (self->*end)()
 

Detailed Description

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

View that adapts member iterator accessors to a PyIteratorRange.

MemberRangeView holds a ShadoweePtr to the container, and obtains the iterator pair by calling the supplied member accessors (self->*begin)() and (self->*end)() 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 MemberRangeView 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 member iterator accessors.

Definition at line 315 of file pyiteratorrange.h.


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