trsl logo
Public Types | Public Member Functions | List of all members
trsl::mp_weight_accessor< WeightType, ElementType > Class Template Reference

Method Pointer weight accessor. More...

#include <weight_accessor.hpp>

Public Types

typedef WeightType(ElementType::* WeightAccessorMethodPointer) () const
 Pointer to a const method of ElementType that returns double.
 

Public Member Functions

 mp_weight_accessor ()
 Default constructor, accessor will return 1 all the time.
 
 mp_weight_accessor (WeightAccessorMethodPointer wptr)
 Constructor from a WeightAccessorMethodPointer. More...
 
WeightType operator() (ElementType const &e) const
 Functor implementation. More...
 

Detailed Description

template<typename WeightType, typename ElementType>
class trsl::mp_weight_accessor< WeightType, ElementType >

Method Pointer weight accessor.

Weight accessor for element classes that provide access to their weight through a method signed WeightType (ElementType::*)() const.

This class is very similar to std::const_mem_fun_ref_t. The only two differences are

These differences allow mp_weight_accessor to be used as a default type for is_picked_systematic weight accessor, since a default-value initialization won't imply segfault. However, access is a bit slower because of the extra check for a non-NULL pointer. If the pointer is NULL, operator() returns 1.

See Accessors for more details.

Definition at line 61 of file weight_accessor.hpp.

Constructor & Destructor Documentation

◆ mp_weight_accessor()

template<typename WeightType , typename ElementType >
trsl::mp_weight_accessor< WeightType, ElementType >::mp_weight_accessor ( WeightAccessorMethodPointer  wptr)
inline

Constructor from a WeightAccessorMethodPointer.

Parameters
wptrPointer to the method of ElementType that returns the element weight.

Definition at line 80 of file weight_accessor.hpp.

Member Function Documentation

◆ operator()()

template<typename WeightType , typename ElementType >
WeightType trsl::mp_weight_accessor< WeightType, ElementType >::operator() ( ElementType const &  e) const
inline

Functor implementation.

Returns
1 if wptr_ is NULL, e.*wptr_() else.

Definition at line 88 of file weight_accessor.hpp.


The documentation for this class was generated from the following file:
© Copyright 2007-2011 Renaud Detry.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt.)
Revised Wed Jan 8 2020 14:43:32.