Skip to content

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

Comments

Yeah, they even admit that their macro compiles to identical code as the original RAII version. Where's the "overhead"?

As a general rule, if your C++ compiler can statically see the layout of your structures and the implementation of your functions, it will produce code as efficient as inlining everything yourself. Sufficiently complex functions make the benefits of inlining a judgment call on the compiler's part, but for something as simple as an RAII scoped lock, the abstraction is free.

AboutSource Built by g1lg1l

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