MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
marley::IteratorToPointerMember< It, R > Class Template Reference

Template class that creates an iterator to a class member based on an iterator to a pointer (either bare or smart) to the class object. More...

#include <IteratorToPointerMember.hh>

Public Types

typedef std::iterator_traits< It >::difference_type difference_type
 
typedef std::iterator_traits< It >::iterator_category iterator_category
 
typedef R * pointer
 
typedef R & reference
 
typedef std::remove_reference< decltype(*std::declval< T_pointer >)) >::type T
 Type of the target of the pointer pointed to by the original iterator. More...
 
typedef std::iterator_traits< It >::value_type T_pointer
 Type of the pointer pointed to by the original iterator.
 
typedef R value_type
 

Public Member Functions

 IteratorToPointerMember (It from, R T::*memptr)
 Construction from an iterator and a pointer to member. More...
 
bool operator!= (const IteratorToPointerMember< It, R > &rhs) const
 
virtual reference operator* () const
 
IteratorToPointerMember operator+ (difference_type n) const
 
IteratorToPointerMemberoperator++ ()
 
IteratorToPointerMember operator++ (int)
 Postfix operator++ (dummy argument) More...
 
IteratorToPointerMemberoperator+= (difference_type n)
 
difference_type operator- (const IteratorToPointerMember< It, R > &rhs) const
 
IteratorToPointerMember operator- (difference_type n) const
 
IteratorToPointerMemberoperator-- ()
 
IteratorToPointerMember operator-- (int)
 Postfix operator-- (see note about the postfix operator++)
 
IteratorToPointerMemberoperator-= (difference_type n)
 
virtual pointer operator-> () const
 
bool operator== (const IteratorToPointerMember< It, R > &rhs) const
 
reference operator[] (difference_type n) const
 

Public Attributes

It m_it
 

Protected Attributes

value_type T::* m_memptr
 

Detailed Description

template<typename It, typename R>
class marley::IteratorToPointerMember< It, R >

Template class that creates an iterator to a class member based on an iterator to a pointer (either bare or smart) to the class object.

Ideally this class would inherit from marley::IteratorToMember and merely override the operator*() and operator->() functions, but such behavior doesn't appear to be currently possible (6/2016) using template classes.

Template Parameters
Ittype of the original iterator
Rtype of the member we want to point to

Member Typedef Documentation

◆ T

template<typename It , typename R >
typedef std::remove_reference< decltype( *std::declval<T_pointer>) ) >::type marley::IteratorToPointerMember< It, R >::T

Type of the target of the pointer pointed to by the original iterator.

We could have used std::remove_pointer<T_pointer>::type here as well, but that approach does not work with smart pointers (e.g., std::unique_ptr).

Constructor & Destructor Documentation

◆ IteratorToPointerMember()

template<typename It , typename R >
marley::IteratorToPointerMember< It, R >::IteratorToPointerMember ( It  from,
R T::*  memptr 
)
inline

Construction from an iterator and a pointer to member.

Parameters
fromIterator to the object
memptrPointer to the member of interest

Member Function Documentation

◆ operator++()

template<typename It , typename R >
IteratorToPointerMember< It, R > marley::IteratorToPointerMember< It, R >::operator++ ( int  )
inline

Postfix operator++ (dummy argument)

Note
The standard behavior for this operator is to return the un-incremented value while incrementing the operand. See discussion here.

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