| 50 | |
| 51 | template<template<typename, typename...> typename ContainerType, typename ResultType, typename SeparatorType, typename... Rest> |
| 52 | ResultType Join( |
| 53 | const ContainerType<ResultType, Rest...>& container, |
| 54 | const SeparatorType& separator) |
| 55 | { |
| 56 | if (container.empty()) |
| 57 | return ResultType {}; |
| 58 | |
| 59 | const auto sepratorLength = StringLength(separator); |
| 60 | const auto totalSeparatorLength = sepratorLength * (container.size() - 1); |
| 61 | |
| 62 | ResultType result; |
| 63 | |
| 64 | const auto size = std::accumulate( |
| 65 | container.begin(), container.end(), totalSeparatorLength, |
| 66 | [](size_t size, const ResultType& item) |
| 67 | { return size + StringLength(item); }); |
| 68 | |
| 69 | result.reserve(size); |
| 70 | |
| 71 | bool first = true; |
| 72 | for (const auto& item : container) |
| 73 | { |
| 74 | if (!first) |
| 75 | result += separator; |
| 76 | result += item; |
| 77 | first = false; |
| 78 | } |
| 79 | |
| 80 | return result; |
| 81 | } |
| 82 | |
| 83 | STRING_UTILS_API std::string ToLower(const std::string& str); |
| 84 | STRING_UTILS_API std::string ToLower(const std::string_view& str); |
no test coverage detected