![]() |
Home | Libraries | People | FAQ | More |
Creates an object that, when formatted, applies a per-element function to a range.
Defined in header <boost/mysql/sequence.hpp>
template< class Range, class FormatFn>format_sequence<sequence_range_t< Range >, typename std::decay< FormatFn >::type > sequence( Range&& range, FormatFn&& fn,constant_string_viewglue = ", ");
Objects returned by this function satisfy Formattable.
Formatting such objects invokes fn
for each element in range,
outputting glue between invocations.
This generates an effect similar to std::ranges::views::join.
By default, this function creates an owning object by decay-copying range into it. C arrays are copied into
std::array objects. This behavior can be disabled
by passing std::reference_wrapper objects, which are converted
to references (as std::make_tuple does). The sequence_range_t type trait accounts
for these transformations.
Formally:
Range is a (possibly
cv-qualified) C array reference (as per std::is_array<Range>), and the array has N elements of type U,
the output range type is std::array<std::remove_cv< U >, N>, and the range is created as if
std::to_array was called.
Range is a std::reference_wrapper<
U >
object, or a reference to one, the output range type is U&.
This effectively disables copying the input range. The resulting object
will be a view type, and the caller is responsible for lifetime management.
std::remove_cvref_t<Range>, and it will be created by forwarding
the passed range.
FormatFn is always decay-copied
into the resulting object.
The glue string is always stored as a view, as it should usually point to a compile-time constant.
The resulting range and format function should be compatible, and any required copy/move operations should be well defined. Formally:
std::decay_t<FormatFn>
should be a formatter function compatible with the elements of the output
range. See format_sequence for the formal
requirements.
Range is a std::reference_wrapper<
U >,
or a reference to one, no further requirements are placed on U.
Range is a lvalue
reference to a C array, its elements should be copy-constructible (as
per std::to_array requirements).
Range is a rvalue
reference to a C array, its elements should be move-constructible (as
per std::to_array requirements).
FormatFn
should be well defined.
Basic guarantee. Propagates any exception thrown when constructing the output range and format function.
Convenience header <boost/mysql.hpp>