Skip to content

Commit 30cfd83

Browse files
author
Amanda Butler
authored
Make nullptr adjustments to Callback.md
Apply changes from PR #1184 to v5.15.
1 parent ca147fd commit 30cfd83

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/api/platform/Callback.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void run_timer_event(Callback<void(float)> on_timer) {
1414
}
1515
```
1616
17-
The only thing to watch out for is that the Callback type has a null Callback, just like a null function pointer. Uninitialized callbacks are null and assert if you call them. If you want a call to always succeed, you need to check if it is null first.
17+
The only thing to watch out for is that the Callback type has an empty Callback, just like a null function pointer. Default initialized callbacks are empty and assert if you call them. If a callback may be empty, you need to check if it is empty before calling it.
1818
1919
``` c++
2020
void run_timer_event(Callback<void(float)> on_timer) {
@@ -24,6 +24,8 @@ void run_timer_event(Callback<void(float)> on_timer) {
2424
}
2525
```
2626

27+
You can reset Callbacks to empty by assigning `nullptr`.
28+
2729
The Callback class is what’s known in C++ as a “Concrete Type”. That is, the Callback class is lightweight enough to be passed around like an int, pointer or other primitive type.
2830

2931
## Callback class reference

0 commit comments

Comments
 (0)