llvm::split

Iterate over partitions of a string split on Separator.

Synopsis

Declared in <llvm/ADT/StringExtras.h>

iterator_range<SplittingIterator>
split(
    StringRef Str,
    StringRef Separator);

Description

Used to permit conveniently iterating over separated strings like so:


for (StringRef x : llvm::split("foo,bar,baz", ","))
  ...;

Note that the passed string must remain valid throughout lifetime of the iterators.

Return Value

A range adaptor for a pair of iterators.

Parameters

NameDescription
StrRepresent a constant reference to a string, i.e. a character array and a length, which need not be null terminated.
SeparatorRepresent a constant reference to a string, i.e. a character array and a length, which need not be null terminated.