std::indirectly_writable(3)
π std::indirectly_writable π
okay bestie, this page is from the C++ Standard Library and it's all about std::indirectly_writable. it's giving "concept with commitment issues but in a principled way" π
let's go.
β¨ NAME β¨
std::indirectly_writable - std::indirectly_writable (yes, that's the whole name, she said what she said π«Ά)
π¦ Synopsis π¦
Defined in header <iterator>
template< class Out, class T >
concept indirectly_writable =
requires(Out&& o, T&& t) {
*o = std::forward<T>(t);
*std::forward<Out>(o) = std::forward<T>(t);
const_cast<const std::iter_reference_t<Out>&&>(*o) =
std::forward<T>(t);
const_cast<const std::iter_reference_t<Out>&&>(*std::forward<Out>(o)) =
std::forward<T>(t);
};
/* none of the four expressions above are required to be
equality-preserving */
β¨ (since C++20) β¨
okay so the concept indirectly_writable<Out, T> specifies the requirements for writing a value whose type and value category are encoded by T into an iterator Out's referenced object. literally "can you write this vibe into that spot?" no cap π«Ά
π Semantic requirements π
Let e be an expression such that decltype((e)) is T, and o be a dereferenceable object of type Out. Then indirectly_writable<Out, T> is modeled only if:
- If
std::indirectly_readable<Out>is modeled andstd::iter_value_t<Out>is the same type asstd::decay_t<T>, 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 π
Expressions declared in requires expressions of the standard library concepts are required to be equality-preserving (except where stated otherwise). periodt β¨
π Notes π
The only valid use of operator* is on the left side of an assignment expression. Assignment through the same value of an indirectly writable type may happen only once. π«Ά
The required expressions with const_cast prevent indirectly_readable objects with prvalue reference types from satisfying the syntactic requirements of indirectly_writable by accident, while permitting proxy references to continue to work as long as their constness is shallow. See Ranges TS issue 381. π
mwah π bestie, that's the whole page β source/version is http://cppreference.com, date 2024.06.10, and the page is std::indirectly_writable(3). slay and read safely π§π
π¦ 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