From 871e3465c2900c89cce7e2aeda0b4e53482b5640 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 20 Jul 2022 14:38:00 -0700 Subject: [PATCH] Add comments for specialized versions of util::split --- src/util.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/util.h b/src/util.h index 24f2400272..bdea606a8b 100644 --- a/src/util.h +++ b/src/util.h @@ -607,16 +607,40 @@ template std::vector split(T s, const T& delim) return l; } +/** + * Specialized version of util::split that allows for differing string and delimiter types, + * with the requirement that the delimiter must be of the same type as what is stored in the + * string type. For example, this allows passing a std::string as the string to split with + * a const char* delimiter. + * + * @param s the string to split + * @param delim the delimiter to split the string on + * @return a vector of containing the separate parts of the string. + */ template std::vector split(T s, U delim) { return split(s, T{delim}); } +/** + * Specialized version of util::split that takes a const char* string and delimiter. + * + * @param s the string to split + * @param delim the delimiter to split the string on + * @return a vector of string_view objects containing the separate parts of the string. + */ inline std::vector split(const char* s, const char* delim) { return split(std::string_view(s), std::string_view(delim)); } +/** + * Specialized version of util::split that takes a const wchar_t* string and delimiter. + * + * @param s the string to split + * @param delim the delimiter to split the string on + * @return a vector of wstring_view objects containing the separate parts of the string. + */ inline std::vector split(const wchar_t* s, const wchar_t* delim) { return split(std::wstring_view(s), std::wstring_view(delim));