Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qgar::const_mem_ptr_fun_t< Result, X, Arg > Class Template Reference
[STL add-ons]

#include <qgarlib/stl.H>

List of all members.


Detailed Description

template<typename Result, typename X, typename Arg>
class qgar::const_mem_ptr_fun_t< Result, X, Arg >

Adaptor for const member functions to a unary_function.

mem_fun_ptr_t is an adaptor for const member functions that take one argument. If T is some class with a member Result T::f(Arg) (Result type can be void, and t an instance of T. Then the mem_ptr_fun_t<result, T, Arg> is a valid STL functor that makes possible the call of t->f() as if it was a normal function.

If F is a mem_ptr_fun_t that was constructed to use the member function T::f(Arg), and if t a pointer to an instance of T (T*) and a is a value of type Arg, then the expression F(a) is equivalent to the expression t->f(a). The difference is simply that F can be passed to STL algorithms whose arguments must be function objects.

It is usually rather inconvienient to use the constructor of mem_ptr_fun_t directly. It is better to use the helper function qst_mem_ptr_fun instead.

See also:
qgar::mem_ptr_fun()
Author:
Jan Rendek
Date:
May 28, 2003 16:11
Since:
Qgar 2.1

Definition at line 270 of file stl.H.

Public Member Functions

 const_mem_ptr_fun_t (const X *const inst, Result(X::*ptr)(Arg) const)
 Creates an adapter to a unary member function of an instance of class X.
Result operator() (Arg a) const
 Executes the unary member function passed on creation and return the result.

Private Attributes

X * _inst
 Pointer to the instance whose member function is to be called.
Result(X::* _ptr )(Arg) const
 Pointer to the member function to be called.


Constructor & Destructor Documentation

template<typename Result, typename X, typename Arg>
qgar::const_mem_ptr_fun_t< Result, X, Arg >::const_mem_ptr_fun_t const X *const   inst,
Result(X::*)(Arg) const   ptr
[inline]
 

Creates an adapter to a unary member function of an instance of class X.

Parameters:
inst instance of which the function member will be called
ptr pointer on the function member to be called

Definition at line 285 of file stl.H.


Member Function Documentation

template<typename Result, typename X, typename Arg>
Result qgar::const_mem_ptr_fun_t< Result, X, Arg >::operator() Arg  a  )  const [inline]
 

Executes the unary member function passed on creation and return the result.

Parameters:
a parameter passed to the member function

Definition at line 297 of file stl.H.

References qgar::const_mem_ptr_fun_t< Result, X, Arg >::_inst, and qgar::const_mem_ptr_fun_t< Result, X, Arg >::_ptr.


Member Data Documentation

template<typename Result, typename X, typename Arg>
X* qgar::const_mem_ptr_fun_t< Result, X, Arg >::_inst [private]
 

Pointer to the instance whose member function is to be called.

Definition at line 305 of file stl.H.

Referenced by qgar::const_mem_ptr_fun_t< Result, X, Arg >::operator()().

template<typename Result, typename X, typename Arg>
Result(X::* qgar::const_mem_ptr_fun_t< Result, X, Arg >::_ptr)(Arg) const [private]
 

Pointer to the member function to be called.

Referenced by qgar::const_mem_ptr_fun_t< Result, X, Arg >::operator()().


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