https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121858
--- Comment #7 from 康桓瑋 <hewillk at gmail dot com> --- (In reply to Tomasz Kamiński from comment #4) > LEWG explicitly decided that reference_wrapper does not have special > handling for function_ref, so your example is required to compile: > std::function_ref<void()> fr(std::nontype<&S::f>, sr); > > However, fr will store pointer to sr, and will-start dangling as soon as it > goes out of scope. In other words, the rvalue-reference case would dangle > immediately, and make sense > that it is ill-formed. > std::function_ref<void()> fr(std::nontype<&S::f>, std::ref(s)); Yes. But if we know it is a reference_wrapper, we can dispatch function_ref(nontype_t<f>, cv T*) using reference_wrapper::get(). I'm wondering if special handling of reference_wrapper<T> is actually worthwhile, since it is more efficient to store a pointer to T than to store a pointer to reference_wrapper<T>.
