On Friday, 29 September 2017 at 11:12:32 UTC, Cecil Ward wrote:
An idea, I’d be interested to hear if this might be at all
useful to anyone -
If and only if a variable is declared as modifiable (neither
immutable nor const), would it possibly be useful to be able to
have a kind of scope const on/off switch to either impose const
within a block, and/or the converse, that is to impose const as
the default everywhere starting say from an initial directive
straight after the (modifiable) declaration, while being able
to flick the const protection switch off within a block?
auto modifiable = foo();
{
const nonModifiable = modifiable;
//...
}
Or refactor the scope into a function accepting your modifiable
variable as const.
Atila