]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make C++20s operator wrappers operator() static.
authorTomasz Kamiński <tkaminsk@redhat.com>
Thu, 20 Nov 2025 10:23:30 +0000 (11:23 +0100)
committerTomasz Kamiński <tkaminsk@redhat.com>
Wed, 26 Nov 2025 10:45:30 +0000 (11:45 +0100)
commit0ea9d760fbf44c6f50c50a4e259d3ef2c756606c
tree4994f076e4cfc323f10501e1d729326ff14b7896
parentf68fe3ddda40d4c238095ff8c76c473b0d1e4827
libstdc++: Make C++20s operator wrappers operator() static.

The operator() for function objects introduced in C++20 (e.g., std::identity,
std::compare_three_way, std::ranges::equal) is now defined as static.
Although static operator() is a C++23 feature, it is supported in C++20 by
both GCC and clang (since their support was added in clang-16).

This change is not user-observable, as all affected operators are template
functions. Taking the address of such an operator requires casting to a pointer
to member function with a specific signature. The exact signature is unspecified
per C++20 [member.functions] p2 (e.g. due to potential parameters with default
arguments).

libstdc++-v3/ChangeLog:

* include/bits/ranges_cmp.h (std::identity::operator()):
(ranges::equal_to:operator(), ranges::not_equal_to:operator())
(ranges::greater::operator(), ranges::greater_equal::operator())
(ranges::less::operator(), ranges::less_equal::operator()):
Declare as static.
* libsupc++/compare (std::compare_three_way::operator()):
Declare as static.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/bits/ranges_cmp.h
libstdc++-v3/libsupc++/compare