I wonder if it'd work to add a guaranteed non-null pointer to C++ like this:

https://gist.github.com/uliwitness/931873c0b2edaa537b905418a024be04

#CPlusPlus #optionals #shared_ptr

Update: The gist is now fully compiling code.

nonoptional_shared_ptr.cpp

GitHub Gist: instantly share code, notes, and snippets.

Gist

TIL that std::shared_ptr has a custom "deleter" function you can set for actually deleting the memory. Seems to make for a pretty nice way to create a memory buffer manager. I need to shuffle a lot of smallish buffers and allocating/freeing memory all the time is not particularly efficient, especially not when time is essential. I guess this is nothing new to the veterans out there, but it'll make my life easier.

#cpp #std #shared_ptr

weak_from_thisか・・・なるほど。
enable_shared_from_this の C++2011(14) と C++2017 との相違点 by yuki12 https://qiita.com/yuki12/items/ccbe5cf8cf06ffa1fc66 #Qiita #Cpp #Cpp11 #Cpp17 #shared_ptr
enable_shared_from_this の C++2011(14) と C++2017 との相違点 - Qiita

クラステンプレート ```std::enable_shared_from_this``` とは、```std::shared_ptr``` で所有権を管理している場合、これを継承するとインスタンス自身から ```shared_ptr`...