Various documentation fixes

This commit is contained in:
Glen Fernandes
2017-06-14 10:27:46 -04:00
parent 8096b7d324
commit c1820b4a27
2 changed files with 68 additions and 53 deletions

View File

@@ -55,36 +55,43 @@ types.
[subs=+quotes] [subs=+quotes]
``` ```
namespace boost { namespace boost {
// only if T is not an array type
template<class T, class... Args> template<class T, class... Args>
shared_ptr<T> make_shared(Args&&... args); shared_ptr<T> make_shared(Args&&... args);
template<class T, class A, class... Args> template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args); shared_ptr<T> allocate_shared(const A& a, Args&&... args);
// only if T is an array type of the form U[]
template<class T> template<class T>
shared_ptr<T> make_shared(std::size_t n); shared_ptr<T> make_shared(std::size_t n);
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, std::size_t n); shared_ptr<T> allocate_shared(const A& a, std::size_t n);
// only if T is an array type of the form U[N]
template<class T> template<class T>
shared_ptr<T> make_shared(); shared_ptr<T> make_shared();
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared(const A& a); shared_ptr<T> allocate_shared(const A& a);
// only if T is an array type of the form U[]
template<class T> template<class T>
shared_ptr<T> make_shared(std::size_t n, _see below_ v); shared_ptr<T> make_shared(std::size_t n, _see below_ v);
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, std::size_t n, _see below_ v); shared_ptr<T> allocate_shared(const A& a, std::size_t n, _see below_ v);
// only if T is an array type of the form U[N]
template<class T> template<class T>
shared_ptr<T> make_shared(_see below_ v); shared_ptr<T> make_shared(_see below_ v);
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, _see below_ v); shared_ptr<T> allocate_shared(const A& a, _see below_ v);
// only if T is not an array type of the form U[]
template<class T> template<class T>
shared_ptr<T> make_shared_noinit(); shared_ptr<T> make_shared_noinit();
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared_noinit(const A& a); shared_ptr<T> allocate_shared_noinit(const A& a);
// only if T is an array type of the form U[N]
template<class T> template<class T>
shared_ptr<T> make_shared_noinit(std::size_t n); shared_ptr<T> make_shared_noinit(std::size_t n);
template<class T, class A> template<class T, class A>
@@ -92,7 +99,7 @@ namespace boost {
} }
``` ```
## Free Functions ## Common Requirements
The common requirements that apply to all `make_shared` and `allocate_shared` The common requirements that apply to all `make_shared` and `allocate_shared`
overloads, unless specified otherwise, are described below. overloads, unless specified otherwise, are described below.
@@ -100,8 +107,8 @@ overloads, unless specified otherwise, are described below.
Requires:: `A` shall be an _allocator_. The copy constructor and destructor Requires:: `A` shall be an _allocator_. The copy constructor and destructor
of `A` shall not throw exceptions. of `A` shall not throw exceptions.
Effects:: Allocates memory for an object of type `T` or `n` objects of `_U_` Effects:: Allocates memory for an object of type `T` or `n` objects of `U`
(if `T` is an array type of the form `__U__[]` and `n` is determined by (if `T` is an array type of the form `U[]` and `n` is determined by
arguments, as specified by the concrete overload). The object is initialized arguments, as specified by the concrete overload). The object is initialized
from arguments as specified by the concrete overload. Uses a rebound copy of from arguments as specified by the concrete overload. Uses a rebound copy of
`a` (for an unspecified `value_type`) to allocate memory. If an exception is `a` (for an unspecified `value_type`) to allocate memory. If an exception is
@@ -110,48 +117,49 @@ thrown, the functions have no effect.
Returns:: A `shared_ptr` instance that stores and owns the address of the Returns:: A `shared_ptr` instance that stores and owns the address of the
newly constructed object. newly constructed object.
Postconditions:: `__r__.get() != 0` and `__r__.use_count() == 1`, where `_r_` Postconditions:: `r.get() != 0` and `r.use_count() == 1`, where `r`
is the return value. is the return value.
Throws:: An exception thrown from `A::allocate`, or from the initialization Throws:: `std::bad_alloc`, an exception thrown from `A::allocate`, or from the
of the object. initialization of the object.
Remarks:: Remarks::
* Performs no more than one memory allocation. This provides efficiency * Performs no more than one memory allocation. This provides efficiency
equivalent to an intrusive smart pointer. equivalent to an intrusive smart pointer.
* The type of `v` is equivalent to `const std::remove_extent_t<T>&`.
* When an object of an array type is specified to be initialized to a value of * When an object of an array type is specified to be initialized to a value of
the same type `v`, this shall be interpreted to mean that each array element the same type `v`, this shall be interpreted to mean that each array element
of the object is initialized to the corresponding element from `v`. of the object is initialized to the corresponding element from `v`.
* When an object of an array type is specified to be value-initialized, this * When an object of an array type is specified to be value-initialized, this
shall be interpreted to mean that each array element of the object is shall be interpreted to mean that each array element of the object is
value-initialized. value-initialized.
* When a (sub)object of non-array type `_U_` is specified to be initialized to * When a (sub)object of non-array type `U` is specified to be initialized to
a value `v`, or constructed from `args$$...$$`, `make_shared` shall perform a value `v`, or constructed from `args$$...$$`, `make_shared` shall perform
this initialization via the expression `::new(__p__) __U__(__expr__)` (where this initialization via the expression `::new(p) U(expr)` (where
`_expr_` is `v` or `std::forward<Args>(args)$$...$$)` respectively) and `_p_` `_expr_` is `v` or `std::forward<Args>(args)$$...$$)` respectively) and `p`
has type `void*` and points to storage suitable to hold an object of type has type `void*` and points to storage suitable to hold an object of type
`_U_`. `U`.
* When a (sub)object of non-array type `_U_` is specified to be initialized to * When a (sub)object of non-array type `U` is specified to be initialized to
a value `v`, or constructed from `args$$...$$`, `allocate_shared` shall a value `v`, or constructed from `args$$...$$`, `allocate_shared` shall
perform this initialization via the expression perform this initialization via the expression
`std::allocator_traits<__A2__>::construct(__a2__, __p__, __expr__)` (where `std::allocator_traits<A2>::construct(a2, p, expr)` (where
`_expr_` is `v` or `std::forward<Args>(args)$$...$$)` respectively), `_p_` `_expr_` is `v` or `std::forward<Args>(args)$$...$$)` respectively), `p`
points to storage suitable to hold an object of type `_U_`, and `_a2_` of points to storage suitable to hold an object of type `U`, and `a2` of
type `_A2_` is a rebound copy `a` such that its `value_type` is `_U_`. type `A2` is a rebound copy `a` such that its `value_type` is `U`.
* When a (sub)object of non-array type `_U_` is specified to be * When a (sub)object of non-array type `U` is specified to be
default-initialized, `make_shared_noinit` and `allocate_shared_noinit` shall default-initialized, `make_shared_noinit` and `allocate_shared_noinit` shall
perform this initialization via the expression `::new(__p__) __U__`, where perform this initialization via the expression `::new(p) U`, where
`_p_` has type `void*` and points to storage suitable to hold an object of `p` has type `void*` and points to storage suitable to hold an object of
type `_U_`. type `U`.
* When a (sub)object of non-array type `_U_` is specified to be * When a (sub)object of non-array type `U` is specified to be
value-initialized, `make_shared` shall perform this initialization via the value-initialized, `make_shared` shall perform this initialization via the
expression `::new(__p__) __U__()`, where `_p_` has type `void*` and points to expression `::new(p) U()`, where `p` has type `void*` and points to
storage suitable to hold an object of type `_U_`. storage suitable to hold an object of type `U`.
* When a (sub)object of non-array type `_U_` is specified to be * When a (sub)object of non-array type `U` is specified to be
value-initialized, `allocate_shared` shall perform this initialization via the value-initialized, `allocate_shared` shall perform this initialization via the
expression `std::allocator_traits<__A2__>::construct(__a2__, __p__)`, where expression `std::allocator_traits<A2>::construct(a2, p)`, where
`p` points to storage suitable to hold an object of type `_U_` and `_a2_` of `p` points to storage suitable to hold an object of type `U` and `a2` of
type `_A2_` is a rebound copy of `a` such that its value_type is `_U_`. type `A2` is a rebound copy of `a` such that its value_type is `U`.
* Array elements are initialized in ascending order of their addresses. * Array elements are initialized in ascending order of their addresses.
* When the lifetime of the object managed by the return value ends, or when * When the lifetime of the object managed by the return value ends, or when
the initialization of an array element throws an exception, the initialized the initialization of an array element throws an exception, the initialized
@@ -161,6 +169,8 @@ NOTE: These functions will typically allocate more memory than the total size
of the element objects to allow for internal bookkeeping structures such as of the element objects to allow for internal bookkeeping structures such as
the reference counts. the reference counts.
## Free Functions
``` ```
template<class T, class... Args> template<class T, class... Args>
shared_ptr<T> make_shared(Args&&... args); shared_ptr<T> make_shared(Args&&... args);
@@ -190,9 +200,9 @@ template<class T, class A>
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[]`. `T` is an array type of the form `U[]`.
Returns::: A `shared_ptr` to a sequence of `n` value-initialized objects of Returns::: A `shared_ptr` to a sequence of `n` value-initialized objects of
type `_U_`. type `U`.
Examples::: Examples:::
* `auto p = make_shared<double[]>(1024);` * `auto p = make_shared<double[]>(1024);`
* `auto p = make_shared<double[][2][2]>(6);` * `auto p = make_shared<double[][2][2]>(6);`
@@ -208,9 +218,9 @@ template<class T, class A>
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[__N__]`. `T` is an array type of the form `U[N]`.
Returns::: A `shared_ptr` to a sequence of `_N_` value-initialized objects of Returns::: A `shared_ptr` to a sequence of `N` value-initialized objects of
type `_U_`. type `U`.
Examples::: Examples:::
* `auto p = make_shared<double[1024]>();` * `auto p = make_shared<double[1024]>();`
* `auto p = make_shared<double[6][2][2]>();` * `auto p = make_shared<double[6][2][2]>();`
@@ -218,18 +228,18 @@ Examples:::
[subs=+quotes] [subs=+quotes]
``` ```
template<class T> template<class T>
shared_ptr<T> make_shared(std::size_t n, _see below_ v); shared_ptr<T> make_shared(std::size_t n, _see above_ v);
``` ```
:: ::
[subs=+quotes] [subs=+quotes]
``` ```
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, std::size_t n, _see below_ v); shared_ptr<T> allocate_shared(const A& a, std::size_t n, _see above_ v);
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[]`. `T` is an array type of the form `U[]`.
Returns::: A `shared_ptr` to a sequence of `n` objects of type `_U_`, each Returns::: A `shared_ptr` to a sequence of `n` objects of type `U`, each
initialized to `v`. initialized to `v`.
Examples::: Examples:::
* `auto p = make_shared<double[]>(1024, 1.0);` * `auto p = make_shared<double[]>(1024, 1.0);`
@@ -239,18 +249,18 @@ Examples:::
[subs=+quotes] [subs=+quotes]
``` ```
template<class T> template<class T>
shared_ptr<T> make_shared(_see below_ v); shared_ptr<T> make_shared(_see above_ v);
``` ```
:: ::
[subs=+quotes] [subs=+quotes]
``` ```
template<class T, class A> template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, _see below_ v); shared_ptr<T> allocate_shared(const A& a, _see above_ v);
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[__N__]`. `T` is an array type of the form `U[N]`.
Returns::: A `shared_ptr` to a sequence of `_N_` objects of type `_U_`, each Returns::: A `shared_ptr` to a sequence of `N` objects of type `U`, each
initialized to `v`. initialized to `v`.
Examples::: Examples:::
* `auto p = make_shared<double[1024]>(1.0);` * `auto p = make_shared<double[1024]>(1.0);`
@@ -268,9 +278,9 @@ template<class T, class A>
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is not an array type, or an array type of the `__U__[__N__]`. `T` is not an array type, or an array type of the `U[N]`.
Returns::: A `shared_ptr` to a default-initialized object of type `T`, or a Returns::: A `shared_ptr` to a default-initialized object of type `T`, or a
sequence of `_N_` default-initialized objects of type `_U_`, respectively. sequence of `N` default-initialized objects of type `U`, respectively.
Example::: `auto p = make_shared_noinit<double[1024]>();` Example::: `auto p = make_shared_noinit<double[1024]>();`
``` ```
@@ -284,7 +294,7 @@ template<class T, class A>
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[]`. `T` is an array type of the form `U[]`.
Returns::: A `shared_ptr` to a sequence of `_n_` default-initialized objects Returns::: A `shared_ptr` to a sequence of `_n_` default-initialized objects
of type `_U_`. of type `U`.
Example::: `auto p = make_shared_noinit<double[]>(1024);` Example::: `auto p = make_shared_noinit<double[]>(1024);`

View File

@@ -40,20 +40,25 @@ feature with `std::make_unique`.
[subs=+quotes] [subs=+quotes]
``` ```
namespace boost { namespace boost {
// only if T is not an array type
template<class T, class... Args> template<class T, class... Args>
std::unique_ptr<T> make_unique(Args&&... args); std::unique_ptr<T> make_unique(Args&&... args);
// only if T is not an array type
template<class T> template<class T>
std::unique_ptr<T> make_unique(_see below_ v); std::unique_ptr<T> make_unique(_see below_ v);
// only if T is an array type of the form U[]
template<class T> template<class T>
std::unique_ptr<T> make_shared(std::size_t n); std::unique_ptr<T> make_unique(std::size_t n);
// only if T is not an array type
template<class T> template<class T>
std::unique_ptr<T> make_shared_noinit(); std::unique_ptr<T> make_unique_noinit();
// only if T is an array type of the form U[]
template<class T> template<class T>
std::unique_ptr<T> make_shared_noinit(std::size_t n); std::unique_ptr<T> make_unique_noinit(std::size_t n);
} }
``` ```
@@ -78,7 +83,7 @@ template<class T>
Remarks::: Remarks:::
* These overloads shall only participate in overload resolution when `T` is * These overloads shall only participate in overload resolution when `T` is
not an array type. not an array type.
* The type of `v` is `std::remove_reference_t<T>&&`. * The type of `v` is equivalent to `std::remove_reference_t<T>&&`.
Returns::: `std::unique_ptr<T>(new T(std::move(v))`. Returns::: `std::unique_ptr<T>(new T(std::move(v))`.
Example::: `auto p = make_unique<std::vector<int> >({1, 2});` Example::: `auto p = make_unique<std::vector<int> >({1, 2});`
@@ -88,8 +93,8 @@ template<class T>
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[]`. `T` is an array type of the form `U[]`.
Returns::: `std::unique_ptr<__U__[]>(new __U__[n]())`. Returns::: `std::unique_ptr<U[]>(new U[n]())`.
Example::: `auto p = make_unique<double[]>(1024);` Example::: `auto p = make_unique<double[]>(1024);`
``` ```
@@ -108,6 +113,6 @@ template<class T>
``` ```
:: ::
Remarks::: These overloads shall only participate in overload resolution when Remarks::: These overloads shall only participate in overload resolution when
`T` is an array type of the form `__U__[]`. `T` is an array type of the form `U[]`.
Returns::: `std::unique_ptr<__U__[]>(new __U__[n])`. Returns::: `std::unique_ptr<U[]>(new U[n])`.
Example::: `auto p = make_unique_noinit<double[]>(1024);` Example::: `auto p = make_unique_noinit<double[]>(1024);`