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.
All Tuple and Pair Helpers
A compact index of pair and tuple construction, access, forwarding, concatenation, and apply-style helper facilities.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::pairstd::make_pairstd::piecewise_constructstd::tuplestd::make_tuplestd::forward_as_tuplestd::tiestd::tuple_catstd::applystd::ignorestd::get<I>std::get<T>std::tuple_sizestd::tuple_elementforward_as_tuple preserves value categories and should be used deliberately.#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.
std::pair for small two-value returns where the meaning is obviousstd::tuple for generic plumbing or helper layers, not as a substitute for clear domain modelsstd::tie for unpacking into existing variables and std::ignore when one element is intentionally unused#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);
}