Skip to content

Bundle: load store objects

Denis Yaroshevskiy edited this page Jun 12, 2021 · 1 revision

This is not finished, I dunno where I'm going with this.

After @jfalcou did some of the first prs about this, I think we need to maybe think again because not everything is working.

What do we want?

We want some sort of generalised zip/object support.

What's an object?

An object is any kumi::product_type.

Examples:

// plain tuple
wide<kumi::tuple<int, char>>;

// tuple of tuple
wide<kumi::tuple<kumi::tuple<int, char>, kumi::tuple<int>>;

// struct
struct complex : kumi::tuple<double, double>, eve::default_arithmetics
{
  friend decltype(auto) re (eve::compatible<complex> auto&& self) { return get<0>(EVE_FWD(self)); }
  friend decltype(auto) img(eve::compatible<complex> auto&& self) { return get<1>(EVE_FWD(self)); }
};

struct rgb_color : kumi::tuple<int, int, int>
{
  friend decltype(auto) red  (eve::compatible<rgb_color> auto&& self) { return get<0>(EVE_FWD(self)); }
  friend decltype(auto) green(eve::compatible<rgb_color> auto&& self) { return get<1>(EVE_FWD(self)); }
  friend decltype(auto) blue (eve::compatible<rgb_color> auto&& self) { return get<2>(EVE_FWD(self)); }
};

wide<complex>;
wide<rgb_color>;

// struct with sub-structs
struct colored_dot : kumi::tuple<complex, rgb_color>
{
  friend decltype(auto) coordinate (eve::compatible<colored_dot> auto&& self) { return get<0>(EVE_FWD(self)); }
  friend decltype(auto) color      (eve::compatible<colored_dot> auto&& self) { return get<1>(EVE_FWD(self)); }
};

wide<colored_dot>;

What we should be able to do?

We should be able to:

  • zip ranges.
  • write algorithms on zipped ranges
  • interpret zipped ranges as ranges of objects
  • do with wide of zipped objects most/all of the things we can with wide.

Examples:

load(tuple<float*, aligned_ptr<float*>>, as_<complex>) -> wide<complex>;

load[ignore_first(3).or_(complex{0.0, 0.0})](tuple<float*, aligned_ptr<float*>>);

load[ignore_first(3).or_(eve::zero)](tuple<float*, aligned_ptr<float*>>);

reverse(wide<complex>) -> wide<complex>;

reduce(wide<complex>)