trsl logo

trsl::mp_weight_accessor< WeightType, ElementType > Class Template Reference

Method Pointer weight accessor. More...

#include <weight_accessor.hpp>

List of all members.

Public Types

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

Public Member Functions

 mp_weight_accessor (WeightAccessorMethodPointer wptr=NULL)
 Constructor from a WeightAccessorMethodPointer.
WeightType operator() (ElementType const &e) const
 Functor implementation.

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

template<typename WeightType , typename ElementType >
trsl::mp_weight_accessor< WeightType, ElementType >::mp_weight_accessor ( WeightAccessorMethodPointer  wptr = NULL  )  [inline]

Constructor from a WeightAccessorMethodPointer.

Parameters:
wptr Pointer to the method of ElementType that returns the element weight. If no pointer is passed, operator() will return 1 all the time.

Definition at line 75 of file weight_accessor.hpp.


Member Function Documentation

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 83 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 Apr 6 16:30:07 2011.
SourceForge.net Logo