Garbage collection/reference counting in C++11

Posted by Peter J. Jones on

There are plenty of people who criticize C++ for not having a standard garbage collector. Herb Sutter explains why C++ doesn’t support automatic mark-compact garbage collection but does have a formal ABI for mark-sweep style collectors and supports reference counting through the new unique_ptr, shared_ptr, and weak_ptr types. The article’s comments help shed some light on a very important C++ viewpoint: deterministic destructors are super helpful.

The C++11 FAQ maintained by Bjarne Stroustrup contains more information about the new automatic pointer types.

About the Author

Peter J. Jones has been a professional software engineer for over 20 years and is deeply passionate about helping programmers improve the skills of their craft. He is the author of Effective Ruby: 48 Specific Ways to Write Better Ruby. Peter can be reached through our contact page or his twitter account.