std::basic_..._arg::handle(3)
πΈ std::basic_..._arg::handle(3) πΈ
Okay so this one is from the C++ Standard Libary manual β yes, that's their spelling, not mine, bestie π . We're talking about a fancy little type-erased wrapper situation.
β¨ NAME β¨
std::basic_format_arg::handle β std::basic_format_arg::handle
π¦ Synopsis π¦
Defined in header <format>
template< class Context > (since C++20)
class basic_format_arg<Context>::handle;
A type-erased wrapper that allows formatting an object of a user-defined type.
handle objects are typically created by std::make_format_args and accessed through std::visit_format_arg or the visit member functions of std::basic_format_arg (since C++26).
π Member functions π
formatβ formats the referenced object with the given contexts (C++20) (public member function)
std::basic_format_arg<Context>::handle::format
(since C++20)
void format( std::basic_format_parse_context<Context::char_type>& parse_ctx,
Context& format_ctx ) const;
Let:
Tbe the type of the formatting argument,TDbestd::remove_const_t<T>,TQbeconst TDifconst TDsatisfies__formattable_with<Context>orTDotherwise, andrefbe a reference to the formatting argument.
Equivalent to:
typename Context::template formatter_type<TD> f;
parse_ctx.advance_to(f.parse(parse_ctx));
format_ctx.advance_to(f.format(const_cast<TQ&>(static_cast<const TD&>(ref)),
format_ctx));
π Notes π
β οΈ Reference-semantics warning, bestie: ahandlehas reference semantics for the formatted argument and does not extend its lifetime. It is the programmer's responsibility to ensure that the argument outlives the handle. Usually, ahandleis only used within formatting functions.
π See also π
basic_format_arg(C++20) β class template that provides access to a formatting argument for user-defined formatters (class template)make_format_args(C++20),make_wformat_args(C++20) β creates a type-erased object referencing all formatting arguments, convertible toformat_args(function template)
π That's the whole vibe! Source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::basic_..._arg::handle(3). Go slay your formatting, 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