absl::MaxSplits

A delimiter that limits the number of matches which can occur to the passed limit.

Synopsis

Declared in <absl/strings/str_split.h>

template<typename Delimiter>
/* implementation-defined */
MaxSplits(
    Delimiter delimiter,
    int limit);

Description

The last element in the returned collection will contain all remaining unsplit pieces, which may contain instances of the delimiter. The collection will contain at most limit + 1 elements. Example:

using absl::MaxSplits; std::vector<std::string> v = absl::StrSplit("a,b,c", MaxSplits(',', 1));

// v[0]== "a", v[1]== "b,c"

Return Value

A delimiter wrapping delimiter with the given match limit.

Parameters

NameDescription
delimiterThe underlying delimiter whose matches are limited.
limitThe maximum number of matches allowed.