<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gcc.git/libstdc++-v3/include/bits/funcref_impl.h, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/'/>
<entry>
<title>libstdc++: Fix construction function_ref from nontype&lt;&amp;S::x&gt; and reference_wrapper [PR121858]</title>
<updated>2025-11-18T10:51:16+00:00</updated>
<author>
<name>Tomasz Kamiński</name>
<email>tkaminsk@redhat.com</email>
</author>
<published>2025-10-24T14:45:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=ac45382d0c06bc1a90ce74e0379e52496ab3bffe'/>
<id>ac45382d0c06bc1a90ce74e0379e52496ab3bffe</id>
<content type='text'>
To reduce instantiation count, function_ref(nontype&lt;&amp;S::x&gt;, r) previously
reused the invoker from function_ref(nontype&lt;&amp;S::x&gt;, &amp;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&lt;_Td&gt;::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&lt;__fn&gt;, _Up&amp;&amp;)): Handle.
	reference_wrapper.
	* testsuite/20_util/function_ref/call.cc: Call and update
	test05(). Add new test06() for reference_wrapper.

Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To reduce instantiation count, function_ref(nontype&lt;&amp;S::x&gt;, r) previously
reused the invoker from function_ref(nontype&lt;&amp;S::x&gt;, &amp;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&lt;_Td&gt;::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&lt;__fn&gt;, _Up&amp;&amp;)): Handle.
	reference_wrapper.
	* testsuite/20_util/function_ref/call.cc: Call and update
	test05(). Add new test06() for reference_wrapper.

Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Pass small trivial types by value in polymorphic wrappers</title>
<updated>2025-06-02T11:52:35+00:00</updated>
<author>
<name>Tomasz Kamiński</name>
<email>tkaminsk@redhat.com</email>
</author>
<published>2025-05-28T09:16:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=08031b88e2a32cc334af540703c5332a6b716529'/>
<id>08031b88e2a32cc334af540703c5332a6b716529</id>
<content type='text'>
This patch adjust the passing of parameters for the move_only_function,
copyable_function and function_ref. For types that are declared as being passed
by value in signature template argument, they are passed by value to the invoker,
when they are small (at most two pointers), trivially move constructible and
trivially destructible. The latter guarantees that passing them by value has not
user visible side effects.

In particular, this extends the set of types forwarded by value, that was
previously limited to scalars, to also include specializations of std::span and
std::string_view, and similar standard and program defined-types.

Checking the suitability of the parameter types requires the types to be complete.
As a consequence, the implementation imposes requirements on instantiation of
move_only_function and copyable_function. To avoid producing the errors from
the implementation details, a static assertion was added to partial
specializations of copyable_function, move_only_function and function_ref.
The static assertion uses existing __is_complete_or_unbounded, as arrays type
parameters are automatically decayed in function type.

Standard already specifies in [res.on.functions] p2.5 that instantiating these
partial specialization with incomplete types leads to undefined behavior.

libstdc++-v3/ChangeLog:

	* include/bits/funcwrap.h (__polyfunc::__pass_by_rref): Define.
	(__polyfunc::__param_t): Update to use __pass_by_rref.
	* include/bits/cpyfunc_impl.h:: Assert that are parameters type
	are complete.
	* include/bits/funcref_impl.h: Likewise.
	* include/bits/mofunc_impl.h: Likewise.
	* testsuite/20_util/copyable_function/call.cc: New test.
	* testsuite/20_util/function_ref/call.cc: New test.
	* testsuite/20_util/move_only_function/call.cc: New test.
	* testsuite/20_util/copyable_function/conv.cc: New test.
	* testsuite/20_util/function_ref/conv.cc: New test.
	* testsuite/20_util/move_only_function/conv.cc: New test.
	* testsuite/20_util/copyable_function/incomplete_neg.cc: New test.
	* testsuite/20_util/function_ref/incomplete_neg.cc: New test.
	* testsuite/20_util/move_only_function/incomplete_neg.cc: New test.

Reviewed-by: Patrick Palka &lt;ppalka@redhat.com&gt;
Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adjust the passing of parameters for the move_only_function,
copyable_function and function_ref. For types that are declared as being passed
by value in signature template argument, they are passed by value to the invoker,
when they are small (at most two pointers), trivially move constructible and
trivially destructible. The latter guarantees that passing them by value has not
user visible side effects.

