Use functor deleter for invoking fclose.

This fixes warnings from GCC-14 about ignored attributes
when using std::unique_ptr<FILE>
This commit is contained in:
Eddy Jansson 2024-10-22 17:21:21 +02:00
parent d9b051210b
commit fb3eb7298d

View File

@ -124,8 +124,14 @@ using byte_string_view = std::basic_string_view<uint8_t>;
*
* It implictly converts from an already opened FILE*.
*/
struct file : std::unique_ptr<FILE, decltype(&fclose)> {
file(FILE* f = nullptr) : std::unique_ptr<FILE, decltype(&fclose)>(f, &fclose) {}
struct fclose_deleter {
void operator()(FILE *f) const noexcept {
fclose(f);
}
};
struct file : std::unique_ptr<FILE, struct fclose_deleter> {
file(FILE* f = nullptr) : std::unique_ptr<FILE, struct fclose_deleter>(f) {}
};
/**