This library's syntax explicitly forces you to choose between std::move()-ing or std::ref()-ing existing variables
into adaptors.1 This avoids unintendedly creating dangling references.
See the examples.
An unsorted list of instances where usage patterns that result in standard library undefined behaviour are ill-formed (and thus prevented) with this library:
- Assigning through range adaptors that would invalidate those range adaptors in non-obvious ways (e.g. changing the element underlying a filter adaptor so that it no longer satisfies the predicat).
- Some (but not all) examples of inadvertantly creating a multi-pass adaptor that violates the multi-pass guarantee. See also tradeoffs.
Many of these have examples on the examples page.
Footnotes
-
Note that we are not technically storing
std::reference_wrapper, we are just usingstd::refas a marker for opting in to the indirection. ↩