Function catsep

Synopsis

#include <src/c4/format.hpp>

template <class Sep, class Arg, class... Args>
size_t catsep(substr buf, Sep const &C4_RESTRICT sep, Arg const &C4_RESTRICT a, Args const &C4_RESTRICT ...more)

Description

serialize the arguments, concatenating them to the given fixed-size buffer, using a separator between each argument. The buffer size is strictly respected: no writes will occur beyond its end.

Returns
the number of characters needed to write all the arguments into the buffer.
See
c4::catseprs() if instead of a fixed-size buffer, a resizeable container is desired
See
c4::uncatsep() for the inverse function (ie, reading instead of writing)
See
c4::cat() if no separator is needed
See
c4::format() if a format string is desired

Mentioned in

Source

Lines 553-560 in src/c4/format.hpp.

template<class Sep, class Arg, class... Args>
size_t catsep(substr buf, Sep const& C4_RESTRICT sep, Arg const& C4_RESTRICT a, Args const& C4_RESTRICT ...more)
{
    size_t num = to_chars(buf, a);
    buf  = buf.len >= num ? buf.sub(num) : substr{};
    num += detail::catsep_more(buf, sep, more...);
    return num;
}





Add Discussion as Guest

Log in