named
req/RangeAdaptorObject") (and also [ RangeAdaptorClosureObject
](/w/cpp/named_req/RangeAdaptorClosureObject "cpp/named
req/RangeAdaptorClosureObject") ). The expression  views  ::  values  (  e  )
is [ expression-equivalent ](/w/cpp/language/expressions#Expression-
equivalence "cpp/language/expressions") to  values_view  < [ views::  all_t
](http://en.cppreference.com/w/cpp/ranges/all_view) < decltype  (  (  e  )  )
>> {  e  }  for any suitable subexpression  e  .

##  Contents

  * 1  Notes 
  * 2  Example 
  * 3  Defect reports 
  * 4  See also 

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

values_view  can be useful for extracting _values_ from associative
containers, e.g.

    
    
    [std::map](http://en.cppreference.com/w/cpp/container/map)<int, [std::string](http://en.cppreference.com/w/cpp/string/basic_string)> map{{1, "alpha"}, {2, "beta"}};
    for (auto const& value : std::views::values(map))
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << value << ' ';
    // prints: alpha beta

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

Run this code

    
    
    #include <iostream>
    #include <map>
    #include <ranges>
     
    int main()
    {
        const auto list = {[std::pair](http://en.cppreference.com/w/cpp/utility/pair){1, 11.1}, {2, 22.2}, {3, 33.3}};
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "pair::second values in the list: ";
        for (double value : list | std::views::values)
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << value << ' ';
     
        [std::map](http://en.cppreference.com/w/cpp/container/map)<char, int> map{{'A', 1}, {'B', 2}, {'C', 3}, {'D', 4}, {'E', 5}};
        auto odd = [](int x) { return 0 != (x & 1); };
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "\nodd values in the map: ";
        for (int value : map | std::views::values | std::[views::filter](http://en.cppreference.com/w/cpp/ranges/filter_view)(odd))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << value << ' ';
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
    }

Output:

    
    
    pair::second values in the list: 11.1 22.2 33.3
    odd values in the map: 1 3 5

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/values_view&action=edit&section=3 "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 3563 ](https://cplusplus.github.io/LWG/issue3563) |  C++20  |  ` keys_view ` is unable to participate in CTAD due to its use of  views::all_t  |  views::all_t  removed   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/values_view&action=edit&section=4 "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::elements_view  views::elements  ](/w/cpp/ranges/elements_view "cpp/ranges/elements view") (C++20)  |  takes a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") consisting of [ ` _tuple-like_ ` ](/w/cpp/utility/tuple/tuple-like "cpp/utility/tuple/tuple-like") values and a number N and produces a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") of N  th  element of each tuple   
(class template)  (range adaptor object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ran