#6755 closed Patches (fixed)
[result_of] Inconsistent results between function references and function pointers
| Reported by: | Michel Morin | Owned by: | Daniel Walker |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | utility |
| Version: | Boost Development Trunk | Severity: | Problem |
| Keywords: | C++11 | Cc: |
Description
For function references, decltype-based boost::result_of uses decltype to determine the type. But, for function pointers, decltype-based boost::result_of
falls back to boost::tr1_result_of and does not use decltype.
This inconsistency makes different results for function references and function pointers.
On clang trunk and gcc-4.7 in a C++11 mode, for "typedef const int F();",
- decltype-based
boost::result_of<F&()>isint, but - decltype-based
boost::result_of<F*()>isconst int.
To remove the inconsistency,
decltype-based boost::result_of should use decltype for function pointers.
A patch attached.
Attachments (1)
Change History (4)
by , 11 years ago
| Attachment: | result_of.patch added |
|---|
comment:1 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:2 by , 11 years ago
This is somewhat related to #6731. Really, neither pointers nor member pointers should be dispatched to TR1 result_of. This patch takes us part of the way there.

This patch fixes the inconsistency. This patch also fixes the test so that the patched
result_ofpasses the test.BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));is removed, since this is uncallable. (BOOST_STATIC_ASSERT((is_same<tr1_result_of<func_ptr(void)>::type, int>::value));is kept untouched.)