In particular, this extends the set of types forwarded by value, that was
previously limited to scalars, to also include specializations of std::span and
std::string_view, and similar standard and program defined-types.

Checking the suitability of the parameter types requires the types to be complete.
As a consequence, the implementation imposes requirements on instantiation of
move_only_function and copyable_function. To avoid producing the errors from
the implementation details, a static assertion was added to partial
specializations of copyable_function, move_only_function and function_ref.
The static assertion uses existing __is_complete_or_unbounded, as arrays type
parameters are automatically decayed in function type.

Standard already specifies in [res.on.functions] p2.5 that instantiating these
partial specialization with incomplete types leads to undefined behavior.

libstdc++-v3/ChangeLog:

	* include/bits/funcwrap.h (__polyfunc::__pass_by_rref): Define.
	(__polyfunc::__param_t): Update to use __pass_by_rref.
	* include/bits/cpyfunc_impl.h:: Assert that are parameters type
	are complete.
	* include/bits/funcref_impl.h: Likewise.
	* include/bits/mofunc_impl.h: Likewise.
	* testsuite/20_util/copyable_function/call.cc: New test.
	* testsuite/20_util/function_ref/call.cc: New test.
	* testsuite/20_util/move_only_function/call.cc: New test.
	* testsuite/20_util/copyable_function/conv.cc: New test.
	* testsuite/20_util/function_ref/conv.cc: New test.
	* testsuite/20_util/move_only_function/conv.cc: New test.
	* testsuite/20_util/copyable_function/incomplete_neg.cc: New test.
	* testsuite/20_util/function_ref/incomplete_neg.cc: New test.
	* testsuite/20_util/move_only_function/incomplete_neg.cc: New test.

Reviewed-by: Patrick Palka &lt;ppalka@redhat.com&gt;
Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Implement C++26 function_ref [PR119126]</title>
<updated>2025-05-26T09:25:28+00:00</updated>
<author>
<name>Tomasz Kamiński</name>
<email>tkaminsk@redhat.com</email>
</author>
<published>2025-05-14T10:04:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=545433e9bd32e965726956cb238d53b39844b85c'/>
<id>545433e9bd32e965726956cb238d53b39844b85c</id>
<content type='text'>
This patch implements C++26 function_ref as specified in P0792R14,
with correction for constraints for constructor accepting nontype_t
parameter from LWG 4256.

As function_ref may store a pointer to the const object, __Ptrs::_M_obj is
changed to const void*, so again we do not cast away const from const
objects. To help with necessary casts, a __polyfunc::__cast_to helper is
added, that accepts reference to or target type direclty.

The _Invoker now defines additional call methods used by function_ref:
_S_ptrs() for invoking target passed by reference, and __S_nttp, _S_bind_ptr,
_S_bind_ref for handling constructors accepting nontype_t. The existing
_S_call_storage is changed to thin wrapper, that initialies _Ptrs, and forwards
to _S_call_ptrs.

This reduced the most uses of _Storage::_M_ptr and _Storage::_M_ref,
so this functions was removed, and _Manager uses were adjusted.

Finally we make function_ref available in freestanding mode, as
move_only_function and copyable_function are currently only available in hosted,
so we define _Manager and _Mo_base only if either __glibcxx_move_only_function
or __glibcxx_copyable_function is defined.

	PR libstdc++/119126

