iomanip 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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_IOMANIP
  10. #define _LIBCPP_IOMANIP
  11. /*
  12. iomanip synopsis
  13. namespace std {
  14. // types T1, T2, ... are unspecified implementation types
  15. T1 resetiosflags(ios_base::fmtflags mask);
  16. T2 setiosflags (ios_base::fmtflags mask);
  17. T3 setbase(int base);
  18. template<charT> T4 setfill(charT c);
  19. T5 setprecision(int n);
  20. T6 setw(int n);
  21. template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
  22. template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
  23. template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
  24. template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
  25. template <class charT>
  26. T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14
  27. template <class charT, class traits, class Allocator>
  28. T12 quoted(const basic_string<charT, traits, Allocator>& s,
  29. charT delim=charT('"'), charT escape=charT('\\')); // C++14
  30. template <class charT, class traits, class Allocator>
  31. T13 quoted(basic_string<charT, traits, Allocator>& s,
  32. charT delim=charT('"'), charT escape=charT('\\')); // C++14
  33. } // std
  34. */
  35. #include <__config>
  36. #include <istream>
  37. #include <version>
  38. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  39. # pragma GCC system_header
  40. #endif
  41. _LIBCPP_BEGIN_NAMESPACE_STD
  42. // resetiosflags
  43. class __iom_t1 {
  44. ios_base::fmtflags __mask_;
  45. public:
  46. _LIBCPP_HIDE_FROM_ABI explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {}
  47. template <class _CharT, class _Traits>
  48. friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  49. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x) {
  50. __is.unsetf(__x.__mask_);
  51. return __is;
  52. }
  53. template <class _CharT, class _Traits>
  54. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  55. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x) {
  56. __os.unsetf(__x.__mask_);
  57. return __os;
  58. }
  59. };
  60. inline _LIBCPP_HIDE_FROM_ABI __iom_t1 resetiosflags(ios_base::fmtflags __mask) { return __iom_t1(__mask); }
  61. // setiosflags
  62. class __iom_t2 {
  63. ios_base::fmtflags __mask_;
  64. public:
  65. _LIBCPP_HIDE_FROM_ABI explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {}
  66. template <class _CharT, class _Traits>
  67. friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  68. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x) {
  69. __is.setf(__x.__mask_);
  70. return __is;
  71. }
  72. template <class _CharT, class _Traits>
  73. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  74. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x) {
  75. __os.setf(__x.__mask_);
  76. return __os;
  77. }
  78. };
  79. inline _LIBCPP_HIDE_FROM_ABI __iom_t2 setiosflags(ios_base::fmtflags __mask) { return __iom_t2(__mask); }
  80. // setbase
  81. class __iom_t3 {
  82. int __base_;
  83. public:
  84. _LIBCPP_HIDE_FROM_ABI explicit __iom_t3(int __b) : __base_(__b) {}
  85. template <class _CharT, class _Traits>
  86. friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  87. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x) {
  88. __is.setf(__x.__base_ == 8 ? ios_base::oct
  89. : __x.__base_ == 10 ? ios_base::dec
  90. : __x.__base_ == 16 ? ios_base::hex
  91. : ios_base::fmtflags(0),
  92. ios_base::basefield);
  93. return __is;
  94. }
  95. template <class _CharT, class _Traits>
  96. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  97. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x) {
  98. __os.setf(__x.__base_ == 8 ? ios_base::oct
  99. : __x.__base_ == 10 ? ios_base::dec
  100. : __x.__base_ == 16 ? ios_base::hex
  101. : ios_base::fmtflags(0),
  102. ios_base::basefield);
  103. return __os;
  104. }
  105. };
  106. inline _LIBCPP_HIDE_FROM_ABI __iom_t3 setbase(int __base) { return __iom_t3(__base); }
  107. // setfill
  108. template <class _CharT>
  109. class __iom_t4 {
  110. _CharT __fill_;
  111. public:
  112. _LIBCPP_HIDE_FROM_ABI explicit __iom_t4(_CharT __c) : __fill_(__c) {}
  113. template <class _Traits>
  114. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  115. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x) {
  116. __os.fill(__x.__fill_);
  117. return __os;
  118. }
  119. };
  120. template <class _CharT>
  121. inline _LIBCPP_HIDE_FROM_ABI __iom_t4<_CharT> setfill(_CharT __c) {
  122. return __iom_t4<_CharT>(__c);
  123. }
  124. // setprecision
  125. class __iom_t5 {
  126. int __n_;
  127. public:
  128. _LIBCPP_HIDE_FROM_ABI explicit __iom_t5(int __n) : __n_(__n) {}
  129. template <class _CharT, class _Traits>
  130. friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  131. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x) {
  132. __is.precision(__x.__n_);
  133. return __is;
  134. }
  135. template <class _CharT, class _Traits>
  136. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  137. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x) {
  138. __os.precision(__x.__n_);
  139. return __os;
  140. }
  141. };
  142. inline _LIBCPP_HIDE_FROM_ABI __iom_t5 setprecision(int __n) { return __iom_t5(__n); }
  143. // setw
  144. class __iom_t6 {
  145. int __n_;
  146. public:
  147. _LIBCPP_HIDE_FROM_ABI explicit __iom_t6(int __n) : __n_(__n) {}
  148. template <class _CharT, class _Traits>
  149. friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  150. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x) {
  151. __is.width(__x.__n_);
  152. return __is;
  153. }
  154. template <class _CharT, class _Traits>
  155. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  156. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x) {
  157. __os.width(__x.__n_);
  158. return __os;
  159. }
  160. };
  161. inline _LIBCPP_HIDE_FROM_ABI __iom_t6 setw(int __n) { return __iom_t6(__n); }
  162. // get_money
  163. template <class _MoneyT>
  164. class __iom_t7;
  165. template <class _CharT, class _Traits, class _MoneyT>
  166. _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  167. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
  168. template <class _MoneyT>
  169. class __iom_t7 {
  170. _MoneyT& __mon_;
  171. bool __intl_;
  172. public:
  173. _LIBCPP_HIDE_FROM_ABI __iom_t7(_MoneyT& __mon, bool __intl) : __mon_(__mon), __intl_(__intl) {}
  174. template <class _CharT, class _Traits, class _Mp>
  175. friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x);
  176. };
  177. template <class _CharT, class _Traits, class _MoneyT>
  178. _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  179. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {
  180. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  181. try {
  182. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  183. typename basic_istream<_CharT, _Traits>::sentry __s(__is);
  184. if (__s) {
  185. typedef istreambuf_iterator<_CharT, _Traits> _Ip;
  186. typedef money_get<_CharT, _Ip> _Fp;
  187. ios_base::iostate __err = ios_base::goodbit;
  188. const _Fp& __mf = std::use_facet<_Fp>(__is.getloc());
  189. __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
  190. __is.setstate(__err);
  191. }
  192. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  193. } catch (...) {
  194. __is.__set_badbit_and_consider_rethrow();
  195. }
  196. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  197. return __is;
  198. }
  199. template <class _MoneyT>
  200. inline _LIBCPP_HIDE_FROM_ABI __iom_t7<_MoneyT> get_money(_MoneyT& __mon, bool __intl = false) {
  201. return __iom_t7<_MoneyT>(__mon, __intl);
  202. }
  203. // put_money
  204. template <class _MoneyT>
  205. class __iom_t8;
  206. template <class _CharT, class _Traits, class _MoneyT>
  207. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  208. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
  209. template <class _MoneyT>
  210. class __iom_t8 {
  211. const _MoneyT& __mon_;
  212. bool __intl_;
  213. public:
  214. _LIBCPP_HIDE_FROM_ABI __iom_t8(const _MoneyT& __mon, bool __intl) : __mon_(__mon), __intl_(__intl) {}
  215. template <class _CharT, class _Traits, class _Mp>
  216. friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x);
  217. };
  218. template <class _CharT, class _Traits, class _MoneyT>
  219. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  220. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {
  221. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  222. try {
  223. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  224. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  225. if (__s) {
  226. typedef ostreambuf_iterator<_CharT, _Traits> _Op;
  227. typedef money_put<_CharT, _Op> _Fp;
  228. const _Fp& __mf = std::use_facet<_Fp>(__os.getloc());
  229. if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
  230. __os.setstate(ios_base::badbit);
  231. }
  232. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  233. } catch (...) {
  234. __os.__set_badbit_and_consider_rethrow();
  235. }
  236. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  237. return __os;
  238. }
  239. template <class _MoneyT>
  240. inline _LIBCPP_HIDE_FROM_ABI __iom_t8<_MoneyT> put_money(const _MoneyT& __mon, bool __intl = false) {
  241. return __iom_t8<_MoneyT>(__mon, __intl);
  242. }
  243. // get_time
  244. template <class _CharT>
  245. class __iom_t9;
  246. template <class _CharT, class _Traits>
  247. _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  248. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
  249. template <class _CharT>
  250. class __iom_t9 {
  251. tm* __tm_;
  252. const _CharT* __fmt_;
  253. public:
  254. _LIBCPP_HIDE_FROM_ABI __iom_t9(tm* __tm, const _CharT* __fmt) : __tm_(__tm), __fmt_(__fmt) {}
  255. template <class _Cp, class _Traits>
  256. friend basic_istream<_Cp, _Traits>& operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x);
  257. };
  258. template <class _CharT, class _Traits>
  259. _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  260. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {
  261. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  262. try {
  263. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  264. typename basic_istream<_CharT, _Traits>::sentry __s(__is);
  265. if (__s) {
  266. typedef istreambuf_iterator<_CharT, _Traits> _Ip;
  267. typedef time_get<_CharT, _Ip> _Fp;
  268. ios_base::iostate __err = ios_base::goodbit;
  269. const _Fp& __tf = std::use_facet<_Fp>(__is.getloc());
  270. __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
  271. __is.setstate(__err);
  272. }
  273. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  274. } catch (...) {
  275. __is.__set_badbit_and_consider_rethrow();
  276. }
  277. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  278. return __is;
  279. }
  280. template <class _CharT>
  281. inline _LIBCPP_HIDE_FROM_ABI __iom_t9<_CharT> get_time(tm* __tm, const _CharT* __fmt) {
  282. return __iom_t9<_CharT>(__tm, __fmt);
  283. }
  284. // put_time
  285. template <class _CharT>
  286. class __iom_t10;
  287. template <class _CharT, class _Traits>
  288. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  289. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
  290. template <class _CharT>
  291. class __iom_t10 {
  292. const tm* __tm_;
  293. const _CharT* __fmt_;
  294. public:
  295. _LIBCPP_HIDE_FROM_ABI __iom_t10(const tm* __tm, const _CharT* __fmt) : __tm_(__tm), __fmt_(__fmt) {}
  296. template <class _Cp, class _Traits>
  297. friend basic_ostream<_Cp, _Traits>& operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x);
  298. };
  299. template <class _CharT, class _Traits>
  300. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  301. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {
  302. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  303. try {
  304. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  305. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  306. if (__s) {
  307. typedef ostreambuf_iterator<_CharT, _Traits> _Op;
  308. typedef time_put<_CharT, _Op> _Fp;
  309. const _Fp& __tf = std::use_facet<_Fp>(__os.getloc());
  310. if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_))
  311. .failed())
  312. __os.setstate(ios_base::badbit);
  313. }
  314. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  315. } catch (...) {
  316. __os.__set_badbit_and_consider_rethrow();
  317. }
  318. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  319. return __os;
  320. }
  321. template <class _CharT>
  322. inline _LIBCPP_HIDE_FROM_ABI __iom_t10<_CharT> put_time(const tm* __tm, const _CharT* __fmt) {
  323. return __iom_t10<_CharT>(__tm, __fmt);
  324. }
  325. template <class _CharT, class _Traits>
  326. _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& __quoted_output(
  327. basic_ostream<_CharT, _Traits>& __os,
  328. const _CharT* __first,
  329. const _CharT* __last,
  330. _CharT __delim,
  331. _CharT __escape) {
  332. basic_string<_CharT, _Traits> __str;
  333. __str.push_back(__delim);
  334. for (; __first != __last; ++__first) {
  335. if (_Traits::eq(*__first, __escape) || _Traits::eq(*__first, __delim))
  336. __str.push_back(__escape);
  337. __str.push_back(*__first);
  338. }
  339. __str.push_back(__delim);
  340. return std::__put_character_sequence(__os, __str.data(), __str.size());
  341. }
  342. template <class _CharT, class _Traits, class _String>
  343. _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  344. __quoted_input(basic_istream<_CharT, _Traits>& __is, _String& __string, _CharT __delim, _CharT __escape) {
  345. __string.clear();
  346. _CharT __c;
  347. __is >> __c;
  348. if (__is.fail())
  349. return __is;
  350. if (!_Traits::eq(__c, __delim)) {
  351. // no delimiter, read the whole string
  352. __is.unget();
  353. __is >> __string;
  354. return __is;
  355. }
  356. __save_flags<_CharT, _Traits> __sf(__is);
  357. std::noskipws(__is);
  358. while (true) {
  359. __is >> __c;
  360. if (__is.fail())
  361. break;
  362. if (_Traits::eq(__c, __escape)) {
  363. __is >> __c;
  364. if (__is.fail())
  365. break;
  366. } else if (_Traits::eq(__c, __delim))
  367. break;
  368. __string.push_back(__c);
  369. }
  370. return __is;
  371. }
  372. template <class _CharT, class _Traits>
  373. struct _LIBCPP_HIDDEN __quoted_output_proxy {
  374. const _CharT* __first_;
  375. const _CharT* __last_;
  376. _CharT __delim_;
  377. _CharT __escape_;
  378. _LIBCPP_HIDE_FROM_ABI explicit __quoted_output_proxy(const _CharT* __f, const _CharT* __l, _CharT __d, _CharT __e)
  379. : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {}
  380. template <class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value, int> = 0>
  381. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>&
  382. operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) {
  383. return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_);
  384. }
  385. };
  386. template <class _CharT, class _Traits, class _Allocator>
  387. struct _LIBCPP_HIDDEN __quoted_proxy {
  388. basic_string<_CharT, _Traits, _Allocator>& __string_;
  389. _CharT __delim_;
  390. _CharT __escape_;
  391. _LIBCPP_HIDE_FROM_ABI explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __d, _CharT __e)
  392. : __string_(__s), __delim_(__d), __escape_(__e) {}
  393. friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
  394. operator<<(basic_ostream<_CharT, _Traits>& __os, const __quoted_proxy& __p) {
  395. return std::__quoted_output(
  396. __os, __p.__string_.data(), __p.__string_.data() + __p.__string_.size(), __p.__delim_, __p.__escape_);
  397. }
  398. friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
  399. operator>>(basic_istream<_CharT, _Traits>& __is, const __quoted_proxy& __p) {
  400. return std::__quoted_input(__is, __p.__string_, __p.__delim_, __p.__escape_);
  401. }
  402. };
  403. template <class _CharT, class _Traits, class _Allocator>
  404. _LIBCPP_HIDE_FROM_ABI __quoted_output_proxy<_CharT, _Traits>
  405. __quoted(const basic_string<_CharT, _Traits, _Allocator>& __s,
  406. _CharT __delim = _CharT('"'),
  407. _CharT __escape = _CharT('\\')) {
  408. return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
  409. }
  410. template <class _CharT, class _Traits, class _Allocator>
  411. _LIBCPP_HIDE_FROM_ABI __quoted_proxy<_CharT, _Traits, _Allocator>
  412. __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
  413. return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
  414. }
  415. #if _LIBCPP_STD_VER >= 14
  416. template <class _CharT>
  417. _LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
  418. const _CharT* __end = __s;
  419. while (*__end)
  420. ++__end;
  421. return __quoted_output_proxy<_CharT, void>(__s, __end, __delim, __escape);
  422. }
  423. template <class _CharT, class _Traits, class _Allocator>
  424. _LIBCPP_HIDE_FROM_ABI auto
  425. quoted(const basic_string<_CharT, _Traits, _Allocator>& __s,
  426. _CharT __delim = _CharT('"'),
  427. _CharT __escape = _CharT('\\')) {
  428. return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
  429. }
  430. template <class _CharT, class _Traits, class _Allocator>
  431. _LIBCPP_HIDE_FROM_ABI auto
  432. quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
  433. return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
  434. }
  435. template <class _CharT, class _Traits>
  436. _LIBCPP_HIDE_FROM_ABI auto
  437. quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
  438. return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape);
  439. }
  440. #endif // _LIBCPP_STD_VER >= 14
  441. _LIBCPP_END_NAMESPACE_STD
  442. #endif // _LIBCPP_IOMANIP