Initial Support For C++20 Ranges
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.)
- 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::swapthat does “the using bit” for you.
- The first batch of Range algorithms in
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:
- Updates to
move_iteratorto better adapt “new” Ranges iterator types, including the addition of
subrangeclass template, which aggregates an iterator and sentinel into a convenient range object (a view, to be precise)
view_interfacebase from which view types can inherit some default implementations of simple behaviors
- The constrained transparent comparison function object types
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?