tuple_scan(3) | tuple_scan(3) |
tuple_scan - tuple prefix sum
#include <cfl/tuple/functions/tuple_scan.hpp>
template <typename F, typename I, typename... ARGS>
auto tuple_scan (F && f, I && i, ARGS &&... args);
auto f = [] (int a, int b) { return a + b; }
tuple_scan (f, 1, tuple (2, 3)) == tuple (3, 6);
tuple_scan
is like tuple_fold
, except that intermediate results are returned
in a tuple. Using the notation from [tuple_fold(3)][], r(1)...r(n)
are
returned in a tuple, instead of just r(n)
.
tuple_scan
has the same variants as tuple_fold
: tuple_scanl
,
tuple_scan_all
and tuple_scanl_all
.
For left-to-right scans, tuples containing the result are returned.
However, for right-to-left scans, a tuple_view
is returned instead. Because
direct base classes are specified to be “initialized in declaration order as
they appear in the derived class base-specifier-list (regardless of the order of
the mem-initializers)", it is not possible to construct return value elements
inplace for both right and left scans.
A tuple_view
, is a primarily CFL internal representation of tuples. As far the
user is concerned, such views respond to tuple access and collective functions
as regular tuples - which in practice is the only way to use tuples anyway.
tuple(3), tuple_fold(3), tuple_view(3)