Skip to main content
Pigweed's logo Pigweed
  1. Home
  2. Reference
  3. C/C++
  4. pw::FunctionRef< Signature > Class Template Reference
Loading...
Searching...
No Matches
pw::FunctionRef< Signature > Class Template Reference

Overview

template<typename Signature>
class pw::FunctionRef< Signature >

pw::FunctionRef is a non-owning reference to a callable object. It provides similar functionality to C++26 std::function_ref.

Unlike pw::Function, it does not hold ownership of the callable or its context. It is intended for use as a synchronous callback parameter where the callable is guaranteed to outlive the function call.

pw::FunctionRef is not nullable and must be initialized with a valid callable object. This matches the semantics of C++26 std::function_ref.

Example:

void ProcessItems(pw::FunctionRef<void(const Item&)> callback) {
for (const auto& item : items) {
callback(item);
}
}
Definition: function_ref.h:43

The documentation for this class was generated from the following file: