Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#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&()> is int, but
  • decltype-based boost::result_of<F*()> is const int.

To remove the inconsistency, decltype-based boost::result_of should use decltype for function pointers.

A patch attached.

Attachments (1)

result_of.patch (2.0 KB ) - added by Michel Morin 11 years ago.
This patch fixes the inconsistency. This patch also fixes the test so that the patched result_of passes 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.)

Download all attachments as: .zip

Change History (4)

by Michel Morin, 11 years ago

Attachment: result_of.patch added

This patch fixes the inconsistency. This patch also fixes the test so that the patched result_of passes 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.)

comment:1 by Daniel Walker, 11 years ago

Resolution: fixed
Status: newclosed

(In [77702]) Applied patch from Michel Morin to fix #6755. Updated copyright to recognize contributors from the past several years.

comment:2 by Daniel Walker, 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.

comment:3 by Eric Niebler, 10 years ago

(In [80359]) merge [77702] to release, fixes #6755

Note: See TracTickets for help on using tickets.