he expression  views  ::  all  (  e
)  is [ expression-equivalent ](/w/cpp/language/expressions#Expression-
equivalence "cpp/language/expressions") to:

  * Implicitly converting  e  to a  [ std::  decay_t  ](http://en.cppreference.com/w/cpp/types/decay) < R  > prvalue, if  [ std::  decay_t  ](http://en.cppreference.com/w/cpp/types/decay) < R  > models [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") . 
  * Otherwise,  std  ::  [ ranges::  ref_view  ](http://en.cppreference.com/w/cpp/ranges/ref_view) {  e  }  if that expression is well-formed. 
  * Otherwise,  std  ::  [ ranges::  owning_view  ](http://en.cppreference.com/w/cpp/ranges/owning_view) {  e  }  . 

2)  Calculates the suitable [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view")
type of a [ ` viewable_range ` ](/w/cpp/ranges/viewable_range
"cpp/ranges/viewable range") type.

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/all_view&action=edit&section=1 "Edit
section: Example") ]  Example

Run this code

    
    
    #include <iostream>
    #include <ranges>
    #include <type_traits>
    #include <vector>
     
    int main()
    {
        [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int> v{0, 1, 2, 3, 4, 5};
        for (int n : std::views::all(v) | std::[views::take](http://en.cppreference.com/w/cpp/ranges/take_view)(2))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << n << ' ';
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
     
        static_assert([std::is_same](http://en.cppreference.com/w/cpp/types/is_same)<
            decltype(std::[views::single](http://en.cppreference.com/w/cpp/ranges/single_view)(42)),
            std::[ranges::single_view](http://en.cppreference.com/w/cpp/ranges/single_view)<int>
            >{});
     
        static_assert([std::is_same](http://en.cppreference.com/w/cpp/types/is_same)<
            decltype(std::views::all(v)),
            std::[ranges::ref_view](http://en.cppreference.com/w/cpp/ranges/ref_view)<[std::vector](http://en.cppreference.com/w/cpp/container/vector)<int, [std::allocator](http://en.cppreference.com/w/cpp/memory/allocator)<int>>>
            >{});
     
        int a[]{1, 2, 3, 4};
        static_assert([std::is_same](http://en.cppreference.com/w/cpp/types/is_same)<
            decltype(std::views::all(a)),
            std::[ranges::ref_view](http://en.cppreference.com/w/cpp/ranges/ref_view)<int[4]>
            >{});
     
        static_assert([std::is_same](http://en.cppreference.com/w/cpp/types/is_same)<
            decltype(std::[ranges::subrange](http://en.cppreference.com/w/cpp/ranges/subrange){[std::begin](http://en.cppreference.com/w/cpp/iterator/begin)(a) + 1, [std::end](http://en.cppreference.com/w/cpp/iterator/end)(a) - 1}),
            std::[ranges::subrange](http://en.cppreference.com/w/cpp/ranges/subrange)<int*, int*, std::[ranges::subrange_kind](http://en.cppreference.com/w/cpp/ranges/subrange_kind)(1)>
            >{});
    }

Output:

    
    
    0 1

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/all_view&action=edit&section=2 "Edit
section: Defect reports") ]  Defect reports

The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.

DR  |  Applied to  |  Behavior as published  |  Correct behavior   
---|---|---|---  
[ LWG 3724 ](https://cplusplus.github.io/LWG/issue3724) |  C++20  |  ` views::all ` might result in hard error for some move-only views  |  it gets well-constrained   
[ P2415R2 ](https://wg21.link/P2415R2) |  C++20  |  ` views::all ` returned a ` subrange ` for a non- [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") rvalue [ ` range ` ](/w/cpp/ranges/range "cpp/ranges/range") |  returns an ` owning_view ` for it   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/all_view&action=edit&section=3 "Edit
section: See also") ]  See also

[ ranges::empty_view  views::empty  ](/w/cpp/ranges/empty_view "cpp/ranges/empty view") (C++20)  |  an empty [ ` vi