|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-05-01 12:57:03
AMDG
Ovanes Markarian wrote:
> Hicham,
>
> it does not create a new new type it only declares a type.
>
> Consider the following example:
>
> template<int ()>
> struct X
> {};
>
>
> This means your type X expects a function pointer type with return
> value int and no parameters. This can be used in a meta programming to
> make some type assumptions or inspection. This is how the result_of
> works. Think of result_of as of type X but a bit more complex and
> which can give an assumption about the function type passed. We can write:
>
> template<int ()>
> struct X
> {
> typedef int type;
> };
>
> <snip>
>
> Here MyFunc is a name of the function pointer type, which allows us to
> reference this type from inside the template.
>
>
> Hope that helps.
This has very little to do with result_of.
The expression result_of<floatfct(float, float)>::type is the return type of
calling an object of type floatfct with two float arguments.
floatfct(float, float)
is a function type that takes two floats and returns a floatfct. result_of
is an ordinary class template, that uses metaprogramming to decompose
the function type and treats the return type as the function that will
be called.
template<class T>
struct result_of;
template<class F>
struct result_of<F()> {};
template<class F, class Arg1>
struct result_of<F(Arg1)> {};
...
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net