mirror of
https://github.com/boostorg/core.git
synced 2025-07-29 20:37:22 +02:00
Minor documentation update for noinit_adaptor
This commit is contained in:
@ -23,7 +23,7 @@ and whose `destroy(ptr)` invokes `value_type` destructor directly.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
[section Examples]
|
||||
|
||||
The following example shows use of this allocator adaptor to achieve default
|
||||
initialization of elements of a trivial type, which are later assigned values.
|
||||
@ -31,6 +31,7 @@ initialization of elements of a trivial type, which are later assigned values.
|
||||
```
|
||||
#include <boost/core/noinit_adaptor.hpp>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -39,6 +40,25 @@ int main()
|
||||
}
|
||||
```
|
||||
|
||||
The `allocate_shared_noinit` function templates are now implemented simply
|
||||
using `allocate_shared` with `noinit_adaptor`.
|
||||
|
||||
```
|
||||
template<class T, class A>
|
||||
enable_if_t<is_unbounded_array_v<T>, shared_ptr<T> >
|
||||
allocate_shared_noinit(const A& a, size_t n)
|
||||
{
|
||||
return allocate_shared<T>(boost::noinit_adapt(a), n);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
enable_if_t<!is_unbounded_array_v<T>, shared_ptr<T> >
|
||||
allocate_shared_noinit(const A& a)
|
||||
{
|
||||
return allocate_shared<T>(boost::noinit_adapt(a));
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
Reference in New Issue
Block a user