Why is ‘mutable’ a lambda function attribute, instead of being a capture type?

There is a mention about your suggestion in n2651:

The syntax for lambda expressions could be extended to allow declaring
whether the closure members should be declared mutable or not.

This approach could be confusing to programmers, as the mutability is not a
property of the closure object, but rather the variables stored in the
closure.

I don’t know if this is the only reason, but it does seem like it was considered.
However, in Herb Sutter’s proposal, he suggests getting rid of mutable and not making the capture copies implicitly const, so we might see changes again.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)