Reference

freebsd::FILE_up(3)

std::unique_ptr specialization for stdio FILE objects

NAME

freebsd::FILE_up – std::unique_ptr specialization for stdio FILE objects

LIBRARY

library “libutil++”

SYNOPSIS

#include <libutil++.hh>

using FILE_up = std::unique_ptr<FILE, fclose_deleter>;

DESCRIPTION

This class is a specialization of std::unique_ptr for stdio FILE objects. When a FILE object managed by an instance of this class is disposed, fclose(3) is invoked to dispose of the FILE object.

EXAMPLES

freebsd::FILE_up fp(fopen("foo.txt", "w"));
if (!fp)
	err(1, "fopen");
fprintf(fp.get(), "hello0);
// `fp' is implicitly closed on destruction

SEE ALSO

fclose(3), fopen(3)