tuple(3) tuple(3)

NAME

tuple - heterogeneous fixed size collection of elements

SYNOPSIS

#include <cfl/tuple/tuple.hpp>

auto a = tuple (0, 1.0, [] () { return 2; });

atN <0> (a) == 0;
atN <1> (a) == 1.0;
atN <2> (a) () == 2;

DESCRIPTION

A tuple is a fixed size collection of elements, not necessarily of the same type. Tuples have static traversal and typically a small number of elements. If a tuple is nested, i.e. one or more elements themselves are tuples, a collection of arbitrary shape can be constructed.

Tuples are generated with the tuple function, yielding a tuple_c container.

Elements are accessed with the atN or atK functions. Collective operations on tuples include, but are not limited to, tuple_map, tuple_fold, tuple_scan, tuple_product and tuple_unfold.

Notably, non-tuples are considered to be dimensionless tuples, qualifying them as arguments to some tuple specific functions. In general, tuples can be classified as heterogeneous multi-dimensional dense arrays, not necessarily regular.

RETURN VALUES

A tuple_c container, with element values stored using standard CFL storage rules (see conventions(5)). tuple responds to storage manipulation with the prfn and prvalue families of functions. As a comparison with standard library, prfn (tuple) corresponds to std::make_tuple, glfn (tuple) to std::forward_as_tuple and tuple_c to std::tuple.

NOTE

The get function used in the standard library for std::tuple element access, is in CFL only used for non-collection containers. The reason is the decision to avoid function templates and instead use function objects (see conventions(5)). Function templates may have both non-template and template overloads - the index argument in the latter case - and classes can not. So a different name (atN) is required for indexed access in CFL.

SEE ALSO

conventions(5), glfn(3), atN(3), atK(3), tuple_map(3), tuple_fold(3), tuple_scan(3), tuple_product(3)