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

qgar::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::mem_ptr_fun2_t< Result, X, Arg1, Arg2 >

Adaptor for member functions to a binary_function.

mem_fun2_ptr_t is an adaptor for 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 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 mem_ptr_fun_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 Arg, 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 inconvienient to use the constructor of 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 347 of file stl.H.

Public Member Functions

 mem_ptr_fun2_t (X *inst, Result(X::*ptr)(Arg1, Arg2))
 Creates an adapter to a binary member function of an instance of class X.
Result operator() (Arg1 a, Arg2 b)
 Executes the binary 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 )(Arg1, Arg2)
 Pointer to the member function to be called.


Constructor & Destructor Documentation

template<typename Result, typename X, typename Arg1, typename Arg2>
qgar::mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::mem_ptr_fun2_t X *  inst,
Result(X::*)(Arg1, Arg2)  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 362 of file stl.H.


Member Function Documentation

template<typename Result, typename X, typename Arg1, typename Arg2>
Result qgar::mem_ptr_fun2_t< Result, X, Arg1, Arg2 >::operator() Arg1  a,
Arg2  b
[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 375 of file stl.H.

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


Member Data Documentation

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

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

Definition at line 383 of file stl.H.

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

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

Pointer to the member function to be called.

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


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