Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KRM7 committed Feb 24, 2024
1 parent c57618f commit 38c0a98
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Objects created with `make_unique_small<T>` are allocated on the stack if:
The size of the stack buffer depends on the architecture and the overall size of the
`small_unique_ptr` object, but the default values on 64 bit architectures will typically be:

- 48 for polymorphic types
- 56 for polymorphic types that implement a virtual `small_unique_ptr_move` method
- `sizeof(T)` for non-polymophic types, with an upper limit of 56
- 56 for array types (rounded down to a multiple of the element size)
- 48 bytes for polymorphic types
- 56 bytes for polymorphic types that implement a virtual `small_unique_ptr_move` method
- `sizeof(T)` for non-polymophic types, with an upper limit of 56 bytes
- 56 bytes for array types (rounded down to a multiple of the element size)

The overall size of a `small_unique_ptr<T, Size>` object for a polymorphic type is:

- `Size` if `T` may be allocated in the stack buffer (64 by default)
- `Size` if `T` may be allocated in the stack buffer (64 bytes by default)
- `sizeof(T*)` otherwise

The interface matches `std::unique_ptr`, except for:
Expand All @@ -41,11 +41,10 @@ so any constexpr usage is subject to the same transient allocation requirements

--------------------------------------------------------------------------------------------------

<details>
<summary>
Example of a simplified <code>move_only_function</code> implementation with small object
optimization using <code>small_unique_ptr</code>
</summary>
#### Usage example

Example of a simplified `move_only_function` implementation with small object
optimization using `small_unique_ptr`:

```cpp
template<typename...>
Expand Down Expand Up @@ -118,4 +117,4 @@ private:
smp::small_unique_ptr<ImplBase> fptr_ = nullptr;
};
```
</details>

0 comments on commit 38c0a98

Please sign in to comment.