Re: Function pointer
"George" <George@discussions.microsoft.com> wrote in message
news:604118DE-ACFC-4A92-9E5D-89D689F49210@microsoft.com
In the following statements,
[Code]
template <class R, class T> class mem_fun_t : public unary_function
<T*, R>
{
R (T::*pmf)()
...
}
[/Code]
1. I think pmf is a type of function pointer, the return type of the
function is R and the function is a member function of type (class)
T. Is my understanding correct?
Looks good to me.
2. If yes, what is the parameter list of the function? Empty
parameter list?
Yes.
3. I doubt whether it is useful to define a function pointer with
empty parameter list -- too restricted.
There's also mem_fun1_t that wraps a member function with one parameter
into a functor with two parameters. All STL algorithms take either unary
or binary functors, so these two are sufficient for STL needs.
The next version of C++ standard will contain a class named "function" -
a generalized wrapper around function pointers with arbitrary (not
really - there's an implementation defined upper limit, but it would be
much larger than 2) number of parameters. See
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
VC2008 is claimed to support TR1 (the spec cited above). I haven't
checked it myself.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925