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.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

All Callable Wrappers and Adapters

Direct invocation utilities

Type-erased and storing wrappers

Binding and negation adapters

Reference-preserving adapters

Standard function objects

Practical rules

Small worked example

#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.

Decision guide

Example in practice

#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);
}