Item 43. auto_ptr Is Unusual
Whenever one discusses RAII, it’s necessary to discuss auto_ptr
. This is always a task. It’s not that we’re ashamed of auto_ptr
, mind you, but it’s kind of like explaining your brother to strangers; he’s a superlative person, but you have to be in the right frame of mind to appreciate that. And there’s no denying that both your brother and auto_ptr
have a different worldview from the typical person or object, respectively.
As we discussed in RAII [40, 139], the use of resource handles is a pervasively employed technique in C++ programming, so the standard library supplies a resource handle template that serves many resource handle needs: auto_ptr
. The auto_ptr
class template is used to generate smart pointers (see ...
Get C++ Common Knowledge: Essential Intermediate Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.