cesium-native 0.43.0
Loading...
Searching...
No Matches
joinToString.h
1#pragma once
2
3#include <numeric>
4#include <string>
5
6namespace CesiumUtility {
17template <class TIterator>
18std::string
19joinToString(TIterator begin, TIterator end, const std::string& separator) {
20 if (begin == end)
21 return std::string();
22
23 std::string first = *begin;
24
25 return std::accumulate(
26 ++begin,
27 end,
28 std::move(first),
29 [&separator](const std::string& acc, const std::string& element) {
30 return acc + separator + element;
31 });
32}
33
43template <class TCollection>
44std::string joinToString(TCollection collection, const std::string& separator) {
45 return joinToString(collection.cbegin(), collection.cend(), separator);
46}
47} // namespace CesiumUtility
Utility classes for Cesium.
std::string joinToString(TIterator begin, TIterator end, const std::string &separator)
Joins multiple elements together into a string, separated by a given separator.