30#define _GLIBCXX_PRINT 1
32#pragma GCC system_header
36#define __glibcxx_want_print
47# include <system_error>
50namespace std _GLIBCXX_VISIBILITY(default)
52_GLIBCXX_BEGIN_NAMESPACE_VERSION
55 vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args)
57 __format::_Str_sink<char> __buf;
58 std::vformat_to(__buf.out(), __fmt, __args);
59 auto __out = __buf.view();
60 if (std::fwrite(__out.data(), 1, __out.size(), __stream) != __out.size())
61 __throw_system_error(EIO);
65 vprint_unicode(FILE* __stream, string_view __fmt, format_args __args)
67#if !defined(_WIN32) || defined(__CYGWIN__)
70 std::vprint_nonunicode(__stream, __fmt, __args);
72 __format::_Str_sink<char> __buf;
73 std::vformat_to(__buf.out(), __fmt, __args);
74 auto __out = __buf.view();
76 void* __open_terminal(FILE*);
77 error_code __write_to_terminal(
void*, span<char>);
79 if (
auto __term = __open_terminal(__stream))
81 string __out = std::vformat(__fmt, __args);
83 if (!std::fflush(__stream))
85 __e = __write_to_terminal(__term, __out);
93 _GLIBCXX_THROW_OR_ABORT(system_error(__e,
"std::vprint_unicode"));
97 if (std::fwrite(__out.data(), 1, __out.size(), __stream) != __out.size())
98 __throw_system_error(EIO);
102 template<
typename... _Args>
104 print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args)
106 auto __fmtargs = std::make_format_args(__args...);
107 if constexpr (__unicode::__literal_encoding_is_utf8())
108 std::vprint_unicode(__stream, __fmt.get(), __fmtargs);
110 std::vprint_nonunicode(__stream, __fmt.get(), __fmtargs);
113 template<
typename... _Args>
115 print(format_string<_Args...> __fmt, _Args&&... __args)
116 { std::print(stdout, __fmt, std::forward<_Args>(__args)...); }
118 template<
typename... _Args>
120 println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args)
122 std::print(__stream,
"{}\n",
123 std::format(__fmt, std::forward<_Args>(__args)...));
126 template<
typename... _Args>
128 println(format_string<_Args...> __fmt, _Args&&... __args)
129 { std::println(stdout, __fmt, std::forward<_Args>(__args)...); }
132 vprint_unicode(string_view __fmt, format_args __args)
133 { std::vprint_unicode(stdout, __fmt, __args); }
136 vprint_nonunicode(string_view __fmt, format_args __args)
137 { std::vprint_nonunicode(stdout, __fmt, __args); }
140 inline void println(FILE* __stream)
142#if defined(_WIN32) && !defined(__CYGWIN__)
143 if constexpr (__unicode::__literal_encoding_is_utf8())
144 std::vprint_unicode(__stream,
"\n", std::make_format_args());
147 if (std::putc(
'\n', __stream) == EOF)
148 __throw_system_error(EIO);
151 inline void println() { std::println(stdout); }
153_GLIBCXX_END_NAMESPACE_VERSION
const error_category & generic_category() noexcept
Error category for errno error codes.
error_code make_error_code(future_errc __errc) noexcept
Overload of make_error_code for future_errc.
ISO C++ entities toplevel namespace is std.