Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Stroika::Foundation::Characters::FormatLiteral< LITERAL > Struct Template Reference

what "..."_f is: a format string whose literal is part of its type - so it is widened (if narrow) at compile time, and checked against the arguments of each call at compile time, as std::format checks its format string More...

#include <Format.h>

Inheritance diagram for Stroika::Foundation::Characters::FormatLiteral< LITERAL >:
Stroika::Foundation::Characters::FormatString< wchar_t >

Public Member Functions

template<Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA(IFormattable)... ARGS>
String operator() (ARGS &&... args) const
 
template<Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA(IFormattable)... ARGS>
String operator() (const locale &loc, ARGS &&... args) const
 As FormatString's, but checked at compile time.
 
 operator FormatString< char > () const
 
- Public Member Functions inherited from Stroika::Foundation::Characters::FormatString< wchar_t >
constexpr wstring_view get () const
 
constexpr qStroika_Foundation_Characters_FMT_PREFIX_::wstring_view getx_ () const
 the format string as the formatting library's own wstring_view (std's, or fmtlib's) - only for calling Common::StdCompat::vformat directly
 
String operator() (ARGS &&... args) const
 format args - checked against the format string at run time: a mismatch throws format_error (a FormatLiteral, "..."_f, checks at compile time)
 
String operator() (const locale &loc, ARGS &&... args) const
 As above, with a locale.
 

Static Public Member Functions

template<typename... ARGS>
static consteval void CheckArgs ()
 Unless the format string suits arguments of types ARGS..., a compile-time error - this is an immediate function.
 

Detailed Description

template<Private_::FixedString_ LITERAL>
struct Stroika::Foundation::Characters::FormatLiteral< LITERAL >

what "..."_f is: a format string whose literal is part of its type - so it is widened (if narrow) at compile time, and checked against the arguments of each call at compile time, as std::format checks its format string

It is a FormatString<wchar_t>, so anything taking a FormatString takes one - but only what takes a FormatLiteral checks the arguments: its operator (), Format, DbgTrace, TraceContextBumper, Logger::Log and WebServer::Response::write.

Note
Before Stroika v3.0d25, "..."_f was a FormatString<char> (or <wchar_t>): its format string checked only at run time (a mistake threw format_error), and a narrow one widened - into a newly allocated buffer - each time it ran.
Example Usage
String a = "provider={}"_f (provider);
DbgTrace ("provider={}"_f, provider);
// String b = "{} {}"_f (provider); // does not compile: two arguments wanted, one given
#define DbgTrace
Definition Trace.h:327
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201

Definition at line 205 of file Characters/Format.h.

Member Function Documentation

◆ operator()()

template<Private_::FixedString_ LITERAL>
template<Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA(IFormattable)... ARGS>
String Stroika::Foundation::Characters::FormatLiteral< LITERAL >::operator() ( ARGS &&...  args) const

As FormatString's operator (), but args are checked against the format string at compile time

Definition at line 197 of file Characters/Format.inl.

◆ operator FormatString< char >()

template<Private_::FixedString_ LITERAL>
requires (same_as<typename decltype (LITERAL)::CharType, char>)
Stroika::Foundation::Characters::FormatLiteral< LITERAL >::operator FormatString< char > ( ) const

For code that names FormatString<char>, as a narrow "..."_f was before Stroika v3.0d25: this one copies the literal

Definition at line 243 of file Characters/Format.inl.


The documentation for this struct was generated from the following files: