Jlm
Loading...
Searching...
No Matches
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
11namespace jlm::util
12{
13
14template<typename... Args>
15static inline void
16format_to_stream(std::ostream & os, Args... args);
17
18template<typename Arg>
19static inline void
20format_to_stream(std::ostream & os, const Arg & arg)
21{
22 os << arg;
23}
24
25template<typename Arg, typename... Args>
26static inline void
27format_to_stream(std::ostream & os, const Arg & arg, Args... args)
28{
29 os << arg;
30 format_to_stream(os, args...);
31}
32
33template<typename... Args>
34static inline std::string
35strfmt(Args... args)
36{
37 std::ostringstream os;
38 format_to_stream(os, args...);
39 return os.str();
40}
41
48std::string
49CreateRandomAlphanumericString(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)