mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
Documentation: Update names of RefPtr helper functions
This seems to have been missed when these functions were renamed.
This commit is contained in:
parent
4aaab80649
commit
5fe619de99
1 changed files with 4 additions and 4 deletions
|
@ -90,18 +90,18 @@ Note: A `NonnullRefPtr` can be assigned to a `RefPtr` but not vice versa. To tra
|
||||||
|
|
||||||
### Construction using helper functions
|
### Construction using helper functions
|
||||||
|
|
||||||
There is a `create<T>()` global helper function that constructs a new object and returns it wrapped in a `NonnullRefPtr`. All arguments passed to it are forwarded to `T`'s constructor. If memory cannot be allocated for the object, the program is terminated.
|
There is a `make_ref_counted<T>()` global helper function that constructs a new object and returns it wrapped in a `NonnullRefPtr`. All arguments passed to it are forwarded to `T`'s constructor. If memory cannot be allocated for the object, the program is terminated.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
NonnullRefPtr<Bar> our_object = create<Bar>();
|
NonnullRefPtr<Bar> our_object = make_ref_counted<Bar>();
|
||||||
NonnullRefPtr<Bar> another_owner = our_object;
|
NonnullRefPtr<Bar> another_owner = our_object;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
The `try_create<T>()` function constructs an object wrapped in `RefPtr<T>` which may be null if the allocation does not succeed. This allows the calling code to handle allocation failure as it wishes. All arguments passed to it are forwarded to `T`'s constructor.
|
The `try_make_ref_counted<T>()` function constructs an object wrapped in `RefPtr<T>` which may be null if the allocation does not succeed. This allows the calling code to handle allocation failure as it wishes. All arguments passed to it are forwarded to `T`'s constructor.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
RefPtr<Bar> our_object = try_create<Bar>();
|
RefPtr<Bar> our_object = try_make_ref_counted<Bar>();
|
||||||
if (!our_object) {
|
if (!our_object) {
|
||||||
// handle allocation failure...
|
// handle allocation failure...
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue