Wayverb
string_builder.h
1 #pragma once
2 
3 #include "utilities/for_each.h"
4 
5 #include <sstream>
6 
7 namespace util {
8 
9 template <typename... Ts>
10 inline std::ostream& to_stream(std::ostream& os, const Ts&... ts) {
11  for_each_params([&os](const auto& i) { os << i; }, ts...);
12  return os;
13 }
14 
15 template <typename... Ts>
16 inline std::string build_string(const Ts&... ts) {
17  std::stringstream ss;
18  to_stream(ss, ts...);
19  return ss.str();
20 }
21 
22 struct Bracketer final {
23  explicit Bracketer(std::ostream& os,
24  const char* open = "{",
25  const char* closed = "}");
26 
27  ~Bracketer();
28 
29 private:
30  std::ostream& os;
31  const char* closed;
32 };
33 
34 } // namespace util
Definition: allocator.h:6
Definition: string_builder.h:22