mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 12:00:03 -05:00
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>