kumi v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ windows()

template<std::size_t N, concepts::product_type T>
auto kumi::windows ( T && t)
inlinenodiscardconstexpr

Creates a kumi::tuple of product_types, each containing N consecutive elements from t. Windows starts at 0 and advance by 1 element each time.

Template Parameters
NSize of the window to generate
Parameters
tthe tuple to from which to extract the windows
Returns
A tuple of product_types, each containing N consecutive elements of t
Note
Windows behaves like overlapping tiles: each inner product_type is a tile over t starting at index tile_number. All the windows are of the same size.

Helper type

namespace kumi::result
{
template<std::size_t N, product_type> struct windows;
template<std::size_t N, product_type T>
using windows_t = typename windows<N, T>::type;
}
constexpr auto windows(T &&t)
Creates a kumi::tuple of product_types, each containing N consecutive elements from t....
Definition tiler.hpp:43

Computes the return type of a call to kumi::windows

Examples:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{1, 'y', 3.f, short{55}, -8, 66., "Pete"};
auto w = kumi::windows<3>(t);
std::cout << " Standard Windows " << "\n";
std::cout << w << "\n";
kumi::for_each([&](auto tile)
{
get<0>(tile)++;
},w);
std::cout << t << "\n";
std::cout << " Windows with references " << "\n";
std::cout << w2 << "\n";
kumi::for_each([&](auto tile)
{
get<0>(tile)++;
},w2);
std::cout << t << "\n";
}
constexpr auto to_ref(R &&r)
Creates a kumi::record of references given a reference to a kumi::record_type.
Definition record.hpp:413
constexpr void for_each(Function f, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::product_type. f is applied on the values if ...
Definition for_each.hpp:32
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:29
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto r = kumi::record{"a"_id = 1, "b"_id = 'y', "c"_id = 3.f, "d"_id = short{55}
,"e"_id = -8, "f"_id = 66., "g"_id = "Pete"};
auto w = kumi::windows<3>(r);
std::cout << " Standard Windows " << "\n";
std::cout << w << "\n";
kumi::for_each([&](auto tile)
{
},w);
std::cout << r << "\n";
std::cout << " Windows with references " << "\n";
std::cout << w2 << "\n";
kumi::for_each([&](auto tile)
{
},w2);
std::cout << r << "\n";
}
constexpr auto values_of(T &&t) noexcept
Extracts the values of the fields of a kumi::product_type.
Definition meta.hpp:44
constexpr decltype(auto) get(record< Ts... > &&r) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition record.hpp:506
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29