Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

format_sql_to (1 of 2 overloads)
PrevUpHomeNext

(EXPERIMENTAL) Composes a SQL query client-side appending it to a format context.

Synopsis

Defined in header <boost/mysql/format_sql.hpp>

template<
    class... Formattable>
void
format_sql_to(
    format_context_base& ctx,
    constant_string_view format_str,
    Formattable&&... args);
Description

Parses format_str as a format string, substituting replacement fields (like {}, {1} or {name}) by formatted arguments, extracted from args.

Formatting is performed as if format_context_base::append_raw and format_context_base::append_value were called on ctx, effectively appending characters to its output string.

Compared to format_sql, this function is more flexible, allowing the following use cases:

  • Appending characters to an existing context. Can be used to concatenate the output of successive format operations efficiently.
  • Using string types different to std::string (works with any basic_format_context).
  • Avoiding exceptions (see basic_format_context::get).
Exception safety

Basic guarantee. Memory allocations may throw.

Errors

PrevUpHomeNext