Open squinkylabs opened 1 year ago
This is a great idea. I studied the smart pointers quite a bit before getting started but didn't have the confidence to put them to use. I'll keep this one open because it's worth doing at some point.
I usually use std::shared_ptr for everything. Some ppl who really care about the last drop of efficiency use std::unique_ptr. unique_ptr is what you are supposed to use if there is only one client that needs to point to an object. But it's slightly more difficult to use (for me, anyway).
This code uses all "naked" pointers. The potential problem with this is that you forget to delete them, or you forget to initialize them. Or you shared objects ownership between multiple objects.
I wouldn't change all your code right now, but it's something to think about in the fugure.
Of course many Rack APIs will give you a pointer to something, but you don't own it, so you would not want to use one of these kinds of pointers, in effect messing up memory ownership>