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 pointstd::ranges::swap
, which is like a smarterstd::swap
that does “the using bit” for you. - The first batch of Range algorithms in
<algorithm>
:copy
,copy_n
, andcopy_if
all_of
,any_of
, andnone_of
find
,find_if
, andfind_if_not
count
andcount_if
for_each
andfor_each_n
equal
andmismatch
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 https://github.com/microsoft/STL 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_end
,find_first_of
, andadjacent_find
- Updates to
reverse_iterator
andmove_iterator
to better adapt “new” Ranges iterator types, including the addition ofmove_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_to
,not_equal_to
,less
,greater
,less_equal
,greater_equal
, andcompare_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.
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?