Alias template format
Alias template wformat
Header:
proxy.h
Module:proxy
Namespace:pro::inline v4::skills
Since: 4.0.0
template <class FB>
using format = /* see below */;
template <class FB>
using wformat = /* see below */;
The alias templates format and wformat modify a specialization of basic_facade_builder to allow formatting via the standard formatting functions. Specializations of std::formatter<proxy_indirect_accessor<F>, char> and std::formatter<proxy_indirect_accessor<F>, wchar_t> will be enabled for the 2 skills, respectively, where F is a built facade type.
format and wformat also add constraints to a built facade type F, requiring a contained value of proxy<F> be formattable. Formally, let p be a contained value of proxy<F>, CharT be char (for format) or wchar_t (for wformat), T be std::decay_t<decltype(*std::as_const(p))>, std::formatter<T, CharT> shall be an enabled specialization of std::formatter.
Example
#include <format>
#include <iostream>
#include <proxy/proxy.h>
struct Formattable : pro::facade_builder //
::add_skill<pro::skills::format> //
::build {};
int main() {
pro::proxy<Formattable> p = pro::make_proxy<Formattable>(123);
std::cout << std::format("{}", *p) << "\n"; // Prints "123"
std::cout << std::format("{:*<6}", *p) << "\n"; // Prints "123***"
}