1.\" 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 2025 Chelsio Communications, Inc. 5.\" Written by: John Baldwin <jhb@FreeBSD.org> 6.\" 7.Dd July 31, 2025 8.Dt FREEBSD::STRINGF 3 9.Os 10.Sh NAME 11.Nm freebsd::stringf 12.Nd build a std::string using stdio formatting 13.Sh LIBRARY 14.Lb libutil++ 15.Sh SYNOPSIS 16.In libutil++.hh 17.Ft std::string 18.Fn freebsd::stringf "const char *fmt" "..." 19.Ft std::string 20.Fn freebsd::stringf "const char *fmt" "va_list ap" 21.Sh DESCRIPTION 22These functions construct a 23.Vt std::string 24object containing a formatted string. 25The output of the string is dictated by the 26.Fa fmt 27argument and additional arguments using the same conventions documented in 28.Xr printf 3 . 29The first form provides functionality similar to 30.Xr asprintf 3 31and the second form is similar to 32.Xr vasprintf 3 . 33.Sh RETURN VALUES 34These functions return a std::string object. 35.Sh EXCEPTIONS 36These functions may throw one of the following exceptions: 37.Bl -tag -width Er 38.It Bq Er std::bad_alloc 39Failed to allocate memory. 40.It Bq Er std::length_error 41The result would exceeed the maximum possible string size. 42.El 43.Sh EXAMPLES 44.Bd -literal -offset indent 45std::string s = freebsd::stringf("hello %s", "world"); 46.Ed 47.Sh SEE ALSO 48.Xr asprintf 3 49