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

PrevUpHomeNext

sequence

Creates an object that, when formatted, applies a per-element function to a range.

Synopsis

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_view glue = ", ");
Description

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:

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.

Type requirements

The resulting range and format function should be compatible, and any required copy/move operations should be well defined. Formally:

Exception safety

Basic guarantee. Propagates any exception thrown when constructing the output range and format function.

Convenience header <boost/mysql.hpp>


PrevUpHomeNext