All Callable Wrappers and Adapters
All Callable Wrappers and Adapters
A compact scan page for invocation utilities, function wrappers, adapters, and callable helper types in the standard library.
All Callable Wrappers and Adapters
A compact scan page for invocation utilities, function wrappers, adapters, and callable helper types in the standard library.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::invokestd::invoke_rstd::mem_fnstd::functionstd::move_only_functionstd::copyable_functionstd::function_ref is not in the standard library as of C++23std::bindstd::bind_frontstd::not_fnstd::reference_wrapper<T>std::refstd::crefstd::plus, std::minus, std::multipliesstd::less, std::greater, std::equal_tostd::logical_and, std::logical_or, std::logical_notstd::bit_and, std::bit_or, std::bit_xorstd::bind for readability.std::function in hot paths.#include <functional>
#include <vector>
int add_offset(int value, int offset) {
return value + offset;
}
int main() {
auto plus_ten = std::bind_front(add_offset, std::placeholders::_1, 10);
std::function<int(int)> op = [plus_ten](int value) { return plus_ten(value); };
return op(32);
}
This demonstrates the rough layering: bind_front adapts a callable, while std::function stores one behind a uniform runtime type.
std::bind_front only when partial application is the clearest shapestd::function or another wrapper only when you need storage, reassignment, or runtime polymorphism#include <functional>
#include <string>
int scale(int value, int factor) {
return value * factor;
}
int main() {
auto double_it = std::bind_front(scale, std::placeholders::_1, 2);
std::function<int(int)> op = [double_it](int value) { return double_it(value); };
return op(21);
}