quill
Classes | Functions
custom Namespace Reference

This example shows deferred formatting for a user-defined type while sharing formatting customisation between Quill's bundled fmtquill namespace and standalone fmt through a single free format_as() function. More...

Classes

class  User
 

Functions

std::string format_as (User const &user)
 

Detailed Description

This example shows deferred formatting for a user-defined type while sharing formatting customisation between Quill's bundled fmtquill namespace and standalone fmt through a single free format_as() function.

The important part is that format_as() must live in the same namespace as the user-defined type so that ADL can find it.

DeferredFormatCodec<T> is still used for the Quill side, while format_as() avoids writing both:

as long as format_as() returns a type that both libraries already know how to format, such as std::string, std::string_view or an arithmetic type.