views::concat iterates several containers as one range
Iterating several containers as if they were one is an ordinary need with no good answer before C++26. You either copied everything into a scratch vector, which allocates and duplicates the data, or you wrote the loop three times, or you built a nest of iterators by hand. None of it composed with the rest of <ranges>.
std::views::concat (P2542) is the missing adaptor. It presents any number of ranges as a single sequence, borrowing rather than copying:
The demo concatenates a std::vector<int>, a std::array<int, 2>, and another vector, then pipes the result through transform:
concat : [1, 2, 3, 4, 5, 6]
size : 6
doubled : [2, 4, 6, 8, 10, 12]
The three containers keep their own storage and their own types. Nothing was copied to produce the joined view, and the result is a range like any other, so it feeds straight into transform, filter, or a range-based for.
How it differs from join
The two are easy to confuse and do different jobs:
views::joinflattens a range of ranges: one container whose elements are themselves containers, all of the same type.views::concattakes several ranges as separate arguments, and they may be different types as long as their elements share a common reference type.
That last part is what makes concat useful for real code. A vector and an array and a span are unrelated types; join cannot help you, because you cannot put them in one container without erasing something. concat takes them as they are.
The view is as capable as its weakest input: random access and sizing survive if every input supports them, which is why std::ranges::size works in the demo. Feed it an input range and the result degrades accordingly, in the usual <ranges> way.
The typical use is exactly what it looks like: iterate a default set followed by user overrides, walk several buckets in order, or run one algorithm across a header and a body without merging them into a temporary first. It arrives alongside a wider batch of new views still working through the committee, but this one is standardised and shipping.
Sources: P2542 “views::concat” · cppreference: std::ranges::concat_view.