std::experi...es::Writable(3)
β¨ NAME β¨
std::experimental::ranges::Writable β bestie, that's the name, and the one-line description is literally std::experimental::ranges::Writable again. This page is chillin' in the C++ Standard Libary manual as std::experi...es::Writable(3). π¦
β¨ Synopsis β¨
Defined in header <experimental/ranges/iterator> β here's the exact concept declaration, no edits, no cap:
Defined in header <experimental/ranges/iterator>
template< class Out, class T >
concept bool Writable =
requires(Out&& o, T&& t) {
*o = std::forward<T>(t);
*std::forward<Out>(o) = std::forward<T>(t);
const_cast<const ranges::reference_t<Out>&&>(*o) =
std::forward<T>(t);
(ranges TS)
const_cast<const
ranges::reference_t<Out>&&>(*std::forward<Out>(o)) =
std::forward<T>(t);
};
/* none of the four expressions above are required to be
equality-preserving */
Okay so Writable<Out, T> is the concept that specifies the requirements for writing a value into an iterator Out's referenced object, where the value's type and value category are encoded by T. That's the whole assignment situation. π
Let E be an expression such that decltype((E)) is T, and let o be a dereferenceable object of type Out. Then Writable<Out, T> is satisfied only if:
- If
Readable<Out> && Same<ranges::value_type_t<Out>, std::decay_t<T>>is satisfied, then*oafter any above assignment is equal to the value ofEbefore the assignment.
o is not required to be dereferenceable after evaluating any of the assignment expressions above. If E is an xvalue, the resulting state of the object it denotes is valid but unspecified. π
π Equality preservation π
An expression is equality preserving if it results in equal outputs given equal inputs.
- 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).
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.
β¨ Notes β¨
- The only valid use of
operator*is on the left side of an assignment expression. - Assignment through the same value of a writable type may happen only once.
- The required expressions with
const_castpreventReadableobjects with prvalue reference types from satisfying the syntactic requirements ofWritableby accident, while permitting proxy references to continue to work as long as their constness is shallow. See Ranges TS issue 381.
Source/version/date sign-off, because the footer deserves a moment: this came from http://cppreference.com, stamped 2024.06.10, and the footer title is std::experi...es::Writable(3). Byeee, go write through your iterators responsibly π
π
π¦ 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