Namespaces
Variants
Actions

Talk:cpp/ranges/lazy split view

From cppreference.com

[edit] non_propagating_cache or non_cache_propagating?

In the Data members section the third bullet describes the current_ object being of std::optional-like exposition-only type /*non_propagating_cache*/<ranges::iterator_t<V>>. Then it states that it caches the result of the calls. This seems to conflict with the comment annotation /*non_propagating_cache*/. Could you elaborate what the comment annotation means (and whether it should be non_cache_propagating instead)?
ticotico (talk) 05:57, 9 February 2022 (PST)

Hi, Javier.
1. We have to use "the comment annotations" like /*some-identifier*/ or /*another_name*/ to denote exposition-only names from the Standard. Originally, such names are introduced using italic style, e.g. lisp-style-identifier, meaning that they are not the subject of standardization.
Cppreference editors have to imitate this italic style which is tricky because we do not fully control the source-code highlighter (GeShi) used under the hood. (Many things are possible but it takes time.) Alternative approach is to use "normal" identifiers, such as __SomeIdentifier (prefixed Pascal style) or __another_name (prefixed standard-style).
2. /*non_propagating_cache*/<ranges::iterator_t<V>> is necessary to satisfy the amortized constant time requirement on iterators. In practice, this means that the first access to the element via the iterator might be done in linear time, while all the following use the cached value (i.e. be performed in O(1) time).
Non-propagating part of the name suggests that when the view-adaptor is copied/moved, the cached value in the "non-propagating" member should not be copied/moved but be reset to the empty state.
In addition, implementations use EBO when appropriate to reduce the size of the view adaptors if certain private members are present only conditionally.
--Space Mission (talk) 07:12, 10 February 2022 (PST)