30#define _GLIBCXX_PRINT 1
33#pragma GCC system_header
38#define __glibcxx_want_print
49# include <system_error>
52namespace std _GLIBCXX_VISIBILITY(default)
54_GLIBCXX_BEGIN_NAMESPACE_VERSION
57 vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args)
59 __format::_Str_sink<char> __buf;
60 std::vformat_to(__buf.out(), __fmt, __args);
61 auto __out = __buf.view();
62 if (std::fwrite(__out.data(), 1, __out.size(), __stream) != __out.size())
63 __throw_system_error(EIO);
67 vprint_unicode(FILE* __stream, string_view __fmt, format_args __args)
69#if !defined(_WIN32) || defined(__CYGWIN__)
72 std::vprint_nonunicode(__stream, __fmt, __args);
74 __format::_Str_sink<char> __buf;
75 std::vformat_to(__buf.out(), __fmt, __args);
76 auto __out = __buf.view();
78 void* __open_terminal(FILE*);
79 error_code __write_to_terminal(
void*, span<char>);
81 if (
auto __term = __open_terminal(__stream))
83 string __out = std::vformat(__fmt, __args);
85 if (!std::fflush(__stream))
87 __e = __write_to_terminal(__term, __out);
95 _GLIBCXX_THROW_OR_ABORT(system_error(__e,
"std::vprint_unicode"));
99 if (std::fwrite(__out.data(), 1, __out.size(), __stream) != __out.size())
100 __throw_system_error(EIO);
104 template<
typename... _Args>
106 print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args)
108 auto __fmtargs = std::make_format_args(__args...);
109 if constexpr (__unicode::__literal_encoding_is_utf8())
110 std::vprint_unicode(__stream, __fmt.get(), __fmtargs);
112 std::vprint_nonunicode(__stream, __fmt.get(), __fmtargs);
115 template<
typename... _Args>
117 print(format_string<_Args...> __fmt, _Args&&... __args)
118 { std::print(stdout, __fmt, std::forward<_Args>(__args)...); }
120 template<
typename... _Args>
122 println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args)
124 std::print(__stream,
"{}\n",
125 std::format(__fmt, std::forward<_Args>(__args)...));
128 template<
typename... _Args>
130 println(format_string<_Args...> __fmt, _Args&&... __args)
131 { std::println(stdout, __fmt, std::forward<_Args>(__args)...); }
134 vprint_unicode(string_view __fmt, format_args __args)
135 { std::vprint_unicode(stdout, __fmt, __args); }
138 vprint_nonunicode(string_view __fmt, format_args __args)
139 { std::vprint_nonunicode(stdout, __fmt, __args); }
142 inline void println(FILE* __stream)
144#if defined(_WIN32) && !defined(__CYGWIN__)
145 if constexpr (__unicode::__literal_encoding_is_utf8())
146 std::vprint_unicode(__stream,
"\n", std::make_format_args());
149 if (std::putc(
'\n', __stream) == EOF)
150 __throw_system_error(EIO);
153 inline void println() { std::println(stdout); }
155_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.