# std::ranges::view::all, std::ranges::all_view

From cppreference.com
< cpp‎ | ranges

template <ViewableRange R> using all_view = decltype(view::all(std::declval<R>())); | (1) | (since C++20)
namespace view { inline constexpr /*unspecified*/ all = /*unspecified*/; } | (2) | (since C++20)

A range adaptor that returns a `View` that includes all elements of its `Range` argument.

The expression view::all(E) is expression-equivalent (has the same effect) to:

- decay-copy(E) if the decayed type of E models `View`.
- Otherwise, std::ranges::ref_view{E} if that expression is well-formed
- Otherwise, std::ranges::subrange{E}

### Example

Run this code

    #include <ranges>
    #include <vector>
    #include <iostream>

    int main()
    {
      std::vector<int> v{0,1,2,3,4,5};
      for(int n : std::view::all(v) | std::view::take(2) ) {
        std::cout << n << ' ';
      }
    }

Output:

    0 1

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/all_view&oldid=110764"