This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
function_ref
should provide result_type
Section: 22.10.17.6.2 [func.wrap.ref.class] Status: New Submitter: Hewill Kang Opened: 2025-09-12 Last modified: 2025-09-19
Priority: Not Prioritized
View all issues with New status.
Discussion:
Currently, function
, move_only_function
, and copyable_function
all have a
type member result_type
, but function_ref
does not:
static_assert(is_same_v< function <int(int)>::result_type, int>);
static_assert(is_same_v<move_only_function <int(int)>::result_type, int>);
static_assert(is_same_v< copyable_function <int(int)>::result_type, int>);
static_assert(is_same_v< function_ref<int(int)>::result_type, int>); // error
It seems worthwhile to also provide it for the latter, as it is consistent with the other wrappers and allows the user to easily extract the return type.
Proposed resolution:
This wording is relative to N5014.
Modify 22.10.17.6.2 [func.wrap.ref.class] as indicated:
namespace std { template<class R, class... ArgTypes> class function_ref<R(ArgTypes...) cv noexcept(noex)> { public: using result_type = R; // 22.10.17.6.3 [func.wrap.ref.ctor], constructors and assignment operators template<class F> function_ref(F*) noexcept; […] }; }