Garbage collection/reference counting in C++11

Posted by: Peter 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.