/src/stdplus/include/stdplus/print.hpp
Line | Count | Source |
1 | | #pragma once |
2 | | #include <stdplus/str/buf.hpp> |
3 | | |
4 | | #include <format> |
5 | | |
6 | | namespace stdplus |
7 | | { |
8 | | |
9 | | void prints(std::FILE* stream, std::string_view data); |
10 | | |
11 | | template <bool ln> |
12 | | struct Printer |
13 | | { |
14 | | template <typename... Args> |
15 | | static void print(std::FILE* stream, std::format_string<Args...> fmt, |
16 | | Args&&... args) |
17 | 1.40k | { |
18 | 1.40k | stdplus::StrBuf buf; |
19 | 1.40k | std::format_to(std::back_inserter(buf), fmt, |
20 | 1.40k | std::forward<Args>(args)...); |
21 | | if constexpr (ln) |
22 | | { |
23 | | buf.push_back('\n'); |
24 | | } |
25 | 1.40k | prints(stream, buf); |
26 | 1.40k | } void stdplus::Printer<false>::print<unsigned long, unsigned long>(_IO_FILE*, std::__1::basic_format_string<char, std::__1::type_identity<unsigned long>::type, std::__1::type_identity<unsigned long>::type>, unsigned long&&, unsigned long&&) Line | Count | Source | 17 | 1.40k | { | 18 | 1.40k | stdplus::StrBuf buf; | 19 | 1.40k | std::format_to(std::back_inserter(buf), fmt, | 20 | 1.40k | std::forward<Args>(args)...); | 21 | | if constexpr (ln) | 22 | | { | 23 | | buf.push_back('\n'); | 24 | | } | 25 | 1.40k | prints(stream, buf); | 26 | 1.40k | } |
Unexecuted instantiation: void stdplus::Printer<false>::print<unsigned char>(_IO_FILE*, std::__1::basic_format_string<char, std::__1::type_identity<unsigned char>::type>, unsigned char&&) |
27 | | }; |
28 | | |
29 | | template <typename... Args> |
30 | | void print(std::FILE* stream, std::format_string<Args...> fmt, Args&&... args) |
31 | 1.40k | { |
32 | 1.40k | Printer<false>::print(stream, fmt, std::forward<Args>(args)...); |
33 | 1.40k | } void stdplus::print<unsigned long, unsigned long>(_IO_FILE*, std::__1::basic_format_string<char, std::__1::type_identity<unsigned long>::type, std::__1::type_identity<unsigned long>::type>, unsigned long&&, unsigned long&&) Line | Count | Source | 31 | 1.40k | { | 32 | 1.40k | Printer<false>::print(stream, fmt, std::forward<Args>(args)...); | 33 | 1.40k | } |
Unexecuted instantiation: void stdplus::print<unsigned char>(_IO_FILE*, std::__1::basic_format_string<char, std::__1::type_identity<unsigned char>::type>, unsigned char&&) |
34 | | |
35 | | template <typename... Args> |
36 | | inline void print(std::format_string<Args...> fmt, Args&&... args) |
37 | | { |
38 | | Printer<false>::print(stdout, fmt, std::forward<Args>(args)...); |
39 | | } |
40 | | |
41 | | template <typename... Args> |
42 | | inline void println(std::FILE* stream, std::format_string<Args...> fmt, |
43 | | Args&&... args) |
44 | | { |
45 | | Printer<true>::print(stream, fmt, std::forward<Args>(args)...); |
46 | | } |
47 | | |
48 | | template <typename... Args> |
49 | | inline void println(std::format_string<Args...> fmt, Args&&... args) |
50 | | { |
51 | | Printer<true>::print(stdout, fmt, std::forward<Args>(args)...); |
52 | | } |
53 | | |
54 | | } // namespace stdplus |