carta
freebsd::stringf(3)

freebsd::stringf3

Build a std::string using stdio formatting

Usage

std::string

std::string

Library

library “libutil++”

Overview

These functions construct a std::string object containing a formatted string. The output of the string is dictated by the fmt argument and additional arguments using the same conventions documented in printf(3). The first form provides functionality similar to asprintf(3) and the second form is similar to vasprintf(3).

Return values

These functions return a std::string object.

Exceptions

These functions may throw one of the following exceptions:

[std::bad_alloc]

Failed to allocate memory.

[std::length_error]

The result would exceeed the maximum possible string size.

Examples

std::string s = freebsd::stringf("hello %s", "world");

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