#include <file.h>
FileDeleter is the deleter class for std::unique_ptr of std::FILE.
std::unique_ptr takes a second template argument which determines what happens when the resource it holds needs to be freed. The default implementation calls delete
. For std::FILE the resource needs to be freed with a call to std::fclose instead. Therefore FilePtr requires a custom deleter class to correctly free the resource.
Public Member Functions | |
constexpr | FileDeleter ()=default |
The class has no members, so this is a noop. More... | |
void | operator() (std::FILE *f) const |
Frees the std::FILE resource if it is non-zero. More... | |
|
constexprdefault |
The class has no members, so this is a noop.
|
inline |
Frees the std::FILE resource if it is non-zero.
[in] | f | File resource. |
runtime_error | if the file could not get closed. |