libstdc++-v3/ChangeLog:

	* doc/doxygen/stdheader.cc: Added funcref_impl.h file.
	* include/Makefile.am: Added funcref_impl.h file.
	* include/Makefile.in: Added funcref_impl.h file.
	* include/bits/funcref_impl.h: New file.
	* include/bits/funcwrap.h: (_Ptrs::_M_obj): Const-qualify.
	(_Storage::_M_ptr, _Storage::_M_ref): Remove.
	(__polyfunc::__cast_to) Define.
	(_Base_invoker::_S_ptrs, _Base_invoker::_S_nttp)
	(_Base_invoker::_S_bind_ptrs, _Base_invoker::_S_bind_ref)
	(_Base_invoker::_S_call_ptrs): Define.
	(_Base_invoker::_S_call_storage): Foward to _S_call_ptrs.
	(_Manager::_S_local, _Manager::_S_ptr): Adjust for _M_obj being
	const qualified.
	(__polyfunc::_Manager, __polyfunc::_Mo_base): Guard with
	__glibcxx_move_only_function || __glibcxx_copyable_function.
	(__polyfunc::__skip_first_arg, __polyfunc::__deduce_funcref)
	(std::function_ref) [__glibcxx_function_ref]: Define.
	* include/bits/utility.h (std::nontype_t, std::nontype)
	(__is_nontype_v) [__glibcxx_function_ref]: Define.
	* include/bits/version.def: Define function_ref.
	* include/bits/version.h: Regenerate.
	* include/std/functional: Define __cpp_lib_function_ref.
	* src/c++23/std.cc.in (std::nontype_t, std::nontype)
	(std::function_ref) [__cpp_lib_function_ref]: Export.
	* testsuite/20_util/function_ref/assign.cc: New test.
	* testsuite/20_util/function_ref/call.cc: New test.
	* testsuite/20_util/function_ref/cons.cc: New test.
	* testsuite/20_util/function_ref/cons_neg.cc: New test.
	* testsuite/20_util/function_ref/conv.cc: New test.
	* testsuite/20_util/function_ref/deduction.cc: New test.
	* testsuite/20_util/function_ref/mutation.cc: New test.

Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch implements C++26 function_ref as specified in P0792R14,
with correction for constraints for constructor accepting nontype_t
parameter from LWG 4256.

As function_ref may store a pointer to the const object, __Ptrs::_M_obj is
changed to const void*, so again we do not cast away const from const
objects. To help with necessary casts, a __polyfunc::__cast_to helper is
added, that accepts reference to or target type direclty.

The _Invoker now defines additional call methods used by function_ref:
_S_ptrs() for invoking target passed by reference, and __S_nttp, _S_bind_ptr,
_S_bind_ref for handling constructors accepting nontype_t. The existing
_S_call_storage is changed to thin wrapper, that initialies _Ptrs, and forwards
to _S_call_ptrs.

This reduced the most uses of _Storage::_M_ptr and _Storage::_M_ref,
so this functions was removed, and _Manager uses were adjusted.

Finally we make function_ref available in freestanding mode, as
move_only_function and copyable_function are currently only available in hosted,
so we define _Manager and _Mo_base only if either __glibcxx_move_only_function
or __glibcxx_copyable_function is defined.

	PR libstdc++/119126

libstdc++-v3/ChangeLog:

	* doc/doxygen/stdheader.cc: Added funcref_impl.h file.
	* include/Makefile.am: Added funcref_impl.h file.
	* include/Makefile.in: Added funcref_impl.h file.
	* include/bits/funcref_impl.h: New file.
	* include/bits/funcwrap.h: (_Ptrs::_M_obj): Const-qualify.
	(_Storage::_M_ptr, _Storage::_M_ref): Remove.
	(__polyfunc::__cast_to) Define.
	(_Base_invoker::_S_ptrs, _Base_invoker::_S_nttp)
	(_Base_invoker::_S_bind_ptrs, _Base_invoker::_S_bind_ref)
	(_Base_invoker::_S_call_ptrs): Define.
	(_Base_invoker::_S_call_storage): Foward to _S_call_ptrs.
	(_Manager::_S_local, _Manager::_S_ptr): Adjust for _M_obj being
	const qualified.
	(__polyfunc::_Manager, __polyfunc::_Mo_base): Guard with
	__glibcxx_move_only_function || __glibcxx_copyable_function.
	(__polyfunc::__skip_first_arg, __polyfunc::__deduce_funcref)
	(std::function_ref) [__glibcxx_function_ref]: Define.
	* include/bits/utility.h (std::nontype_t, std::nontype)
	(__is_nontype_v) [__glibcxx_function_ref]: Define.
	* include/bits/version.def: Define function_ref.
	* include/bits/version.h: Regenerate.
	* include/std/functional: Define __cpp_lib_function_ref.
	* src/c++23/std.cc.in (std::nontype_t, std::nontype)
	(std::function_ref) [__cpp_lib_function_ref]: Export.
	* testsuite/20_util/function_ref/assign.cc: New test.
	* testsuite/20_util/function_ref/call.cc: New test.
	* testsuite/20_util/function_ref/cons.cc: New test.
	* testsuite/20_util/function_ref/cons_neg.cc: New test.
	* testsuite/20_util/function_ref/conv.cc: New test.
	* testsuite/20_util/function_ref/deduction.cc: New test.
	* testsuite/20_util/function_ref/mutation.cc: New test.

Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
