[ox/std] Add ox::join(del, strList)
This commit is contained in:
parent
7c6df56414
commit
21883a046e
15
deps/ox/src/ox/std/fmt.hpp
vendored
15
deps/ox/src/ox/std/fmt.hpp
vendored
@ -184,4 +184,19 @@ constexpr StringType sfmt(const char *fmt, Args... args) noexcept {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T = String>
|
||||||
|
constexpr Result<T> join(auto d, const auto &list) {
|
||||||
|
if (!list.size()) {
|
||||||
|
return T("");
|
||||||
|
}
|
||||||
|
T out;
|
||||||
|
out += list.front().value;
|
||||||
|
const auto dLen = ox_strlen(d);
|
||||||
|
for (auto i = 1ul; i < list.size(); ++i) {
|
||||||
|
out += d;
|
||||||
|
out += list[i];
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user