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_fun2_t< Result, X, Arg1, Arg2 > Class Template Reference
[STL add-ons]

#include <qgarlib/stl.H>

List of all members.


Detailed Description

template<typename Result, typename X, typename Arg1, typename Arg2>
class qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >

Adaptor for member functions to a binary_function.

const_mem_fun2_ptr_t is an adaptor for const member functions that take two arguments. If T is some class with a member Result T::f(Arg1, Arg2) (Result type can be void), and t an instance of T. Then the const_mem_ptr_fun2_t<Result, T, Arg1, Arg2> is a valid STL functor that makes possible the call of t->f() as if it was a normal function.

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

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

See also:
qgar::qstl_mem_ptr_fun()
Author:
Jan Rendek
Date:
June 03, 2003 08:41
Since:
Qgar 2.1

Definition at line 428 of file stl.H.

Public Member Functions

 const_mem_ptr_fun2_t (X *inst, Result(X::*ptr)(Arg1, Arg2) const)
 Creates an adapter to a binary member function of an instance of class X.
Result operator() (Arg1 a, Arg2 b) const
 Executes the binary member function passed on creation and return the result.

Private Attributes

X * _inst
 A pointer to the instance whose member function is to be called.
Result(X::* _ptr )(Arg1, Arg2) const
 A pointer to the member function to be called.


Constructor & Destructor Documentation

template<typename Result, typename X, typename Arg1, typename Arg2>
qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::const_mem_ptr_fun2_t X *  inst,
Result(X::*)(Arg1, Arg2) const   ptr
[inline]
 

Creates an adapter to a binary 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 443 of file stl.H.


Member Function Documentation

template<typename Result, typename X, typename Arg1, typename Arg2>
Result qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::operator() Arg1  a,
Arg2  b
const [inline]
 

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

Parameters:
a first parameter passed to the member function
b second parameter passed to the member function

Definition at line 457 of file stl.H.

References qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::_inst, and qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::_ptr.


Member Data Documentation

template<typename Result, typename X, typename Arg1, typename Arg2>
X* qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::_inst [private]
 

A pointer to the instance whose member function is to be called.

Definition at line 465 of file stl.H.

Referenced by qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::operator()().

template<typename Result, typename X, typename Arg1, typename Arg2>
Result(X::* qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::_ptr)(Arg1, Arg2) const [private]
 

A pointer to the member function to be called.

Referenced by qgar::const_mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::operator()().


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