All Tuple and Pair Helpers

All Tuple and Pair Helpers

A compact index of pair and tuple construction, access, forwarding, concatenation, and apply-style helper facilities.

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 Tuple and Pair Helpers

Pair facilities

Tuple facilities

Access and metadata helpers

Practical rules

Small worked example

#include <tuple>

int add(int a, int b) {
	return a + b;
}

int main() {
	auto args = std::make_tuple(20, 22);
	return std::apply(add, args);
}

That is the most practical tuple-helper pattern: collect arguments or data, then unpack them into a callable with std::apply.

Decision guide

Example in practice

#include <tuple>

int add(int a, int b) {
    return a + b;
}

int main() {
    auto args = std::make_tuple(20, 22);
    return std::apply(add, args);
}