After watching You don't know const and mutable I am kind of puzzled how to handle mutable properly in future.
While I think the case of const is pretty much safe, since one would assume physical read-only by default (minus the old logic exception), properly handling mutable puzzles me.
For example with the new threadsafe-condition the following seems wrong:
int main() {
int n;
[=]() mutable {n = 10;}();
return n;
}
I would assume, that in this case, n would have to be wrapped into a std::atomic or the copy of n be protected by concurrent writes in another way!?
nexactly are you talking about? The variable declared inmainor the copy in the lambda?mutablecondition only applies to explicitly marked objects, in this case the copy ofn.mutablefor a lambda is a different kind ofmutablethan the one for members. It just means that the memberoperator()is not marked asconst.§5.1.2/5: "This function call operator is declaredconst(9.3.1) if and only if the lambda-expression’s parameter-declaration-clause is not followed bymutable."