Landing: c56ec55c797d
Project / Subsystem
gcc / libstdc++
Date
2025-05-15
Author
Tomasz Kamiński
Commit
c56ec55c797daee08681354b229f4475558c1342
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- libstdc++
- patch_id
- —
- commit_hash
- c56ec55c797daee08681354b229f4475558c1342
- source_type
- github
- headline
- libstdc++: Reduce indirection in function_ref where possible.
- tldr
- The `std::function_ref` in libstdc++ avoids double indirection by optimizing construction and assignment.
- author
- Tomasz Kamiński
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • libstdc++
- • C++
- • function_ref
- • optimization
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2025-05-15T00:00:00.000Z
This commit implements P3961R1, which reduces double indirection in std::function_ref by optimizing its construction and assignment. The implementation expands the set of compatible signatures to include ParamType&& and ParamType, and by-value return types that differ only in cv-qualifiers. This optimization is also applied when function_ref<Ret(Args...) const> is constructed from function_ref<Ret(Args...)>, even if the underlying target can be mutated by the call.