carta
freebsd::FILE_up(3)

freebsd::FILE_up3

Std::unique_ptr specialization for stdio file objects

Usage

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

Library

library “libutil++”

Overview

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

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.