Skip to content

Does this library has an analogue of ranges::views::intersperse? #139

@denzor200

Description

@denzor200

Can i write some code like this:

#include <range/v3/all.hpp>
#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>
int main()
{
        auto op = [](auto & input, int i, auto & ins)
        {
            return input | ranges::views::intersperse(ins)
                         | ranges::to<std::string>();
        };
        std::string input{"foobarbaxbat"};
        char insert{','};
        auto rng = op(input, 1, insert);
        std::cout << rng << '\n';      // Outputs: f,o,o,b,a,r,b,a,x,b,a,t
}

without range-v3 library, using Boost.Range instead of range-v3?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions