]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef __CEPH_STRINGIFY_H |
2 | #define __CEPH_STRINGIFY_H | |
3 | ||
4 | #include <string> | |
5 | #include <sstream> | |
6 | ||
224ce89b WB |
7 | #include "include/types.h" |
8 | ||
7c673cae FG |
9 | template<typename T> |
10 | inline std::string stringify(const T& a) { | |
11 | #if defined(__GNUC__) && !(defined(__clang__) || defined(__INTEL_COMPILER)) | |
12 | static __thread std::ostringstream ss; | |
13 | ss.str(""); | |
14 | #else | |
15 | std::ostringstream ss; | |
16 | #endif | |
17 | ss << a; | |
18 | return ss.str(); | |
19 | } | |
20 | ||
21 | template <class T, class A> | |
22 | T joinify(const A &begin, const A &end, const T &t) | |
23 | { | |
24 | T result; | |
25 | for (A it = begin; it != end; it++) { | |
26 | if (!result.empty()) | |
27 | result.append(t); | |
28 | result.append(*it); | |
29 | } | |
30 | return result; | |
31 | } | |
32 | ||
33 | #endif |