Jlm
strfmt.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #ifndef JLM_UTIL_STRFMT_HPP
7 #define JLM_UTIL_STRFMT_HPP
8 
9 #include <sstream>
10 
11 namespace jlm::util
12 {
13 
14 template<typename... Args>
15 static inline void
16 format_to_stream(std::ostream & os, Args... args);
17 
18 template<typename Arg>
19 static inline void
20 format_to_stream(std::ostream & os, const Arg & arg)
21 {
22  os << arg;
23 }
24 
25 template<typename Arg, typename... Args>
26 static inline void
27 format_to_stream(std::ostream & os, const Arg & arg, Args... args)
28 {
29  os << arg;
30  format_to_stream(os, args...);
31 }
32 
33 template<typename... Args>
34 static inline std::string
35 strfmt(Args... args)
36 {
37  std::ostringstream os;
38  format_to_stream(os, args...);
39  return os.str();
40 }
41 
48 std::string
49 CreateRandomAlphanumericString(std::size_t length);
50 
51 }
52 
53 #endif
std::string CreateRandomAlphanumericString(std::size_t length)
Definition: strfmt.cpp:15
static std::string strfmt(Args... args)
Definition: strfmt.hpp:35
static void format_to_stream(std::ostream &os, Args... args)