O'Reilly logo

Efficient C++ Performance Programming Techniques by David Mayhew, Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementation Details

Implementing reference counting is a delicate, nontrivial task. The same goes for explaining it. Instead of re-inventing the wheel, we chose to base our performance discussion on the reference counting implementation developed by Meyers in item 29 of “More Effective C++” [Mey96], for several reasons:

  • It is an efficient implementation, given what it set out to accomplish.

  • It is explained very well in [Mey96]. You may refer to it for more details than we provide here.

  • Many people may already be familiar with this particular implementation.

Let's start with a Widget class and evolve it into a reference-counted one. The Widget class contains a member pointing to heap memory (Meyers uses a String class in his initial demonstration ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required