2 ms·
I might be wrong here, but I think that the first one is a declaration of a guard with the name m using the default constructor. The same way that int (a); a
by ynfnehf 7y ago
I might be wrong here, but I think that the first one is a declaration of a guard with the name m using the default constructor.
The same way that
int (a);
and
int a;
are equivalent.
So the guard should remain until end of scope, but won't guard anything.
- clappski 7y agolock_guard doesn’t have a default ctor, you have to pass a mutex (or presumably invoke a move ctor, but I can’t see one on cppref).
- bstamour 7y agoLock guard has no default constructor, so the line will in fact materialize a temporary lock guard around the mutex m, then throw it away at the semi-colon, thus locking nothing.