CppCommon  1.0.4.1
C++ Common Library
format.inl
Go to the documentation of this file.
1 
9 namespace CppCommon {
10 
11 template <typename... T>
12 inline std::string format(fmt::format_string<T...> pattern, T&&... args)
13 {
14  return fmt::vformat(pattern, fmt::make_format_args(args...));
15 }
16 
17 template <typename... T>
18 inline std::wstring format(fmt::wformat_string<T...> pattern, T&&... args)
19 {
20  return fmt::vformat<wchar_t>(pattern, fmt::make_format_args<fmt::wformat_context>(args...));
21 }
22 
23 template <typename... T>
24 inline void print(fmt::format_string<T...> pattern, T&&... args)
25 {
26  return fmt::vprint(pattern, fmt::make_format_args(args...));
27 }
28 
29 template <typename... T>
30 inline void print(fmt::wformat_string<T...> pattern, T&&... args)
31 {
32  return fmt::vprint<wchar_t>(pattern, fmt::make_format_args<fmt::wformat_context>(args...));
33 }
34 
35 template <typename TOutputStream, typename... T>
36 inline void print(TOutputStream& stream, fmt::format_string<T...> pattern, T&&... args)
37 {
38  return fmt::vprint(stream, pattern, fmt::make_format_args(args...));
39 }
40 
41 template <typename TOutputStream, typename... T>
42 inline void print(TOutputStream& stream, fmt::wformat_string<T...> pattern, T&&... args)
43 {
44  return fmt::vprint<wchar_t>(stream, pattern, fmt::make_format_args<fmt::wformat_context>(args...));
45 }
46 
47 } // namespace CppCommon
48 
50 
51 using namespace fmt::literals;
52 
C++ Common project definitions.
Definition: token_bucket.h:15
std::string format(fmt::format_string< T... > pattern, T &&... args)
Format string.
Definition: format.inl:12
void print(fmt::format_string< T... > pattern, T &&... args)
Format string and print it into the std::cout.
Definition: format.inl:24