diff options
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..e1c9370 --- /dev/null +++ b/src/util.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef UTIL_H_440DEAA0 | ||
2 | #define UTIL_H_440DEAA0 | ||
3 | |||
4 | #include <string> | ||
5 | #include <sstream> | ||
6 | |||
7 | namespace twitter { | ||
8 | |||
9 | template <class InputIterator> | ||
10 | std::string implode(InputIterator first, InputIterator last, std::string delimiter) | ||
11 | { | ||
12 | std::stringstream result; | ||
13 | |||
14 | for (InputIterator it = first; it != last; it++) | ||
15 | { | ||
16 | if (it != first) | ||
17 | { | ||
18 | result << delimiter; | ||
19 | } | ||
20 | |||
21 | result << *it; | ||
22 | } | ||
23 | |||
24 | return result.str(); | ||
25 | } | ||
26 | |||
27 | }; | ||
28 | |||
29 | #endif /* end of include guard: UTIL_H_440DEAA0 */ | ||