File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ Author: Daniel Poetzl
10
10
#ifndef CPROVER_UTIL_STRING_UTILS_H
11
11
#define CPROVER_UTIL_STRING_UTILS_H
12
12
13
+ #include < ostream>
13
14
#include < string>
14
15
#include < vector>
15
16
@@ -33,4 +34,31 @@ std::string trim_from_last_delimiter(
33
34
const std::string &s,
34
35
const char delim);
35
36
37
+ // / Prints items to an stream, separated by a constant delimiter
38
+ // / \tparam It An iterator type
39
+ // / \tparam Delimiter A delimiter type which supports printing to ostreams
40
+ // / \param os An ostream to write to
41
+ // / \param b Iterator pointing to first item to print
42
+ // / \param e Iterator pointing past last item to print
43
+ // / \param delimiter Object to print between each item in the iterator range
44
+ // / \return A reference to the ostream that was passed in
45
+ template <typename Stream, typename It, typename Delimiter>
46
+ Stream &join_strings (
47
+ Stream &os,
48
+ const It b,
49
+ const It e,
50
+ const Delimiter &delimiter)
51
+ {
52
+ if (b==e)
53
+ {
54
+ return os;
55
+ }
56
+ os << *b;
57
+ for (auto it=std::next (b); it!=e; ++it)
58
+ {
59
+ os << delimiter << *it;
60
+ }
61
+ return os;
62
+ }
63
+
36
64
#endif
You can’t perform that action at this time.
0 commit comments