
Sohail Somani
[...] template<typename T> struct DeletingDeleter { [...] };
struct FileCloser { [...] };
template
struct scoped_ptr { [...] }; typedef scoped_ptr
file_ptr;
I also tried to make my own raii strategy, and as in your example above, I put the deleter as part of the template parameters, directly in the smart pointer interface. The side effect of it is that if you use a boost binder that on its turn uses one or more template functions or classes, you end up with many lines to describe the template specializations (or call it "template prototyping"), or as in your case, many lines of extra structure and classes. (I wished the new "auto" feature in C++0x existed!) Still, the method used by shared_ptr<> is very useful: it hides the deleter in a template class the derives from a normal base class that is a member of the shared_ptr<>. So when you defines the smart pointer with a deleter, you avoid describing the full specialization. That is the reason why I suggested to reuse the shared_ptr<> astuce in scoped_ptr<>.