Date: Sun, 16 Feb 2025 11:16:46 +0100
Filip, at that point we should step away from the mutable/const sort
of manual management style. Perhaps something like:
> mutable (const int x = 0) {
> // x is a non-const lvalue within this block for the purpose of initialization
> }
> // x is an lvalue of type const int, but it is not a const object
>
> // if x was a class type, the move constructor would be called here because we lift constness
> // for the purpose of return or throw
> return x;
I much prefer this "RAII const management" over the "manual const management".
However, even then, you can achieve a very similar (scoped) effect by
using a do expression as the initializer of x.
of manual management style. Perhaps something like:
> mutable (const int x = 0) {
> // x is a non-const lvalue within this block for the purpose of initialization
> }
> // x is an lvalue of type const int, but it is not a const object
>
> // if x was a class type, the move constructor would be called here because we lift constness
> // for the purpose of return or throw
> return x;
I much prefer this "RAII const management" over the "manual const management".
However, even then, you can achieve a very similar (scoped) effect by
using a do expression as the initializer of x.
Received on 2025-02-16 10:17:00