Using the Filter View in Practice

Speaker: Nicolai Josuttis

Audience level: 7

One of the most important but also most suprising C++ standard views is the filter view, introduced with C++20.

Filtering the elements of a range is a key use case when dealing with ranges and views.
However, due to the design of views in general and the filter view in particular, there are a lot of aspects to consider in practice.

There are good reasons for the design of the filter view.
However, tradeoffs had to be made so that the resulting design is a compromize of different requirements leading to both great and poor options to use a filter.
You can not only create suprising compile-time errors; you can easily create non-intuitive runtime errors due to undefined behavior.
Knowing all these aspects of filter views is key for successfully filtering elements. Listen and learn important things you neither know nor expect when using views and the filter view.