cesium-native  0.41.0
joinToString.h
1 #pragma once
2 
3 #include <numeric>
4 #include <string>
5 
6 namespace CesiumUtility {
17 template <class TIterator>
18 std::string
19 joinToString(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 
43 template <class TCollection>
44 std::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.
Definition: joinToString.h:19