2 ms·
> As far as I know, there is no way to actually force a C++ class to be heap allocated. Make the destructor (and possibly the constructors) private, have publi
by badmintonbaseba 2y ago
> As far as I know, there is no way to actually force a C++ class to be heap allocated.
Make the destructor (and possibly the constructors) private, have public factory functions that hand out unique_ptr with a custom deleter, or define a public destroying operator delete (C++20) and use unique_ptr with its default deleter.