d********t 发帖数: 9628 | | l*****a 发帖数: 14598 | 2 auto_ptr v1(****);
auto_ptr v2=v1;
then v1 will not hold the pointer to the resource.
for share_ptr, you can have several objects to manage the same resource
【在 d********t 的大作中提到】 : 请大侠们不吝赐教!
| q****x 发帖数: 7404 | 3 google
【在 d********t 的大作中提到】 : 请大侠们不吝赐教!
| d********t 发帖数: 9628 | 4 Thanks!
【在 l*****a 的大作中提到】 : auto_ptr v1(****); : auto_ptr v2=v1; : then v1 will not hold the pointer to the resource. : for share_ptr, you can have several objects to manage the same resource
| r****t 发帖数: 10904 | 5 different approaches towards resource bookkeeping, resulting in different copy behaviors. | n**e 发帖数: 116 | 6 boost shared_ptr is a reference counted smart pointer. It can be used in
standard containers, for example, std::vector >.
std::auto_ptr is not a reference counted smart pointer. It does NOT have
ownership, i.e, when a std::auto_ptr is assigned to another one, its
ownership is transferred. As a result, it can NOT be used in standard
containers. | d********t 发帖数: 9628 | 7 唉,STL自己的smart pointer都不能用在自己的container里,太悲催了。
【在 n**e 的大作中提到】 : boost shared_ptr is a reference counted smart pointer. It can be used in : standard containers, for example, std::vector >. : std::auto_ptr is not a reference counted smart pointer. It does NOT have : ownership, i.e, when a std::auto_ptr is assigned to another one, its : ownership is transferred. As a result, it can NOT be used in standard : containers.
|
|