https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122418
Bug ID: 122418
Summary: invoke_result_t does not take into account volatile
reference_wrapper
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
invoke_result_t doesn't seem to account for reference_wrapper with a volatile
qualifier, which makes it expect that the underlying reference can be obtained
via .get(), but since .get() is not volatile, the volatile reference_wrapper is
always an invalid type for member function invoking.
#include <type_traits>
#include <functional>
struct S {
void f() { };
};
template<class T>
void test(T t) {
volatile auto r = std::ref(t);
if constexpr (requires { std::invoke(&T::f, r); })
std::invoke(&T::f, r);
}
int main() {
test(S{});
}
https://godbolt.org/z/cnn8G5x8M