Initial Support For C++20 Ranges 

Casey Carter

We are happy to announce that Visual Studio 2019 version 16.6 contains the first user-visible pieces of C++20 Ranges support. We’ve been working on support machinery for a few releases now, but in this release the tip of the iceberg has finally broken the surface of the water and there are now some tools available for users. The Ranges implementation critically depends on C++ Concepts, and as such is usable with both MSVC and Clang in their C++20 Preview modes but not yet well-supported by IntelliSense. (Don’t worry, we’ll have proper IntelliSense support soon.) 

What’s Available? 

  • The standard library concepts in <concepts> have been shipping in MSVC since version 16.3. This includes the customization point std::ranges::swap, which is like a smarter std::swap that does “the using bit” for you. 
  • The first batch of Range algorithms in <algorithm>: 
    • copycopy_n, and copy_if
    • all_ofany_of, and none_of
    • findfind_if, and find_if_not
    • count and count_if
    • for_each and for_each_n
    • equal and mismatch 

There’s a brief demo of some of these facilities in Mahmoud Saleh’s talk from the Pure Virtual C++ conference (with code available). 

What’s Coming Next? 

We have been developing the STL publicly on GitHub since it was open-sourced, so you can always pop over to to see what we’re working on. The Changelog page in the attached wiki is effectively a set of release notes for past and future STL work that we update continuously as pull requests are merged. This comment in the “Implement Ranges” issue tracks which parts of the Ranges design we’ve implemented in what pull requests, and even provides a rough idea of what we expect to work on next. 

Visual Studio 2019 version 16.7 (currently in Preview) includes more components of Ranges: 

  • Algorithms find_endfind_first_of, and adjacent_find 
  • Updates to reverse_iterator and move_iterator to better adapt “new” Ranges iterator types, including the addition of move_sentinel 
  • The subrange class template, which aggregates an iterator and sentinel into a convenient range object (a view, to be precise) 
  • The view_interface base from which view types can inherit some default implementations of simple behaviors 
  • The constrained transparent comparison function object types equal_tonot_equal_tolessgreaterless_equalgreater_equal, and compare_three_way 

Version 16.8 will include much more: our current plan is to fully support Ranges on Concepts in /std:c++latest mode with IntelliSense in 16.8! 

Kick the Tires 

Please give the available components a try, and we’ll keep them coming. (Don’t forget to download Visual Studio 2019 version 16.7 Preview if you want to use things mentioned immediately above.) We’d love to hear from you to help us prioritize and build the right features for you. We can be reached via the comments below, Developer Community, and Twitter (@VisualC). For issues and questions specific to the STL or our Ranges implementation, the best way to reach is by filing an issue on GitHub. 

1 comment

Comments are closed. Login to edit/delete your existing comments

  • Hristo Hristov 0

    Clang libc++ library lacks concepts/ranges support yet. Why don’t you contribute your work to Clang? It would be great if by the next revision there is also support in Clang on other platforms?

Feedback usabilla icon