std::basic_format_arg(3)
π NAME π
std::basic_format_arg β std::basic_format_arg
Welcome to std::basic_format_arg(3), the page from the C++ Standard Libary manual β yes, βLibaryβ is literally what the header says, not me π. We are gonna get you comfy with formatting arguments, no cap, bestie π
.
β¨ Synopsis β¨
Defined in header <format>.
template< class Context > (since C++20)
class basic_format_arg;
Provides access to a formatting argument.
basic_format_arg objects are typically created by std::make_format_args and accessed through std::visit_format_arg or the visit member functions (since C++26).
A basic_format_arg object behaves as if it stores a std::variant of the following types:
std::monostate(only if the object was default-constructed)boolContext::char_typeintunsigned intlong long intunsigned long long intfloatdoublelong doubleconst Context::char_type*std::basic_string_view<Context::char_type>const void*basic_format_arg::handle
π Member classes π
handleβ type-erased wrapper that allows formatting an object of user-defined type;(C++20);(public member class)
π«Ά Member functions π«Ά
constructorβ constructs astd::basic_format_arg;(C++20);(public member function)operator boolβ checks if the current object holds a formatting argument;(C++20);(public member function)visitβ visit the stored formatting argument;(C++26);(public member function)
π Non-member functions π
visit_format_argβ argument visitation interface for user-defined formatters;(C++20); (deprecated in C++26);(function template)
π§ std::basic_format_arg::basic_format_arg π§
basic_format_arg() noexcept; (since C++20)
Default constructor. Constructs a basic_format_arg that does not hold a formatting argument. The stored object has type std::monostate.
To create a basic_format_arg that holds a formatting argument, std::make_format_args has to be used.
π¦ std::basic_format_arg::operator bool π¦
explicit operator bool() const noexcept; (since C++20)
Checks whether *this holds a formatting argument.
Returns true if *this holds a formatting argument (i.e. the stored object does not have type std::monostate), false otherwise.
β std::basic_format_arg::visit β
template< class Visitor >(since C++26):
decltype(auto) visit( this basic_format_arg arg, Visitor&& vis );
template< class R, class Visitor >(since C++26):
R visit( this basic_format_arg arg, Visitor&& vis );
Applies the visitor vis to the object contained in arg.
The visit functions do not modify the basic_format_arg object on which it is called because a copy of the object is used when calling vis.
- Equivalent to
return std::visit(std::forward<Visitor>(vis), v);, wherevis thestd::variantstored inarg. - Equivalent to
return std::visit<R>(std::forward<Visitor>(vis), v);, wherevis thestd::variantstored inarg.
πΈ Notes πΈ
π Feature-test macro π
__cpp_lib_formatβ value202306L; Std(C++26); FeatureMember visit
π Example π
This section is incomplete Reason: no example
π See also π
basic_format_argsβ(C++20)format_argsβ(C++20)wformat_argsβ(C++20);(class template);class that provides access to all formatting arguments
π Category π
Todo no example
Mwah π β source http://cppreference.com, version/date 2024.06.10, page std::basic_format_arg(3). Slay your formatting era, bestie π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms