---
name: "freebsd::FILE_up"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/freebsd::FILE_up"
---

# 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)](/fclose/3.md) 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)](/fclose/3.md), [fopen(3)](/fopen/3.md)
