News for hackers. Stuff that matters.
Re:Ask HN: Good C++ code bases to read? by thechao on Wednesday October 28, 2020 @01:23PM (#24921504)
unique_ptr<> let's me override its destructor behavior with a function object that's called on the resource. I mostly use unique_ptr<> for 'wild' mmap()s, FILE*()s, etc.
Re:Ask HN: Good C++ code bases to read? by ncmncm on Wednesday October 28, 2020 @06:10PM (#24924682)
You can make a world of pain in any language.

But you don't have to. If you are trafficking in unique_ptr customizations, you are coding The Hard Way. std::unique_ptr is convenient mechanism, not an organizing principle. Make a named class or class template with a member that is a unique_ptr, and traffic in instances of that class, by value.

If you are working with FILE pointers, you are doing things the hard way. Do you have some library that demands you give it a FILE pointer? Otherwise you probably want a std::filebuf. Likely on the stack, or a member of class that provides a more useful abstraction than a raw file.