Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To me, the cool (and uncommon in other languages' standard libraries) part about C++ ranges is that they reify pipelines so that you can cut and paste them into variables, like so:

    auto get_ids(std::span<const Widget> data)
    {
        auto pipeline = filter(&Widget::alive) | transform(&Widget::id);
        auto sink = to<std::vector>();
        return data | pipeline | sink;
    }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: