Reference Well, how does the custom deleter of std::unique_ptr work?
Constructor
std::unique_ptr<ErrorHandling> error_;
RecursiveDescentParser::RecursiveDescentParser(std::string inputStream, bool fileService,
boost::optional<std::string> filePathName, std::ofstream &writer){
if (fileService == true){
error_(new ErrorHandling(fileService, writer)); <---- compiler error
}
else{
error_(new ErrorHandling(fileService, std::ofstream())); <---- compiler error
}
}
Compiler error
Error 1 error C2247: 'std::default_delete<_Ty>::operator ()' not accessible because 'std::unique_ptr<_Ty>' uses 'private' to inherit from 'std::_Unique_ptr_base<_Ty,_Dx,_Empty_deleter>'
Cause of error described here.
I decided since 'std::default_delete<_Ty>::operator ()
is private
because child class (std::unique_ptr
in this case) has specified private inheritance
that I would write my own custom deleter. Problem is I am too uncomfortable with the syntax and notation to succeed.