Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/ADT/StringExtras.h
Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | inline std::string join_items(Sep Separator, Args &&... Items) { | ||||
return Result; | return Result; | ||||
} | } | ||||
/// A helper class to return the specified delimiter string after the first | /// A helper class to return the specified delimiter string after the first | ||||
/// invocation of operator StringRef(). Used to generate a comma-separated | /// invocation of operator StringRef(). Used to generate a comma-separated | ||||
/// list from a loop like so: | /// list from a loop like so: | ||||
/// | /// | ||||
/// \code | /// \code | ||||
/// SubsequentDelim SD; | /// ListSeparator SD; | ||||
/// for (auto &I : C) | /// for (auto &I : C) | ||||
/// OS << SD << I.getName(); | /// OS << SD << I.getName(); | ||||
/// \end | /// \end | ||||
class SubsequentDelim { | class ListSeparator { | ||||
bool First = true; | bool First = true; | ||||
StringRef Delim; | StringRef Separator; | ||||
public: | public: | ||||
SubsequentDelim(StringRef Delim = ", ") : Delim(Delim) {} | ListSeparator(StringRef Separator = ", ") : Separator(Separator) {} | ||||
operator StringRef() { | operator StringRef() { | ||||
if (First) { | if (First) { | ||||
First = false; | First = false; | ||||
return {}; | return {}; | ||||
} | } | ||||
return Delim; | return Separator; | ||||
} | } | ||||
}; | }; | ||||
} // end namespace llvm | } // end namespace llvm | ||||
#endif // LLVM_ADT_STRINGEXTRAS_H | #endif // LLVM_ADT_STRINGEXTRAS_H |