From Jason Turner

[util.smartptr.shared.create]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpf8hgl_pa/{from.md → to.md} +15 -9
tmp/tmpf8hgl_pa/{from.md → to.md} RENAMED
@@ -1,35 +1,41 @@
1
  ##### `shared_ptr` creation <a id="util.smartptr.shared.create">[[util.smartptr.shared.create]]</a>
2
 
3
  ``` cpp
4
- template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
 
5
  template<class T, class A, class... Args>
6
  shared_ptr<T> allocate_shared(const A& a, Args&&... args);
7
  ```
8
 
9
  *Requires:* The expression `::new (pv) T(std::forward<Args>(args)...)`,
10
  where `pv` has type `void*` and points to storage suitable to hold an
11
  object of type `T`, shall be well formed. `A` shall be an
12
- *allocator* ([[allocator.requirements]]). The copy constructor and
13
  destructor of `A` shall not throw exceptions.
14
 
15
  *Effects:* Allocates memory suitable for an object of type `T` and
16
- constructs an object in that memory via the placement new expression
17
  `::new (pv) T(std::forward<Args>(args)...)`. The template
18
  `allocate_shared` uses a copy of `a` to allocate memory. If an exception
19
  is thrown, the functions have no effect.
20
 
21
  *Returns:* A `shared_ptr` instance that stores and owns the address of
22
  the newly constructed object of type `T`.
23
 
24
- *Postconditions:* `get() != 0 && use_count() == 1`
25
 
26
  *Throws:* `bad_alloc`, or an exception thrown from `A::allocate` or from
27
  the constructor of `T`.
28
 
29
- *Remarks:* Implementations should perform no more than one memory
30
- allocation. This provides efficiency equivalent to an intrusive smart
31
- pointer.
 
32
 
33
- These functions will typically allocate more memory than `sizeof(T)` to
34
- allow for internal bookkeeping structures such as the reference counts.
 
 
 
 
35
 
 
1
  ##### `shared_ptr` creation <a id="util.smartptr.shared.create">[[util.smartptr.shared.create]]</a>
2
 
3
  ``` cpp
4
+ template<class T, class... Args>
5
+ shared_ptr<T> make_shared(Args&&... args);
6
  template<class T, class A, class... Args>
7
  shared_ptr<T> allocate_shared(const A& a, Args&&... args);
8
  ```
9
 
10
  *Requires:* The expression `::new (pv) T(std::forward<Args>(args)...)`,
11
  where `pv` has type `void*` and points to storage suitable to hold an
12
  object of type `T`, shall be well formed. `A` shall be an
13
+ allocator ([[allocator.requirements]]). The copy constructor and
14
  destructor of `A` shall not throw exceptions.
15
 
16
  *Effects:* Allocates memory suitable for an object of type `T` and
17
+ constructs an object in that memory via the placement *new-expression*
18
  `::new (pv) T(std::forward<Args>(args)...)`. The template
19
  `allocate_shared` uses a copy of `a` to allocate memory. If an exception
20
  is thrown, the functions have no effect.
21
 
22
  *Returns:* A `shared_ptr` instance that stores and owns the address of
23
  the newly constructed object of type `T`.
24
 
25
+ *Postconditions:* `get() != 0 && use_count() == 1`.
26
 
27
  *Throws:* `bad_alloc`, or an exception thrown from `A::allocate` or from
28
  the constructor of `T`.
29
 
30
+ *Remarks:* The `shared_ptr` constructor called by this function enables
31
+ `shared_from_this` with the address of the newly constructed object of
32
+ type `T`. Implementations should perform no more than one memory
33
+ allocation.
34
 
35
+ [*Note 7*: This provides efficiency equivalent to an intrusive smart
36
+ pointer. *end note*]
37
+
38
+ [*Note 8*: These functions will typically allocate more memory than
39
+ `sizeof(T)` to allow for internal bookkeeping structures such as the
40
+ reference counts. — *end note*]
41