[all-commits] [llvm/llvm-project] c37478: [libc++][ranges] use `static operator()` for C++23...

Xiaoyang Liu via All-commits all-commits at lists.llvm.org
Fri Mar 22 16:32:23 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c3747883a0bf34d271bc89dbfc60590adf75d999
      https://github.com/llvm/llvm-project/commit/c3747883a0bf34d271bc89dbfc60590adf75d999
  Author: Xiaoyang Liu <siujoeng.lau at gmail.com>
  Date:   2024-03-23 (Sat, 23 Mar 2024)

  Changed paths:
    M libcxx/include/__algorithm/ranges_ends_with.h
    M libcxx/include/__algorithm/ranges_starts_with.h
    M libcxx/include/__ranges/as_rvalue_view.h
    M libcxx/include/__ranges/repeat_view.h
    M libcxx/include/__ranges/to.h
    M libcxx/include/__ranges/zip_view.h

  Log Message:
  -----------
  [libc++][ranges] use `static operator()` for C++23 ranges (#86052)

## Abstract

This pull request converts the `operator()` of all CPOs and niebloids
related to C++23 ranges to `static`.

## Motivation

In `libc++`, CPOs and niebloids are implemented as function objects.
Currently, the `operator()` for such a function object is a
`const`-qualified member function. This means that even if the function
object is has no data members, an extra register is used to pass in the
`this` pointer when calling `operator()`, unless the compiler can inline
the function call. Declaraing `operator()` as `static` would optimize
away the unnecessary `this` pointer passing for stateless function
objects, since there is no object instance state that needs to be
accessed.

## Reference

- [P1169R4: static `operator()`](https://wg21.link/P1169R4)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list