Reference

freebsd::stringf(3)

build a std::string using stdio formatting

NAME

freebsd::stringf – build a std::string using stdio formatting

LIBRARY

library “libutil++”

SYNOPSIS

#include <libutil++.hh>

std::string

freebsd::stringf(const char *fmt, ...);

std::string

freebsd::stringf(const char *fmt, va_list ap);

DESCRIPTION

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");

SEE ALSO

asprintf(3)