Closed dangdkhanh closed 1 year ago
intersperse
takes a range and a value type of that range. L"-"
is not convertible to the value type of s | chunk(2)
(which in this case is a ranges::take_view<...>
), so this can't really work.
One way to fix this would be to first produce a range of wstring
and then interspersing wstring(L"-")
. The string
version of that looks like this:
fmt::print("{}\n",
s // range of char
| ranges::views::chunk(2) // range of take_view<...>
| ranges::views::transform(ranges::to<std::string>()) // range of std::string
| ranges::views::intersperse(std::string("-")) // range of std::string
);
Since s
is contiguous, you could also get away with producing a range of string_view
and interspersing a string_view
.
Hi, I'm using the following code but it has not compiled.
Is there a way to make it work without converting back to vector? Thanks you!