Skip to content

Comment on In the C++ bag of tricks: scoped locks

Comments

Wouldn't this be exception-safe, provided lock_iter defines a ctor, dtor, operator bool() and operator ++()?

    #define LOCKED(lk) for (lock_iter i = lk; i; i++)
(Edit: I thought lock_iter could be an empty class but no, it can not, so I edited my post. lock_iter will have an internal flag that should be optimized away following the same logic int i is optimized in the OP's version)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.