ostream 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_OSTREAM
  10. #define _LIBCPP_OSTREAM
  11. /*
  12. ostream synopsis
  13. template <class charT, class traits = char_traits<charT> >
  14. class basic_ostream
  15. : virtual public basic_ios<charT,traits>
  16. {
  17. public:
  18. // types (inherited from basic_ios (27.5.4)):
  19. typedef charT char_type;
  20. typedef traits traits_type;
  21. typedef typename traits_type::int_type int_type;
  22. typedef typename traits_type::pos_type pos_type;
  23. typedef typename traits_type::off_type off_type;
  24. // 27.7.2.2 Constructor/destructor:
  25. explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
  26. basic_ostream(basic_ostream&& rhs);
  27. virtual ~basic_ostream();
  28. // 27.7.2.3 Assign/swap
  29. basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14
  30. basic_ostream& operator=(basic_ostream&& rhs);
  31. void swap(basic_ostream& rhs);
  32. // 27.7.2.4 Prefix/suffix:
  33. class sentry;
  34. // 27.7.2.6 Formatted output:
  35. basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
  36. basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&));
  37. basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
  38. basic_ostream& operator<<(bool n);
  39. basic_ostream& operator<<(short n);
  40. basic_ostream& operator<<(unsigned short n);
  41. basic_ostream& operator<<(int n);
  42. basic_ostream& operator<<(unsigned int n);
  43. basic_ostream& operator<<(long n);
  44. basic_ostream& operator<<(unsigned long n);
  45. basic_ostream& operator<<(long long n);
  46. basic_ostream& operator<<(unsigned long long n);
  47. basic_ostream& operator<<(float f);
  48. basic_ostream& operator<<(double f);
  49. basic_ostream& operator<<(long double f);
  50. basic_ostream& operator<<(const void* p);
  51. basic_ostream& operator<<(const volatile void* val); // C++23
  52. basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
  53. basic_ostream& operator<<(nullptr_t);
  54. // 27.7.2.7 Unformatted output:
  55. basic_ostream& put(char_type c);
  56. basic_ostream& write(const char_type* s, streamsize n);
  57. basic_ostream& flush();
  58. // 27.7.2.5 seeks:
  59. pos_type tellp();
  60. basic_ostream& seekp(pos_type);
  61. basic_ostream& seekp(off_type, ios_base::seekdir);
  62. protected:
  63. basic_ostream(const basic_ostream& rhs) = delete;
  64. basic_ostream(basic_ostream&& rhs);
  65. // 27.7.3.3 Assign/swap
  66. basic_ostream& operator=(basic_ostream& rhs) = delete;
  67. basic_ostream& operator=(const basic_ostream&& rhs);
  68. void swap(basic_ostream& rhs);
  69. };
  70. // 27.7.2.6.4 character inserters
  71. template<class charT, class traits>
  72. basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT);
  73. template<class charT, class traits>
  74. basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char);
  75. template<class traits>
  76. basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char);
  77. // signed and unsigned
  78. template<class traits>
  79. basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char);
  80. template<class traits>
  81. basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char);
  82. // NTBS
  83. template<class charT, class traits>
  84. basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
  85. template<class charT, class traits>
  86. basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*);
  87. template<class traits>
  88. basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*);
  89. // signed and unsigned
  90. template<class traits>
  91. basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*);
  92. template<class traits>
  93. basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*);
  94. // swap:
  95. template <class charT, class traits>
  96. void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y);
  97. template <class charT, class traits>
  98. basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
  99. template <class charT, class traits>
  100. basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
  101. template <class charT, class traits>
  102. basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
  103. // rvalue stream insertion
  104. template <class Stream, class T>
  105. Stream&& operator<<(Stream&& os, const T& x);
  106. template<class traits>
  107. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; // since C++20
  108. template<class traits>
  109. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; // since C++20
  110. template<class traits>
  111. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; // since C++20
  112. template<class traits>
  113. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; // since C++20
  114. template<class traits>
  115. basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; // since C++20
  116. template<class traits>
  117. basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; // since C++20
  118. template<class traits>
  119. basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; // since C++20
  120. template<class traits>
  121. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; // since C++20
  122. template<class traits>
  123. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; // since C++20
  124. template<class traits>
  125. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; // since C++20
  126. template<class traits>
  127. basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; // since C++20
  128. template<class traits>
  129. basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; // since C++20
  130. template<class traits>
  131. basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; // since C++20
  132. template<class traits>
  133. basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; // since C++20
  134. } // std
  135. */
  136. #include <__assert> // all public C++ headers provide the assertion handler
  137. #include <__config>
  138. #include <__memory/shared_ptr.h>
  139. #include <__memory/unique_ptr.h>
  140. #include <bitset>
  141. #include <ios>
  142. #include <locale>
  143. #include <new>
  144. #include <streambuf>
  145. #include <version>
  146. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  147. # pragma GCC system_header
  148. #endif
  149. _LIBCPP_BEGIN_NAMESPACE_STD
  150. template <class _CharT, class _Traits>
  151. class _LIBCPP_TEMPLATE_VIS basic_ostream
  152. : virtual public basic_ios<_CharT, _Traits>
  153. {
  154. public:
  155. // types (inherited from basic_ios (27.5.4)):
  156. typedef _CharT char_type;
  157. typedef _Traits traits_type;
  158. typedef typename traits_type::int_type int_type;
  159. typedef typename traits_type::pos_type pos_type;
  160. typedef typename traits_type::off_type off_type;
  161. // 27.7.2.2 Constructor/destructor:
  162. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  163. explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
  164. { this->init(__sb); }
  165. ~basic_ostream() override;
  166. protected:
  167. inline _LIBCPP_INLINE_VISIBILITY
  168. basic_ostream(basic_ostream&& __rhs);
  169. // 27.7.2.3 Assign/swap
  170. inline _LIBCPP_INLINE_VISIBILITY
  171. basic_ostream& operator=(basic_ostream&& __rhs);
  172. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  173. void swap(basic_ostream& __rhs)
  174. { basic_ios<char_type, traits_type>::swap(__rhs); }
  175. basic_ostream (const basic_ostream& __rhs) = delete;
  176. basic_ostream& operator=(const basic_ostream& __rhs) = delete;
  177. public:
  178. // 27.7.2.4 Prefix/suffix:
  179. class _LIBCPP_TEMPLATE_VIS sentry;
  180. // 27.7.2.6 Formatted output:
  181. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  182. basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
  183. { return __pf(*this); }
  184. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  185. basic_ostream& operator<<(basic_ios<char_type, traits_type>&
  186. (*__pf)(basic_ios<char_type,traits_type>&))
  187. { __pf(*this); return *this; }
  188. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  189. basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
  190. { __pf(*this); return *this; }
  191. basic_ostream& operator<<(bool __n);
  192. basic_ostream& operator<<(short __n);
  193. basic_ostream& operator<<(unsigned short __n);
  194. basic_ostream& operator<<(int __n);
  195. basic_ostream& operator<<(unsigned int __n);
  196. basic_ostream& operator<<(long __n);
  197. basic_ostream& operator<<(unsigned long __n);
  198. basic_ostream& operator<<(long long __n);
  199. basic_ostream& operator<<(unsigned long long __n);
  200. basic_ostream& operator<<(float __f);
  201. basic_ostream& operator<<(double __f);
  202. basic_ostream& operator<<(long double __f);
  203. basic_ostream& operator<<(const void* __p);
  204. #if _LIBCPP_STD_VER > 20
  205. _LIBCPP_HIDE_FROM_ABI
  206. basic_ostream& operator<<(const volatile void* __p) {
  207. return operator<<(const_cast<const void*>(__p));
  208. }
  209. #endif
  210. basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
  211. #if _LIBCPP_STD_VER > 14
  212. // LWG 2221 - nullptr. This is not backported to older standards modes.
  213. // See https://reviews.llvm.org/D127033 for more info on the rationale.
  214. _LIBCPP_INLINE_VISIBILITY
  215. basic_ostream& operator<<(nullptr_t)
  216. { return *this << "nullptr"; }
  217. #endif
  218. // 27.7.2.7 Unformatted output:
  219. basic_ostream& put(char_type __c);
  220. basic_ostream& write(const char_type* __s, streamsize __n);
  221. basic_ostream& flush();
  222. // 27.7.2.5 seeks:
  223. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  224. pos_type tellp();
  225. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  226. basic_ostream& seekp(pos_type __pos);
  227. inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  228. basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
  229. protected:
  230. _LIBCPP_INLINE_VISIBILITY
  231. basic_ostream() {} // extension, intentially does not initialize
  232. };
  233. template <class _CharT, class _Traits>
  234. class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry
  235. {
  236. bool __ok_;
  237. basic_ostream<_CharT, _Traits>& __os_;
  238. public:
  239. explicit sentry(basic_ostream<_CharT, _Traits>& __os);
  240. ~sentry();
  241. sentry(const sentry&) = delete;
  242. sentry& operator=(const sentry&) = delete;
  243. _LIBCPP_INLINE_VISIBILITY
  244. explicit operator bool() const {return __ok_;}
  245. };
  246. template <class _CharT, class _Traits>
  247. basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os)
  248. : __ok_(false),
  249. __os_(__os)
  250. {
  251. if (__os.good())
  252. {
  253. if (__os.tie())
  254. __os.tie()->flush();
  255. __ok_ = true;
  256. }
  257. }
  258. template <class _CharT, class _Traits>
  259. basic_ostream<_CharT, _Traits>::sentry::~sentry()
  260. {
  261. if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf)
  262. && !uncaught_exception())
  263. {
  264. #ifndef _LIBCPP_NO_EXCEPTIONS
  265. try
  266. {
  267. #endif // _LIBCPP_NO_EXCEPTIONS
  268. if (__os_.rdbuf()->pubsync() == -1)
  269. __os_.setstate(ios_base::badbit);
  270. #ifndef _LIBCPP_NO_EXCEPTIONS
  271. }
  272. catch (...)
  273. {
  274. }
  275. #endif // _LIBCPP_NO_EXCEPTIONS
  276. }
  277. }
  278. template <class _CharT, class _Traits>
  279. basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
  280. {
  281. this->move(__rhs);
  282. }
  283. template <class _CharT, class _Traits>
  284. basic_ostream<_CharT, _Traits>&
  285. basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
  286. {
  287. swap(__rhs);
  288. return *this;
  289. }
  290. template <class _CharT, class _Traits>
  291. basic_ostream<_CharT, _Traits>::~basic_ostream()
  292. {
  293. }
  294. template <class _CharT, class _Traits>
  295. basic_ostream<_CharT, _Traits>&
  296. basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb)
  297. {
  298. #ifndef _LIBCPP_NO_EXCEPTIONS
  299. try
  300. {
  301. #endif // _LIBCPP_NO_EXCEPTIONS
  302. sentry __s(*this);
  303. if (__s)
  304. {
  305. if (__sb)
  306. {
  307. #ifndef _LIBCPP_NO_EXCEPTIONS
  308. try
  309. {
  310. #endif // _LIBCPP_NO_EXCEPTIONS
  311. typedef istreambuf_iterator<_CharT, _Traits> _Ip;
  312. typedef ostreambuf_iterator<_CharT, _Traits> _Op;
  313. _Ip __i(__sb);
  314. _Ip __eof;
  315. _Op __o(*this);
  316. size_t __c = 0;
  317. for (; __i != __eof; ++__i, ++__o, ++__c)
  318. {
  319. *__o = *__i;
  320. if (__o.failed())
  321. break;
  322. }
  323. if (__c == 0)
  324. this->setstate(ios_base::failbit);
  325. #ifndef _LIBCPP_NO_EXCEPTIONS
  326. }
  327. catch (...)
  328. {
  329. this->__set_failbit_and_consider_rethrow();
  330. }
  331. #endif // _LIBCPP_NO_EXCEPTIONS
  332. }
  333. else
  334. this->setstate(ios_base::badbit);
  335. }
  336. #ifndef _LIBCPP_NO_EXCEPTIONS
  337. }
  338. catch (...)
  339. {
  340. this->__set_badbit_and_consider_rethrow();
  341. }
  342. #endif // _LIBCPP_NO_EXCEPTIONS
  343. return *this;
  344. }
  345. template <class _CharT, class _Traits>
  346. basic_ostream<_CharT, _Traits>&
  347. basic_ostream<_CharT, _Traits>::operator<<(bool __n)
  348. {
  349. #ifndef _LIBCPP_NO_EXCEPTIONS
  350. try
  351. {
  352. #endif // _LIBCPP_NO_EXCEPTIONS
  353. sentry __s(*this);
  354. if (__s)
  355. {
  356. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  357. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  358. if (__f.put(*this, *this, this->fill(), __n).failed())
  359. this->setstate(ios_base::badbit | ios_base::failbit);
  360. }
  361. #ifndef _LIBCPP_NO_EXCEPTIONS
  362. }
  363. catch (...)
  364. {
  365. this->__set_badbit_and_consider_rethrow();
  366. }
  367. #endif // _LIBCPP_NO_EXCEPTIONS
  368. return *this;
  369. }
  370. template <class _CharT, class _Traits>
  371. basic_ostream<_CharT, _Traits>&
  372. basic_ostream<_CharT, _Traits>::operator<<(short __n)
  373. {
  374. #ifndef _LIBCPP_NO_EXCEPTIONS
  375. try
  376. {
  377. #endif // _LIBCPP_NO_EXCEPTIONS
  378. sentry __s(*this);
  379. if (__s)
  380. {
  381. ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
  382. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  383. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  384. if (__f.put(*this, *this, this->fill(),
  385. __flags == ios_base::oct || __flags == ios_base::hex ?
  386. static_cast<long>(static_cast<unsigned short>(__n)) :
  387. static_cast<long>(__n)).failed())
  388. this->setstate(ios_base::badbit | ios_base::failbit);
  389. }
  390. #ifndef _LIBCPP_NO_EXCEPTIONS
  391. }
  392. catch (...)
  393. {
  394. this->__set_badbit_and_consider_rethrow();
  395. }
  396. #endif // _LIBCPP_NO_EXCEPTIONS
  397. return *this;
  398. }
  399. template <class _CharT, class _Traits>
  400. basic_ostream<_CharT, _Traits>&
  401. basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
  402. {
  403. #ifndef _LIBCPP_NO_EXCEPTIONS
  404. try
  405. {
  406. #endif // _LIBCPP_NO_EXCEPTIONS
  407. sentry __s(*this);
  408. if (__s)
  409. {
  410. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  411. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  412. if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
  413. this->setstate(ios_base::badbit | ios_base::failbit);
  414. }
  415. #ifndef _LIBCPP_NO_EXCEPTIONS
  416. }
  417. catch (...)
  418. {
  419. this->__set_badbit_and_consider_rethrow();
  420. }
  421. #endif // _LIBCPP_NO_EXCEPTIONS
  422. return *this;
  423. }
  424. template <class _CharT, class _Traits>
  425. basic_ostream<_CharT, _Traits>&
  426. basic_ostream<_CharT, _Traits>::operator<<(int __n)
  427. {
  428. #ifndef _LIBCPP_NO_EXCEPTIONS
  429. try
  430. {
  431. #endif // _LIBCPP_NO_EXCEPTIONS
  432. sentry __s(*this);
  433. if (__s)
  434. {
  435. ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
  436. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  437. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  438. if (__f.put(*this, *this, this->fill(),
  439. __flags == ios_base::oct || __flags == ios_base::hex ?
  440. static_cast<long>(static_cast<unsigned int>(__n)) :
  441. static_cast<long>(__n)).failed())
  442. this->setstate(ios_base::badbit | ios_base::failbit);
  443. }
  444. #ifndef _LIBCPP_NO_EXCEPTIONS
  445. }
  446. catch (...)
  447. {
  448. this->__set_badbit_and_consider_rethrow();
  449. }
  450. #endif // _LIBCPP_NO_EXCEPTIONS
  451. return *this;
  452. }
  453. template <class _CharT, class _Traits>
  454. basic_ostream<_CharT, _Traits>&
  455. basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
  456. {
  457. #ifndef _LIBCPP_NO_EXCEPTIONS
  458. try
  459. {
  460. #endif // _LIBCPP_NO_EXCEPTIONS
  461. sentry __s(*this);
  462. if (__s)
  463. {
  464. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  465. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  466. if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
  467. this->setstate(ios_base::badbit | ios_base::failbit);
  468. }
  469. #ifndef _LIBCPP_NO_EXCEPTIONS
  470. }
  471. catch (...)
  472. {
  473. this->__set_badbit_and_consider_rethrow();
  474. }
  475. #endif // _LIBCPP_NO_EXCEPTIONS
  476. return *this;
  477. }
  478. template <class _CharT, class _Traits>
  479. basic_ostream<_CharT, _Traits>&
  480. basic_ostream<_CharT, _Traits>::operator<<(long __n)
  481. {
  482. #ifndef _LIBCPP_NO_EXCEPTIONS
  483. try
  484. {
  485. #endif // _LIBCPP_NO_EXCEPTIONS
  486. sentry __s(*this);
  487. if (__s)
  488. {
  489. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  490. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  491. if (__f.put(*this, *this, this->fill(), __n).failed())
  492. this->setstate(ios_base::badbit | ios_base::failbit);
  493. }
  494. #ifndef _LIBCPP_NO_EXCEPTIONS
  495. }
  496. catch (...)
  497. {
  498. this->__set_badbit_and_consider_rethrow();
  499. }
  500. #endif // _LIBCPP_NO_EXCEPTIONS
  501. return *this;
  502. }
  503. template <class _CharT, class _Traits>
  504. basic_ostream<_CharT, _Traits>&
  505. basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
  506. {
  507. #ifndef _LIBCPP_NO_EXCEPTIONS
  508. try
  509. {
  510. #endif // _LIBCPP_NO_EXCEPTIONS
  511. sentry __s(*this);
  512. if (__s)
  513. {
  514. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  515. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  516. if (__f.put(*this, *this, this->fill(), __n).failed())
  517. this->setstate(ios_base::badbit | ios_base::failbit);
  518. }
  519. #ifndef _LIBCPP_NO_EXCEPTIONS
  520. }
  521. catch (...)
  522. {
  523. this->__set_badbit_and_consider_rethrow();
  524. }
  525. #endif // _LIBCPP_NO_EXCEPTIONS
  526. return *this;
  527. }
  528. template <class _CharT, class _Traits>
  529. basic_ostream<_CharT, _Traits>&
  530. basic_ostream<_CharT, _Traits>::operator<<(long long __n)
  531. {
  532. #ifndef _LIBCPP_NO_EXCEPTIONS
  533. try
  534. {
  535. #endif // _LIBCPP_NO_EXCEPTIONS
  536. sentry __s(*this);
  537. if (__s)
  538. {
  539. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  540. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  541. if (__f.put(*this, *this, this->fill(), __n).failed())
  542. this->setstate(ios_base::badbit | ios_base::failbit);
  543. }
  544. #ifndef _LIBCPP_NO_EXCEPTIONS
  545. }
  546. catch (...)
  547. {
  548. this->__set_badbit_and_consider_rethrow();
  549. }
  550. #endif // _LIBCPP_NO_EXCEPTIONS
  551. return *this;
  552. }
  553. template <class _CharT, class _Traits>
  554. basic_ostream<_CharT, _Traits>&
  555. basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
  556. {
  557. #ifndef _LIBCPP_NO_EXCEPTIONS
  558. try
  559. {
  560. #endif // _LIBCPP_NO_EXCEPTIONS
  561. sentry __s(*this);
  562. if (__s)
  563. {
  564. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  565. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  566. if (__f.put(*this, *this, this->fill(), __n).failed())
  567. this->setstate(ios_base::badbit | ios_base::failbit);
  568. }
  569. #ifndef _LIBCPP_NO_EXCEPTIONS
  570. }
  571. catch (...)
  572. {
  573. this->__set_badbit_and_consider_rethrow();
  574. }
  575. #endif // _LIBCPP_NO_EXCEPTIONS
  576. return *this;
  577. }
  578. template <class _CharT, class _Traits>
  579. basic_ostream<_CharT, _Traits>&
  580. basic_ostream<_CharT, _Traits>::operator<<(float __n)
  581. {
  582. #ifndef _LIBCPP_NO_EXCEPTIONS
  583. try
  584. {
  585. #endif // _LIBCPP_NO_EXCEPTIONS
  586. sentry __s(*this);
  587. if (__s)
  588. {
  589. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  590. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  591. if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
  592. this->setstate(ios_base::badbit | ios_base::failbit);
  593. }
  594. #ifndef _LIBCPP_NO_EXCEPTIONS
  595. }
  596. catch (...)
  597. {
  598. this->__set_badbit_and_consider_rethrow();
  599. }
  600. #endif // _LIBCPP_NO_EXCEPTIONS
  601. return *this;
  602. }
  603. template <class _CharT, class _Traits>
  604. basic_ostream<_CharT, _Traits>&
  605. basic_ostream<_CharT, _Traits>::operator<<(double __n)
  606. {
  607. #ifndef _LIBCPP_NO_EXCEPTIONS
  608. try
  609. {
  610. #endif // _LIBCPP_NO_EXCEPTIONS
  611. sentry __s(*this);
  612. if (__s)
  613. {
  614. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  615. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  616. if (__f.put(*this, *this, this->fill(), __n).failed())
  617. this->setstate(ios_base::badbit | ios_base::failbit);
  618. }
  619. #ifndef _LIBCPP_NO_EXCEPTIONS
  620. }
  621. catch (...)
  622. {
  623. this->__set_badbit_and_consider_rethrow();
  624. }
  625. #endif // _LIBCPP_NO_EXCEPTIONS
  626. return *this;
  627. }
  628. template <class _CharT, class _Traits>
  629. basic_ostream<_CharT, _Traits>&
  630. basic_ostream<_CharT, _Traits>::operator<<(long double __n)
  631. {
  632. #ifndef _LIBCPP_NO_EXCEPTIONS
  633. try
  634. {
  635. #endif // _LIBCPP_NO_EXCEPTIONS
  636. sentry __s(*this);
  637. if (__s)
  638. {
  639. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  640. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  641. if (__f.put(*this, *this, this->fill(), __n).failed())
  642. this->setstate(ios_base::badbit | ios_base::failbit);
  643. }
  644. #ifndef _LIBCPP_NO_EXCEPTIONS
  645. }
  646. catch (...)
  647. {
  648. this->__set_badbit_and_consider_rethrow();
  649. }
  650. #endif // _LIBCPP_NO_EXCEPTIONS
  651. return *this;
  652. }
  653. template <class _CharT, class _Traits>
  654. basic_ostream<_CharT, _Traits>&
  655. basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
  656. {
  657. #ifndef _LIBCPP_NO_EXCEPTIONS
  658. try
  659. {
  660. #endif // _LIBCPP_NO_EXCEPTIONS
  661. sentry __s(*this);
  662. if (__s)
  663. {
  664. typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
  665. const _Fp& __f = std::use_facet<_Fp>(this->getloc());
  666. if (__f.put(*this, *this, this->fill(), __n).failed())
  667. this->setstate(ios_base::badbit | ios_base::failbit);
  668. }
  669. #ifndef _LIBCPP_NO_EXCEPTIONS
  670. }
  671. catch (...)
  672. {
  673. this->__set_badbit_and_consider_rethrow();
  674. }
  675. #endif // _LIBCPP_NO_EXCEPTIONS
  676. return *this;
  677. }
  678. template<class _CharT, class _Traits>
  679. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  680. __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
  681. const _CharT* __str, size_t __len)
  682. {
  683. #ifndef _LIBCPP_NO_EXCEPTIONS
  684. try
  685. {
  686. #endif // _LIBCPP_NO_EXCEPTIONS
  687. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  688. if (__s)
  689. {
  690. typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
  691. if (std::__pad_and_output(_Ip(__os),
  692. __str,
  693. (__os.flags() & ios_base::adjustfield) == ios_base::left ?
  694. __str + __len :
  695. __str,
  696. __str + __len,
  697. __os,
  698. __os.fill()).failed())
  699. __os.setstate(ios_base::badbit | ios_base::failbit);
  700. }
  701. #ifndef _LIBCPP_NO_EXCEPTIONS
  702. }
  703. catch (...)
  704. {
  705. __os.__set_badbit_and_consider_rethrow();
  706. }
  707. #endif // _LIBCPP_NO_EXCEPTIONS
  708. return __os;
  709. }
  710. template<class _CharT, class _Traits>
  711. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  712. operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
  713. {
  714. return _VSTD::__put_character_sequence(__os, &__c, 1);
  715. }
  716. template<class _CharT, class _Traits>
  717. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  718. operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
  719. {
  720. #ifndef _LIBCPP_NO_EXCEPTIONS
  721. try
  722. {
  723. #endif // _LIBCPP_NO_EXCEPTIONS
  724. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  725. if (__s)
  726. {
  727. _CharT __c = __os.widen(__cn);
  728. typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
  729. if (std::__pad_and_output(_Ip(__os),
  730. &__c,
  731. (__os.flags() & ios_base::adjustfield) == ios_base::left ?
  732. &__c + 1 :
  733. &__c,
  734. &__c + 1,
  735. __os,
  736. __os.fill()).failed())
  737. __os.setstate(ios_base::badbit | ios_base::failbit);
  738. }
  739. #ifndef _LIBCPP_NO_EXCEPTIONS
  740. }
  741. catch (...)
  742. {
  743. __os.__set_badbit_and_consider_rethrow();
  744. }
  745. #endif // _LIBCPP_NO_EXCEPTIONS
  746. return __os;
  747. }
  748. template<class _Traits>
  749. _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
  750. operator<<(basic_ostream<char, _Traits>& __os, char __c)
  751. {
  752. return _VSTD::__put_character_sequence(__os, &__c, 1);
  753. }
  754. template<class _Traits>
  755. _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
  756. operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
  757. {
  758. return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
  759. }
  760. template<class _Traits>
  761. _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
  762. operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
  763. {
  764. return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
  765. }
  766. template<class _CharT, class _Traits>
  767. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  768. operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
  769. {
  770. return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
  771. }
  772. template<class _CharT, class _Traits>
  773. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  774. operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
  775. {
  776. #ifndef _LIBCPP_NO_EXCEPTIONS
  777. try
  778. {
  779. #endif // _LIBCPP_NO_EXCEPTIONS
  780. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  781. if (__s)
  782. {
  783. typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
  784. size_t __len = char_traits<char>::length(__strn);
  785. const int __bs = 100;
  786. _CharT __wbb[__bs];
  787. _CharT* __wb = __wbb;
  788. unique_ptr<_CharT, void(*)(void*)> __h(0, free);
  789. if (__len > __bs)
  790. {
  791. __wb = (_CharT*)malloc(__len*sizeof(_CharT));
  792. if (__wb == 0)
  793. __throw_bad_alloc();
  794. __h.reset(__wb);
  795. }
  796. for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
  797. *__p = __os.widen(*__strn);
  798. if (std::__pad_and_output(_Ip(__os),
  799. __wb,
  800. (__os.flags() & ios_base::adjustfield) == ios_base::left ?
  801. __wb + __len :
  802. __wb,
  803. __wb + __len,
  804. __os,
  805. __os.fill()).failed())
  806. __os.setstate(ios_base::badbit | ios_base::failbit);
  807. }
  808. #ifndef _LIBCPP_NO_EXCEPTIONS
  809. }
  810. catch (...)
  811. {
  812. __os.__set_badbit_and_consider_rethrow();
  813. }
  814. #endif // _LIBCPP_NO_EXCEPTIONS
  815. return __os;
  816. }
  817. template<class _Traits>
  818. _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
  819. operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
  820. {
  821. return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
  822. }
  823. template<class _Traits>
  824. _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
  825. operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
  826. {
  827. const char *__s = (const char *) __str;
  828. return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
  829. }
  830. template<class _Traits>
  831. _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
  832. operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
  833. {
  834. const char *__s = (const char *) __str;
  835. return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
  836. }
  837. template <class _CharT, class _Traits>
  838. basic_ostream<_CharT, _Traits>&
  839. basic_ostream<_CharT, _Traits>::put(char_type __c)
  840. {
  841. #ifndef _LIBCPP_NO_EXCEPTIONS
  842. try
  843. {
  844. #endif // _LIBCPP_NO_EXCEPTIONS
  845. sentry __s(*this);
  846. if (__s)
  847. {
  848. typedef ostreambuf_iterator<_CharT, _Traits> _Op;
  849. _Op __o(*this);
  850. *__o = __c;
  851. if (__o.failed())
  852. this->setstate(ios_base::badbit);
  853. }
  854. #ifndef _LIBCPP_NO_EXCEPTIONS
  855. }
  856. catch (...)
  857. {
  858. this->__set_badbit_and_consider_rethrow();
  859. }
  860. #endif // _LIBCPP_NO_EXCEPTIONS
  861. return *this;
  862. }
  863. template <class _CharT, class _Traits>
  864. basic_ostream<_CharT, _Traits>&
  865. basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
  866. {
  867. #ifndef _LIBCPP_NO_EXCEPTIONS
  868. try
  869. {
  870. #endif // _LIBCPP_NO_EXCEPTIONS
  871. sentry __sen(*this);
  872. if (__sen && __n)
  873. {
  874. if (this->rdbuf()->sputn(__s, __n) != __n)
  875. this->setstate(ios_base::badbit);
  876. }
  877. #ifndef _LIBCPP_NO_EXCEPTIONS
  878. }
  879. catch (...)
  880. {
  881. this->__set_badbit_and_consider_rethrow();
  882. }
  883. #endif // _LIBCPP_NO_EXCEPTIONS
  884. return *this;
  885. }
  886. template <class _CharT, class _Traits>
  887. basic_ostream<_CharT, _Traits>&
  888. basic_ostream<_CharT, _Traits>::flush()
  889. {
  890. #ifndef _LIBCPP_NO_EXCEPTIONS
  891. try
  892. {
  893. #endif // _LIBCPP_NO_EXCEPTIONS
  894. if (this->rdbuf())
  895. {
  896. sentry __s(*this);
  897. if (__s)
  898. {
  899. if (this->rdbuf()->pubsync() == -1)
  900. this->setstate(ios_base::badbit);
  901. }
  902. }
  903. #ifndef _LIBCPP_NO_EXCEPTIONS
  904. }
  905. catch (...)
  906. {
  907. this->__set_badbit_and_consider_rethrow();
  908. }
  909. #endif // _LIBCPP_NO_EXCEPTIONS
  910. return *this;
  911. }
  912. template <class _CharT, class _Traits>
  913. typename basic_ostream<_CharT, _Traits>::pos_type
  914. basic_ostream<_CharT, _Traits>::tellp()
  915. {
  916. if (this->fail())
  917. return pos_type(-1);
  918. return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
  919. }
  920. template <class _CharT, class _Traits>
  921. basic_ostream<_CharT, _Traits>&
  922. basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
  923. {
  924. sentry __s(*this);
  925. if (!this->fail())
  926. {
  927. if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
  928. this->setstate(ios_base::failbit);
  929. }
  930. return *this;
  931. }
  932. template <class _CharT, class _Traits>
  933. basic_ostream<_CharT, _Traits>&
  934. basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
  935. {
  936. sentry __s(*this);
  937. if (!this->fail())
  938. {
  939. if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
  940. this->setstate(ios_base::failbit);
  941. }
  942. return *this;
  943. }
  944. template <class _CharT, class _Traits>
  945. _LIBCPP_HIDE_FROM_ABI inline
  946. basic_ostream<_CharT, _Traits>&
  947. endl(basic_ostream<_CharT, _Traits>& __os)
  948. {
  949. __os.put(__os.widen('\n'));
  950. __os.flush();
  951. return __os;
  952. }
  953. template <class _CharT, class _Traits>
  954. _LIBCPP_HIDE_FROM_ABI inline
  955. basic_ostream<_CharT, _Traits>&
  956. ends(basic_ostream<_CharT, _Traits>& __os)
  957. {
  958. __os.put(_CharT());
  959. return __os;
  960. }
  961. template <class _CharT, class _Traits>
  962. _LIBCPP_HIDE_FROM_ABI inline
  963. basic_ostream<_CharT, _Traits>&
  964. flush(basic_ostream<_CharT, _Traits>& __os)
  965. {
  966. __os.flush();
  967. return __os;
  968. }
  969. template <class _Stream, class _Tp, class = void>
  970. struct __is_ostreamable : false_type { };
  971. template <class _Stream, class _Tp>
  972. struct __is_ostreamable<_Stream, _Tp, decltype(
  973. std::declval<_Stream>() << std::declval<_Tp>(), void()
  974. )> : true_type { };
  975. template <class _Stream, class _Tp, class = typename enable_if<
  976. _And<is_base_of<ios_base, _Stream>,
  977. __is_ostreamable<_Stream&, const _Tp&> >::value
  978. >::type>
  979. _LIBCPP_INLINE_VISIBILITY
  980. _Stream&& operator<<(_Stream&& __os, const _Tp& __x)
  981. {
  982. __os << __x;
  983. return _VSTD::move(__os);
  984. }
  985. template<class _CharT, class _Traits, class _Allocator>
  986. basic_ostream<_CharT, _Traits>&
  987. operator<<(basic_ostream<_CharT, _Traits>& __os,
  988. const basic_string<_CharT, _Traits, _Allocator>& __str)
  989. {
  990. return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
  991. }
  992. template<class _CharT, class _Traits>
  993. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  994. operator<<(basic_ostream<_CharT, _Traits>& __os,
  995. basic_string_view<_CharT, _Traits> __sv)
  996. {
  997. return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
  998. }
  999. template <class _CharT, class _Traits>
  1000. inline _LIBCPP_INLINE_VISIBILITY
  1001. basic_ostream<_CharT, _Traits>&
  1002. operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
  1003. {
  1004. return __os << __ec.category().name() << ':' << __ec.value();
  1005. }
  1006. template<class _CharT, class _Traits, class _Yp>
  1007. inline _LIBCPP_INLINE_VISIBILITY
  1008. basic_ostream<_CharT, _Traits>&
  1009. operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
  1010. {
  1011. return __os << __p.get();
  1012. }
  1013. template<class _CharT, class _Traits, class _Yp, class _Dp>
  1014. inline _LIBCPP_INLINE_VISIBILITY
  1015. typename enable_if
  1016. <
  1017. is_same<void, __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
  1018. basic_ostream<_CharT, _Traits>&
  1019. >::type
  1020. operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
  1021. {
  1022. return __os << __p.get();
  1023. }
  1024. template <class _CharT, class _Traits, size_t _Size>
  1025. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  1026. operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
  1027. {
  1028. return __os << __x.template to_string<_CharT, _Traits>
  1029. (std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
  1030. std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
  1031. }
  1032. #if 0
  1033. #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  1034. template <class _Traits>
  1035. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
  1036. template <class _Traits>
  1037. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
  1038. template <class _Traits>
  1039. basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
  1040. template <class _Traits>
  1041. basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
  1042. template <class _Traits>
  1043. basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
  1044. template <class _Traits>
  1045. basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
  1046. #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
  1047. #ifndef _LIBCPP_HAS_NO_CHAR8_T
  1048. template <class _Traits>
  1049. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
  1050. template <class _Traits>
  1051. basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
  1052. template <class _Traits>
  1053. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
  1054. template <class _Traits>
  1055. basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
  1056. #endif
  1057. template <class _Traits>
  1058. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
  1059. template <class _Traits>
  1060. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
  1061. template <class _Traits>
  1062. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
  1063. template <class _Traits>
  1064. basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
  1065. #endif // _LIBCPP_STD_VER > 17
  1066. extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
  1067. #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  1068. extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
  1069. #endif
  1070. _LIBCPP_END_NAMESPACE_STD
  1071. #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
  1072. # include <concepts>
  1073. # include <iterator>
  1074. # include <type_traits>
  1075. #endif
  1076. #endif // _LIBCPP_OSTREAM