File indexing completed on 2025-01-18 10:00:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <sstream>
0012 #include <vector>
0013
0014 namespace gloo {
0015
0016 inline void MakeStringInternal(std::stringstream& ) {}
0017
0018 template <typename T>
0019 inline void MakeStringInternal(std::stringstream& ss, const T& t) {
0020 ss << t;
0021 }
0022
0023 template <>
0024 inline void MakeStringInternal(
0025 std::stringstream& ss,
0026 const std::stringstream& t) {
0027 ss << t.str();
0028 }
0029
0030 template <typename T, typename... Args>
0031 inline void
0032 MakeStringInternal(std::stringstream& ss, const T& t, const Args&... args) {
0033 MakeStringInternal(ss, t);
0034 MakeStringInternal(ss, args...);
0035 }
0036
0037 template <typename... Args>
0038 std::string MakeString(const Args&... args) {
0039 std::stringstream ss;
0040 MakeStringInternal(ss, args...);
0041 return std::string(ss.str());
0042 }
0043
0044 template <typename T>
0045 std::string MakeString(const std::vector<T>& v, const std::string& delim=" ") {
0046 std::stringstream ss;
0047 for (auto it = v.begin(); it < v.end(); it++) {
0048 if (it != v.begin()) {
0049 MakeStringInternal(ss, delim);
0050 }
0051 MakeStringInternal(ss, *it);
0052 }
0053 return std::string(ss.str());
0054 }
0055
0056
0057 template <>
0058 inline std::string MakeString(const std::string& str) {
0059 return str;
0060 }
0061 inline std::string MakeString(const char* cstr) {
0062 return std::string(cstr);
0063 }
0064
0065 }