Morning All
It's first thing in the morning for me, so maybe my neurons aren't warmed
up, but I was
surprised this doesn't work.
#include
typedef my_function_type::result_type my_return_type;
2011/10/7 Robert Jones
Morning All It's first thing in the morning for me, so maybe my neurons aren't warmed up, but I was surprised this doesn't work. #include
#include typedef boost::function my_function_type; typedef boost::result_of ::type my_return_type; Doesn't Boost.Function support 'result_of', or am I missing something obvious? If not, is there some other idiom for this, bearing mind that 'my_function_type' might be a Boost.Function, or a true function, or a Boost.Bind? Thx, - Rob. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hello,
Doesn't Boost.Function support 'result_of', or am I missing something obvious?
More the opposite, result_of doesn't support boost::function and is quite limited without "recent" compiler features.
typedef boost::result_of
::type my_return_type;
You may want to use "#define BOOST_RESULT_OF_USE_DECLTYPE" if your compiler is recent enough. Explanations in the docs of result_of. Of course if your compiler is even more recent, it may support * std::result_of.* Regards, Julien PS: niXman solution will work even better if you don't have too many functions...
Better solution:
http://www.boost.org/doc/libs/1_47_0/libs/function_types/doc/html/boost_func...
2011/10/7 Julien Nitard
Hello,
Doesn't Boost.Function support 'result_of', or am I missing something obvious?
More the opposite, result_of doesn't support boost::function and is quite limited without "recent" compiler features.
typedef boost::result_of
::type my_return_type; You may want to use "#define BOOST_RESULT_OF_USE_DECLTYPE" if your compiler is recent enough. Explanations in the docs of result_of. Of course if your compiler is even more recent, it may support std::result_of.
Regards,
Julien
PS: niXman solution will work even better if you don't have too many functions...
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Fri, Oct 7, 2011 at 9:06 AM, niXman
Better solution:
http://www.boost.org/doc/libs/1_47_0/libs/function_types/doc/html/boost_func...
Ah, yes, that's the thing I'm looking for! result_type NOT result_of. Thanks for putting me straight. - Rob.
Change
typedef boost::result_of
On Fri, Oct 7, 2011 at 8:58 AM, Julien Nitard
Hello,
Doesn't Boost.Function support 'result_of', or am I missing something obvious?
More the opposite, result_of doesn't support boost::function and is quite limited without "recent" compiler features.
typedef boost::result_of
::type my_return_type; You may want to use "#define BOOST_RESULT_OF_USE_DECLTYPE" if your compiler is recent enough. Explanations in the docs of result_of. Of course if your compiler is even more recent, it may support * std::result_of.*
Hi Julien - I think I've read the relevant pages already, but it seems to come down to whether the Boost.Function properly publishes its return type. I am a little surprised that it seems not to. Thx, R.
AMDG On 10/07/2011 01:09 AM, Robert Jones wrote:
Hi Julien - I think I've read the relevant pages already, but it seems to come down to whether the Boost.Function properly publishes its return type. I am a little surprised that it seems not to.
It does. As Michel pointed out, you're not using result_of correctly. In Christ, Steven Watanabe
On Fri, Oct 7, 2011 at 3:37 PM, Steven Watanabe
AMDG
On 10/07/2011 01:09 AM, Robert Jones wrote:
Hi Julien - I think I've read the relevant pages already, but it seems to come down to whether the Boost.Function properly publishes its return type. I am a little surprised that it seems not to.
It does. As Michel pointed out, you're not using result_of correctly.
Hi Steven, Julien - Indeed it does, which I didn't understand, but I think I now do. Boost.Function objects publish a 'result' templated nested struct, not a nested type, which it must do since the return type may depend on the invocation arguments, so those arguments must be supplied. Thanks for putting me straight. - Rob.
participants (5)
-
Julien Nitard
-
Michel Morin
-
niXman
-
Robert Jones
-
Steven Watanabe