Hello everyone,


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?

2. If yes, what is the parameter list of the function? Empty parameter list?

3. I doubt whether it is useful to define a function pointer with empty
parameter list -- too restricted.


thanks in advance,
George

Re: Function pointer by Igor

Igor
Mon Dec 10 05:13:33 PST 2007

"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



Re: Function pointer by Carl

Carl
Mon Dec 10 07:31:25 PST 2007

Igor Tandetnik wrote:
> VC2008 is claimed to support TR1 (the spec cited above). I haven't
> checked it myself.

It doesn't support TR1 yet - that support is expected in 1H 2008 as a "out
of band release".

-cd



Re: Function pointer by George

George
Mon Dec 10 19:10:00 PST 2007

Thanks Igor,


My question is answered.


regards,
George

"Igor Tandetnik" wrote:

> "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
>
>
>

Re: Function pointer by George

George
Mon Dec 10 19:11:00 PST 2007

Thanks for your clarification, cd!


regards,
George

"Carl Daniel [VC++ MVP]" wrote:

> Igor Tandetnik wrote:
> > VC2008 is claimed to support TR1 (the spec cited above). I haven't
> > checked it myself.
>
> It doesn't support TR1 yet - that support is expected in 1H 2008 as a "out
> of band release".
>
> -cd
>
>
>