gcc/libstdc++-v3/testsuite/20_util/function_ref
Tomasz Kamiński ac45382d0c libstdc++: Fix construction function_ref from nontype<&S::x> and reference_wrapper [PR121858]
To reduce instantiation count, function_ref(nontype<&S::x>, r) previously
reused the invoker from function_ref(nontype<&S::x>, &r). This assumed r was
always a reference to S or a derived class. However, this constructor is also
valid for lvalues (but not rvalues) of reference_wrapper specializations.

This patch fixes this by limiting above optimization only to situations,
when argument is not specialization of reference_wrapper. This is achieved
bu comparing __inv_unwrap<_Td>::type with _Td. We use __inv_unwrap because
unwrap_reference_t does not handle cv-qualified types.

	PR libstdc++/121858

libstdc++-v3/ChangeLog:

	* include/bits/funcref_impl.h
	(function_ref::function_ref(nontype<__fn>, _Up&&)): Handle.
	reference_wrapper.
	* testsuite/20_util/function_ref/call.cc: Call and update
	test05(). Add new test06() for reference_wrapper.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-11-18 11:51:16 +01:00
..
assign.cc
call.cc libstdc++: Fix construction function_ref from nontype<&S::x> and reference_wrapper [PR121858] 2025-11-18 11:51:16 +01:00
cons.cc
cons_neg.cc
conv.cc
deduction.cc libstdc++: Deduce function_ref<M&() noexcept> from member object pointers. 2025-10-20 17:42:19 +02:00
incomplete_neg.cc
mutation.cc