'std-ranges for string splitting and permutations

I'm trying to build a view that takes a vector of strings, splits those strings into pieces on char ; and returns permutations for the resulting tokens on each line.

int main()
{
    std::vector<std::string> lines;
    auto strsplit_view = std::ranges::views::split(';') | std::ranges::views::transform([](auto &&rng)
                                                                                        { return std::string_view(&*rng.begin(), std::ranges::distance(rng)); });

    auto filesplit_view = lines |
                          std::ranges::views::transform([&](auto &&line)
                                                        { return line | strsplit_view; });

    for (auto line : filesplit_view)
    {
        do
        {
            print(line);
        } while (std::ranges::next_permutation(line).found)
    }
}

Is there a way of incorporating permutations into the view itself, or do I have to perform a separate loop like shown above?

The current code does not work on lines, what do I have to do in order to pass line into ranges::next_permutation in this case?

Error output:

no matching function for call to ‘std::basic_string_view<char>::basic_string_view(std::ranges::transform_view<std::ranges::split_view<std::ranges::ref_view<std::__cxx11::basic_string<char> >, std::ranges::single_view<char> >, main()::<lambda(auto:18&&)> >&)’
   89 |         } while (std::ranges::next_permutation(std::string_view(line)).found)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source