](/mwiki/index.php?title=cpp/ranges/elements_view&action=edit&section=2 "Edit
section: Nested classes") ]  Nested classes

[ _ iterator  _ ](/w/cpp/ranges/elements_view/iterator "cpp/ranges/elements view/iterator") (C++20)  |  the iterator type   
(  exposition-only member class template*  )  
---|---  
[ _ sentinel  _ ](/w/cpp/ranges/elements_view/sentinel "cpp/ranges/elements view/sentinel") (C++20)  |  the sentinel type   
(  exposition-only member class template*  )  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/elements_view&action=edit&section=3 "Edit
section: Helper templates") ]  Helper templates

template  < class  T, [ std::  size_t
](http://en.cppreference.com/w/cpp/types/size_t) N  >  
inline  constexpr  bool  enable_borrowed_range  < std  ::  ranges  ::
elements_view  < T, N  >> =  
std  ::  [ ranges::  enable_borrowed_range  ](http://en.cppreference.com/w/cpp/ranges/borrowed_range) < T  > ;  |  |  (since C++20)   
---|---|---  
|  |   
  
This specialization of [ ` std::ranges::enable_borrowed_range `
](/w/cpp/ranges/borrowed_range "cpp/ranges/borrowed range") makes `
elements_view ` satisfy [ ` borrowed_range ` ](/w/cpp/ranges/borrowed_range
"cpp/ranges/borrowed range") when the underlying view satisfies it.

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

Run this code

    
    
    #include <iostream>
    #include <ranges>
    #include <string>
    #include <tuple>
    #include <vector>
     
    int main()
    {
        const [std::vector](http://en.cppreference.com/w/cpp/container/vector)<[std::tuple](http://en.cppreference.com/w/cpp/utility/tuple)<int, char, [std::string](http://en.cppreference.com/w/cpp/string/basic_string)>> vt
        {
            {1, 'A', "α"},
            {2, 'B', "β"},
            {3, 'C', "γ"},
            {4, 'D', "δ"},
            {5, 'E', "ε"},
        };
     
        for (int const e : std::views::elements<0>(vt))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << e << ' ';
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
     
        for (char const e : vt | std::views::elements<1>)
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << e << ' ';
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
     
        for ([std::string](http://en.cppreference.com/w/cpp/string/basic_string) const& e : std::views::elements<2>(vt))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << e << ' ';
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
    }

Output:

    
    
    1 2 3 4 5
    A B C D E
    α β γ δ ε

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/elements_view&action=edit&section=5 "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 3494 ](https://cplusplus.github.io/LWG/issue3494) |  C++20  |  ` elements_view ` was never a ` borrowed_range ` |  it is a ` borrowed_range `   
if its underlying view is  
[ LWG 3502 ](https://cplusplus.github.io/LWG/issue3502) |  C++20  |  dangling reference could be obtained from ` elements_view ` |  such usage is forbidden   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/elements_view&action=edit&section=6 "Edit
section: See also") ]  See also

[ ranges::keys_view  views::keys  ](/w/cpp/ranges/keys_view "cpp/ranges/keys view") (C++20)  |  takes a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") consisting of pair-like values and produces a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") of the first elements of each pair   
(class template)  (range adaptor object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_keys_view&action=edit)  
---|---  
[ ranges::values_view  views::values  ](/w/cpp/ranges/v