- Why is there lock_guard ? - 3 Updates
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 17 03:40PM -0800 On 2/17/2024 11:15 AM, Bonita Montero wrote: > Why is there lock_guard when unique_lock can anything lock_guard > can do but far more ? lock_guard is meant for its purpose. Only use unique_lock when you need to. And be careful, you can shoot yourself in the foot with it... |
Bonita Montero <Bonita.Montero@gmail.com>: Feb 18 07:59AM +0100 Am 18.02.2024 um 00:40 schrieb Chris M. Thomasson: >> Why is there lock_guard when unique_lock can anything lock_guard >> can do but far more ? > lock_guard is meant for its purpose. ... You easily could do ... template<typename Lock> using std::lock_guard = std::unique_lock<Lock>; ... without any problems. For me lock_guard doesn't make sense. |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 18 12:13PM -0800 On 2/17/2024 10:59 PM, Bonita Montero wrote: > using std::lock_guard = std::unique_lock<Lock>; > ... without any problems. > For me lock_guard doesn't make sense. It has its purpose. If you did this then std::lock_guard would be moveable even though its not meant to be. That's just one point... |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment