Complete scoped_ptr.adoc

This commit is contained in:
Peter Dimov committed 2017-06-12 03:12:03 +03:00
1 parent 0dfb4dad0f
commit dea4e8129d
16 files changed
+238 -40

No files matched your search

+12 -14
View File
@@ -11,9 +11,7 @@ http://www.boost.org/LICENSE_1_0.txt
[#introduction]
# Introduction
:toc:
:toc-title:
:idprefix:
:idprefix: intro
Smart pointers are objects which store pointers to dynamically allocated (heap) objects.
They behave much like built-in {cpp} pointers except that they automatically delete the object
@@ -28,22 +26,22 @@ acquisition is initialization" idiom described in Bjarne Stroustrup's "The C++ P
This library provides five smart pointer class templates:
* `scoped_ptr`, used to contain ownership of a dynamically allocated object to the current scope;
* `scoped_array`, which provides scoped ownership for a dynamically allocated array;
* `shared_ptr`, a versatile tool for managing shared ownership of an object or array;
* `weak_ptr`, a non-owning observer to a shared_ptr-managed object that can be promoted temporarily to shared_ptr;
* `intrusive_ptr`, a pointer to objects with an embedded reference count.
* `<<scoped_ptr,scoped_ptr>>`, used to contain ownership of a dynamically allocated object to the current scope;
* `<<scoped_array,scoped_array>>`, which provides scoped ownership for a dynamically allocated array;
* `<<shared_ptr,shared_ptr>>`, a versatile tool for managing shared ownership of an object or array;
* `<<weak_ptr,weak_ptr>>`, a non-owning observer to a shared_ptr-managed object that can be promoted temporarily to shared_ptr;
* `<<intrusive_ptr,intrusive_ptr>>`, a pointer to objects with an embedded reference count.
`shared_ptr` and `weak_ptr` are part of the {cpp} standard since its 2011 iteration.
In addition, the library contains the following supporting utility functions and classes:
* `make_shared`, a factory function for creating objects that returns a `shared_ptr`;
* `make_unique`, a factory function returning `std::unique_ptr`;
* `enable_shared_from_this`, a helper base class that enables the acquisition of a `shared_ptr` pointing to `this`;
* `pointer_to_other`, a helper trait for converting one smart pointer type to another;
* `static_pointer_cast` and companions, generic smart pointer casts;
* `intrusive_ref_counter`, a helper base class containing a reference count.
* `<<make_shared,make_shared>>`, a factory function for creating objects that returns a `shared_ptr`;
* `<<make_unique,make_unique>>`, a factory function returning `std::unique_ptr`;
* `<<enable_shared_from_this,enable_shared_from_this>>`, a helper base class that enables the acquisition of a `shared_ptr` pointing to `this`;
* `<<pointer_to_other,pointer_to_other>>`, a helper trait for converting one smart pointer type to another;
* `<<pointer_cast,static_pointer_cast>>` and companions, generic smart pointer casts;
* `<<intrusive_ref_counter,intrusive_ref_counter>>`, a helper base class containing a reference count.
As a general rule, the destructor or `operator delete` for an object managed by pointers in the library
are not allowed to throw exceptions.