[result_of] member function

Hi All, Is this feasible? How? class Foo { template<typename Signature> struct result{}; template<typename F> struct result<(F::*f)(value_type)>{ typedef value0_type if f == foo, value1_type if f == bar type; }; value0_type foo(value_type); value1_type bar(value_type); }; How do I invoke result_of to get the result type of F::foo(value_type)?

AMDG er wrote:
Is this feasible? How?
class Foo { template<typename Signature> struct result{};
template<typename F> struct result<(F::*f)(value_type)>{ typedef value0_type if f == foo, value1_type if f == bar type; };
value0_type foo(value_type); value1_type bar(value_type);
};
How do I invoke result_of to get the result type of F::foo(value_type)?
This is not what boost::result_of is for. In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
er wrote:
Is this feasible? How?
class Foo { template<typename Signature> struct result{};
template<typename F> struct result<(F::*f)(value_type)>{ typedef value0_type if f == foo, value1_type if f == bar type; };
value0_type foo(value_type); value1_type bar(value_type);
};
How do I invoke result_of to get the result type of F::foo(value_type)?
This is not what boost::result_of is for.
In Christ, Steven Watanabe Thak you for your answer. I was probably misinterpreting the part that reads
The implementation permits the type F to be a function pointer, function reference, member function pointer, or class type. in the doc of result_of. Is someone aware of an example that illustrates the "member function pointer" part?

AMDG er wrote:
Thak you for your answer. I was probably misinterpreting the part that reads
The implementation permits the type F to be a function pointer, function reference, member function pointer, or class type.
in the doc of result_of. Is someone aware of an example that illustrates the "member function pointer" part?
It works like this: struct S { int f(int); } typedef int (S::*f_type)(int); typedef boost::result_of<f_type(S*, int)>::type f_result_type; Note that this is not very useful if you want to deduce the return type of the function named f in some arbitrary class, because you need to know the type of the member function pointer to use result_of. In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
er wrote:
Thak you for your answer. I was probably misinterpreting the part that reads
The implementation permits the type F to be a function pointer, function reference, member function pointer, or class type.
in the doc of result_of. Is someone aware of an example that illustrates the "member function pointer" part?
It works like this:
struct S { int f(int); } typedef int (S::*f_type)(int); typedef boost::result_of<f_type(S*, int)>::type f_result_type;
Note that this is not very useful if you want to deduce the return type of the function named f in some arbitrary class, because you need to know the type of the member function pointer to use result_of.
In Christ, Steven Watanabe
Thank you for your answer. As a side issue: If F is a class and F() returns F::T&; F const () returns F::T const & result_of<F const ()> will return T& if F::result_type == T&, and void if result_type is not defined?
participants (2)
-
er
-
Steven Watanabe