File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ namespace dsr {
3333// Either pass a lambda allocated on the stack or declare a new lambda for the implicit constructor.
3434// Use as an input argument to high level functions when the function will not be saved for later.
3535// Do not save a TemporaryCallback for later, because then it will refer to stack memory that is no longer available.
36- // If TemporaryCallback outlives a lambda's closure allocated as a nameless structure on the stack, .
36+ // If TemporaryCallback outlives a lambda's closure allocated as a nameless structure on the stack, the stack memory will be deallocated before use.
37+ // If you store the callback then it is safer to use StorableCallback, because deleting the copy constructor can not prevent all memory errors.
3738template <typename T>
3839class TemporaryCallback ;
3940template <typename RESULT, typename ... ARGS>
Original file line number Diff line number Diff line change 11
22#include " ../testTools.h"
33#include " ../../DFPSR/collection/List.h"
4- #include " ../../DFPSR/base/TemporaryCallback .h"
4+ #include " ../../DFPSR/base/StorableCallback .h"
55
66static void targetByReference (List<int32_t > &target, int32_t value) {
77 target.push (value);
@@ -50,7 +50,7 @@ START_TEST(List)
5050 ASSERT_EQUAL (integers.length (), 2 );
5151 ASSERT_EQUAL (integers[0 ], 5 );
5252 ASSERT_EQUAL (integers[1 ], 86 );
53- TemporaryCallback <void (int32_t value)> method ([&integers](int32_t value) {
53+ StorableCallback <void (int32_t value)> method ([&integers](int32_t value) {
5454 integers.push (value);
5555 });
5656 method (24 );
You can’t perform that action at this time.
0 commit comments