eyalz800 / zpp_bits

A lightweight C++20 serialization and RPC library
MIT License
722 stars 56 forks source link

Can't serialize arbitrary std::ranges::viewable_range #172

Open walter298 opened 4 weeks ago

walter298 commented 4 weeks ago

This code doesn't compile:

struct Person {
    std::string name;
    int age = 0;
};

int main() {
    auto [data, in, out] = zpp::bits::data_in_out();
    std::vector<Person> people(5);
    in(std::views::transform(people, [](const auto& p) { return p.name; }));
    out(std::ranges::subrange(people.begin(), people.begin() + 3));
}
eyalz800 commented 2 weeks ago

Currently there is no ranges support, but it’s definitely an interesting feature request