lib_ranges_to_container ` ](/w/cpp/feature_test#cpp_lib_ranges_to_container "cpp/feature test") |  202202L  |  (C++23)  |  std::ranges::to   
[ ` __cpp_lib_ranges_zip ` ](/w/cpp/feature_test#cpp_lib_ranges_zip "cpp/feature test") |  202110L  |  (C++23)  |  std::ranges::zip_view  ,   
std::ranges::zip_transform_view  ,  
std::ranges::adjacent_view  ,  
std::ranges::adjacent_transform_view  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/ranges&action=edit&section=14 "Edit
section: Example") ]  Example

Run this code

    
    
    #include <iostream>
    #include <ranges>
     
    int main()
    {
        auto const ints = {0, 1, 2, 3, 4, 5};
        auto even = [](int i) { return 0 == i % 2; };
        auto square = [](int i) { return i * i; };
     
        // the "pipe" syntax of composing the views:
        for (int i : ints | std::[views::filter](http://en.cppreference.com/w/cpp/ranges/filter_view)(even) | std::[views::transform](http://en.cppreference.com/w/cpp/ranges/transform_view)(square))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << i << ' ';
     
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
     
        // a traditional "functional" composing syntax:
        for (int i : std::[views::transform](http://en.cppreference.com/w/cpp/ranges/transform_view)(std::[views::filter](http://en.cppreference.com/w/cpp/ranges/filter_view)(ints, even), square))
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << i << ' ';
    }

Output:

    
    
    0 4 16
    0 4 16

###  [ [ edit ](/mwiki/index.php?title=cpp/ranges&action=edit&section=15 "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 3509 ](https://cplusplus.github.io/LWG/issue3509)  
( [ P2281R1 ](https://wg21.link/P2281R1) )  |  C++20  |  it was unclear how range adaptor objects bound trailing arguments  |  they are bound   
by value  
[ LWG 3948 ](https://cplusplus.github.io/LWG/issue3948) |  C++23  |  ` _possibly-const-range_ ` and ` _as-const-pointer_ ` were not declared  noexcept  |  declared  noexcept   
  
###  [ [ edit ](/mwiki/index.php?title=cpp/ranges&action=edit&section=16 "Edit
section: See also") ]  See also

  * [ Iterator library ](/w/cpp/iterator "cpp/iterator")
  * [ Constrained algorithms ](/w/cpp/algorithm/ranges "cpp/algorithm/ranges")

Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges&oldid=170296
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges&oldid=170296) "

[ Category ](/w/Special:Categories "Special:Categories") :

  * [ Todo with reason ](/w/Category:Todo_with_reason "Category:Todo with reason")

#####  Navigation

  * [ Support us ](http://www.cppreference.com/support)
  * [ Recent changes ](/w/Special:RecentChanges "A list of recent changes in the wiki \[r\]")
  * [ FAQ ](/w/Cppreference:FAQ)
  * [ Offline version ](/w/Cppreference:Archives)

#####  Toolbox

  * [ What links here ](/w/Special:WhatLinksHere/cpp/ranges "A list of all wiki pages that link here \[j\]")
  * [ Related changes ](/w/Special:RecentChangesLinked/cpp/ranges "Recent changes in pages linked from this page \[k\]")
  * [ Upload file ](http://upload.cppreference.com/w/Special:Upload "Upload files \[u\]")
  * [ Special pages ](/w/Special:SpecialPages "A list of all special pages \[q\]")
  * [ Printable version ](/mwiki/index.php?title=cpp/ranges&printable=yes "Printable version of this page \[p\]")
  * [ Permanent link ](/mwiki/index.php?title=cpp/ranges&oldid=170296 "Permanent link to this revision of the page")
  * [ Page information ](/mwiki/index.php?title=cpp/ranges&action=info)

  * In other languages 

  * [ Español ](http://es.cppreference.com/w/cpp/ranges "cpp/ranges")
  * [ 日本語 ](http://ja.cppreference.com/w/cpp/ranges "cpp/ranges")
  * [ Русский ](http://