What is Nostr?
binkle /
npub1kdy…2hnf
2024-09-06 16:20:12

binkle on Nostr: is there a term for a pointer class which keeps references to all the raw pointers to ...

is there a term for a pointer class which keeps references to all the raw pointers to it and then, upon deallocation, sets all those raw pointers to null? i.e.

MyPtr<int> pVal = new int;
int* pPtr1 = pVal;
int* pPtr2 = pVal;
// pVal now stores int**s pointing to pPtr1 and pPtr2

// do something with pPtr1 and pPtr2 (checking for nullptr as you naturally would)

delete pVal; // during operator delete, pPtr1 and pPtr2 are set to nullptr
Author Public Key
npub1kdyzl44h6mhyl4djtf20w0t7avsy09umshq2k2czjf62ps774phqcd2hnf