Skip to content

Files

Latest commit

 

History

History
13 lines (7 loc) · 526 Bytes

useAutoPointerContainer.md

File metadata and controls

13 lines (7 loc) · 526 Bytes

Pattern: Use of auto_ptr container

Issue: -

Description

You can randomly lose access to pointers if you store auto_ptr pointers in an STL container.

An element of container must be able to be copied but auto_ptr does not fulfill this requirement. You should consider to use shared_ptr or unique_ptr. It is suitable for use in containers, because they no longer copy their values, they move them.

Further Reading