#include <iostream>
#include <kumi/kumi.hpp>
#include <algorithm>
#include <ranges>
#include <vector>
template <class... Ts>
struct soa
{
struct iterator
{
soa* s;
std::size_t i;
auto operator==(iterator b)
const ->
bool {
return i == b.i; }
auto operator<=>(iterator b) const { return i <=> b.i; }
auto operator++() ->iterator& { ++i; return *this; }
auto operator--() ->iterator& { --i; return *this; }
auto operator++(int) ->iterator { auto copy = *this; ++*this; return copy; }
auto operator--(int) ->iterator { auto copy = *this; --*this; return copy; }
friend auto operator+(iterator a, std::size_t b) -> iterator{ return {.s = a.s, .i = a.i + b}; }
friend auto operator+(std::size_t a, iterator b) -> iterator{ return {.s = b.s, .i = a + b.i}; }
friend auto operator-(iterator a, std::size_t b) -> iterator{ return {.s = a.s, .i = a.i - b}; }
friend auto operator-(std::size_t a, iterator b) -> iterator{ return {.s = b.s, .i = a - b.i}; }
auto operator+=(std::size_t b) -> iterator& { i += b; return *this; }
auto operator-=(std::size_t b) -> iterator& { i -= b; return *this; }
auto operator-(iterator b) const -> std::ptrdiff_t { return i - b.i; }
auto operator*() const
{
}
auto operator[](std::ptrdiff_t b) const
{
}
};
auto begin() -> iterator { return {.s = this, .i = 0 }; }
auto end() -> iterator {
return {.s =
this, .i =
kumi::get<0>(fields).size() }; }
};
static_assert(std::random_access_iterator<soa<int>::iterator>);
int main()
{
soa<float,int> s;
get<0>(s.fields) = {1.2f,2.3f,3.4f,4.5f};
get<1>(s.fields) = {10,20,30,40};
for(auto e : s)
std::cout << e << "\n";
}
constexpr auto tie(Ts &... ts) -> record< field< decltype(Fields), Ts & >... >
Creates a kumi::record of lvalue references to its arguments.
Definition record.hpp:353
friend constexpr auto operator==(tuple const &self, tuple< Us... > const &other) noexcept
Compares a tuple with an other for equality.
Definition tuple.hpp:279
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