4 ms·
I have used it c++ to take a scoped lock without naming it and returning a mutex protected value: return scoped_lock{foo_mux_}, return foo_; Also nobody li
by gpderetta 3y ago
I have used it c++ to take a scoped lock without naming it and returning a mutex protected value:
return scoped_lock{foo_mux_}, return foo_;
Also nobody likes it.
- _kst_ 3y agoI think you mean: return scoped_lock{foo_mux_}, foo_;
- gpderetta 3y agoIndeed! :)
- Joker_vD 3y agoDeosn't such an unnamed variable get's immediately destructed, right at the comma? I am pretty certain I'd hit exactly that problem and had to switch to __LINE__-macro to name such scoped locks.
- folmar 3y agoMy understanding of the standard is that the `full-expression` ends at the semicolon and 6.7.7.8 prescribes that the temporary shall be destructed after copying the value to be returned.