std::experi...tputIterator(3)
π std::experi...tputIterator(3) π
okay so bestie, welcome to the C++ Standard Libary (yes that's literally how the page spells it, we do not fix it, we respect the typo π) β today we're covering std::experi...tputIterator, the manual page for std::experimental::ranges::OutputIterator. it's giving niche, it's giving compiler-nerd, it's giving you're gonna need this for the Ranges TS. let's go. β¨
πΈ NAME πΈ
std::experimental::ranges::OutputIterator β and the description? std::experimental::ranges::OutputIterator. that's it. that's the whole thing. iconic, no notes, we love a self-titled moment. π
β¨ Synopsis β¨
first of all, where does it live? right here:
- Defined in header
<experimental/ranges/iterator>
and here's the concept itself, verbatim, do not touch my formatting:
template< class I, class T >
concept bool OutputIterator =
Iterator<I> && Writable<I, T> &&
requires(I i, T&& t) {
*i++ = std::forward<T>(t); // not required to be equality preserving
};
(see that little (ranges TS) floating in the margin of the original page? that's just the vibes tag telling you this is the Ranges TS era. iykyk. π¦)
so what's the actual vibe check? OutputIterator is a refinement of Iterator β like, it's Iterator but with extra requirements, main character energy only. specifically, it adds the requirement that it can be used to write values of values of type and value category encoded by T (via Writable). and EqualityComparable? not required. nope. not a thing here. we simply do not ask that of her. π
now, let E be an expression such that decltype((E)) is T, and let i be a dereferenceable object of type I. then OutputIterator<I, T> is satisfied only if *i++ = E; has effects equivalent to *i = E; ++i;. fr fr, that's the whole deal, that's the assignment-plus-increment pipeline. π
π Equality preservation π
An expression is equality preserving if it results in equal outputs given equal inputs. simple as that, bestie:
- The inputs to an expression consist of its operands.
- The outputs of an expression consist of its result and all operands modified by the expression (if any).
and here's the part where it gets picky β every expression required to be equality preserving is further required to be stable: two evaluations of such an expression with the same input objects must have equal outputs absent any explicit intervening modification of those input objects. so like. don't be out here mutating stuff and then acting brand new. π the audacity would be unmatched.
π Notes π
- Unlike the output iterator requirements in the C++ standard,
OutputIteratorin the Ranges TS does not require that the iterator category tag be defined. so she's low-maintenance like that. π«Ά - Algorithms on output iterators should be single pass. periodt. that's the rule. π₯
okay that's the whole page, you ate that, go forth and write your iterators responsibly π
and a cute little sign-off for the credits: this page was pulled from http://cppreference.com, dated 2024.06.10, and it signs itself std::experi...tputIterator(3) at the bottom like a little signature. slay. πβ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms