iomanip 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. // -*- C++ -*-
  2. //===--------------------------- iomanip ----------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_IOMANIP
  11. #define _LIBCPP_IOMANIP
  12. /*
  13. iomanip synopsis
  14. namespace std {
  15. // types T1, T2, ... are unspecified implementation types
  16. T1 resetiosflags(ios_base::fmtflags mask);
  17. T2 setiosflags (ios_base::fmtflags mask);
  18. T3 setbase(int base);
  19. template<charT> T4 setfill(charT c);
  20. T5 setprecision(int n);
  21. T6 setw(int n);
  22. template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
  23. template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
  24. template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
  25. template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
  26. template <class charT>
  27. T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14
  28. template <class charT, class traits, class Allocator>
  29. T12 quoted(const basic_string<charT, traits, Allocator>& s,
  30. charT delim=charT('"'), charT escape=charT('\\')); // C++14
  31. template <class charT, class traits, class Allocator>
  32. T13 quoted(basic_string<charT, traits, Allocator>& s,
  33. charT delim=charT('"'), charT escape=charT('\\')); // C++14
  34. } // std
  35. */
  36. // Not supported in SGX.
  37. #include <__config>
  38. #if !defined(_LIBCPP_SGX_CONFIG)
  39. #include <istream>
  40. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  41. #pragma GCC system_header
  42. #endif
  43. _LIBCPP_BEGIN_NAMESPACE_STD
  44. // resetiosflags
  45. class __iom_t1
  46. {
  47. ios_base::fmtflags __mask_;
  48. public:
  49. _LIBCPP_INLINE_VISIBILITY
  50. explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {}
  51. template <class _CharT, class _Traits>
  52. friend
  53. _LIBCPP_INLINE_VISIBILITY
  54. basic_istream<_CharT, _Traits>&
  55. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x)
  56. {
  57. __is.unsetf(__x.__mask_);
  58. return __is;
  59. }
  60. template <class _CharT, class _Traits>
  61. friend
  62. _LIBCPP_INLINE_VISIBILITY
  63. basic_ostream<_CharT, _Traits>&
  64. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x)
  65. {
  66. __os.unsetf(__x.__mask_);
  67. return __os;
  68. }
  69. };
  70. inline _LIBCPP_INLINE_VISIBILITY
  71. __iom_t1
  72. resetiosflags(ios_base::fmtflags __mask)
  73. {
  74. return __iom_t1(__mask);
  75. }
  76. // setiosflags
  77. class __iom_t2
  78. {
  79. ios_base::fmtflags __mask_;
  80. public:
  81. _LIBCPP_INLINE_VISIBILITY
  82. explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {}
  83. template <class _CharT, class _Traits>
  84. friend
  85. _LIBCPP_INLINE_VISIBILITY
  86. basic_istream<_CharT, _Traits>&
  87. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x)
  88. {
  89. __is.setf(__x.__mask_);
  90. return __is;
  91. }
  92. template <class _CharT, class _Traits>
  93. friend
  94. _LIBCPP_INLINE_VISIBILITY
  95. basic_ostream<_CharT, _Traits>&
  96. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x)
  97. {
  98. __os.setf(__x.__mask_);
  99. return __os;
  100. }
  101. };
  102. inline _LIBCPP_INLINE_VISIBILITY
  103. __iom_t2
  104. setiosflags(ios_base::fmtflags __mask)
  105. {
  106. return __iom_t2(__mask);
  107. }
  108. // setbase
  109. class __iom_t3
  110. {
  111. int __base_;
  112. public:
  113. _LIBCPP_INLINE_VISIBILITY
  114. explicit __iom_t3(int __b) : __base_(__b) {}
  115. template <class _CharT, class _Traits>
  116. friend
  117. _LIBCPP_INLINE_VISIBILITY
  118. basic_istream<_CharT, _Traits>&
  119. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x)
  120. {
  121. __is.setf(__x.__base_ == 8 ? ios_base::oct :
  122. __x.__base_ == 10 ? ios_base::dec :
  123. __x.__base_ == 16 ? ios_base::hex :
  124. ios_base::fmtflags(0), ios_base::basefield);
  125. return __is;
  126. }
  127. template <class _CharT, class _Traits>
  128. friend
  129. _LIBCPP_INLINE_VISIBILITY
  130. basic_ostream<_CharT, _Traits>&
  131. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x)
  132. {
  133. __os.setf(__x.__base_ == 8 ? ios_base::oct :
  134. __x.__base_ == 10 ? ios_base::dec :
  135. __x.__base_ == 16 ? ios_base::hex :
  136. ios_base::fmtflags(0), ios_base::basefield);
  137. return __os;
  138. }
  139. };
  140. inline _LIBCPP_INLINE_VISIBILITY
  141. __iom_t3
  142. setbase(int __base)
  143. {
  144. return __iom_t3(__base);
  145. }
  146. // setfill
  147. template<class _CharT>
  148. class __iom_t4
  149. {
  150. _CharT __fill_;
  151. public:
  152. _LIBCPP_INLINE_VISIBILITY
  153. explicit __iom_t4(_CharT __c) : __fill_(__c) {}
  154. template <class _Traits>
  155. friend
  156. _LIBCPP_INLINE_VISIBILITY
  157. basic_ostream<_CharT, _Traits>&
  158. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x)
  159. {
  160. __os.fill(__x.__fill_);
  161. return __os;
  162. }
  163. };
  164. template<class _CharT>
  165. inline _LIBCPP_INLINE_VISIBILITY
  166. __iom_t4<_CharT>
  167. setfill(_CharT __c)
  168. {
  169. return __iom_t4<_CharT>(__c);
  170. }
  171. // setprecision
  172. class __iom_t5
  173. {
  174. int __n_;
  175. public:
  176. _LIBCPP_INLINE_VISIBILITY
  177. explicit __iom_t5(int __n) : __n_(__n) {}
  178. template <class _CharT, class _Traits>
  179. friend
  180. _LIBCPP_INLINE_VISIBILITY
  181. basic_istream<_CharT, _Traits>&
  182. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x)
  183. {
  184. __is.precision(__x.__n_);
  185. return __is;
  186. }
  187. template <class _CharT, class _Traits>
  188. friend
  189. _LIBCPP_INLINE_VISIBILITY
  190. basic_ostream<_CharT, _Traits>&
  191. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x)
  192. {
  193. __os.precision(__x.__n_);
  194. return __os;
  195. }
  196. };
  197. inline _LIBCPP_INLINE_VISIBILITY
  198. __iom_t5
  199. setprecision(int __n)
  200. {
  201. return __iom_t5(__n);
  202. }
  203. // setw
  204. class __iom_t6
  205. {
  206. int __n_;
  207. public:
  208. _LIBCPP_INLINE_VISIBILITY
  209. explicit __iom_t6(int __n) : __n_(__n) {}
  210. template <class _CharT, class _Traits>
  211. friend
  212. _LIBCPP_INLINE_VISIBILITY
  213. basic_istream<_CharT, _Traits>&
  214. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x)
  215. {
  216. __is.width(__x.__n_);
  217. return __is;
  218. }
  219. template <class _CharT, class _Traits>
  220. friend
  221. _LIBCPP_INLINE_VISIBILITY
  222. basic_ostream<_CharT, _Traits>&
  223. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x)
  224. {
  225. __os.width(__x.__n_);
  226. return __os;
  227. }
  228. };
  229. inline _LIBCPP_INLINE_VISIBILITY
  230. __iom_t6
  231. setw(int __n)
  232. {
  233. return __iom_t6(__n);
  234. }
  235. // get_money
  236. template <class _MoneyT> class __iom_t7;
  237. template <class _CharT, class _Traits, class _MoneyT>
  238. basic_istream<_CharT, _Traits>&
  239. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
  240. template <class _MoneyT>
  241. class __iom_t7
  242. {
  243. _MoneyT& __mon_;
  244. bool __intl_;
  245. public:
  246. _LIBCPP_INLINE_VISIBILITY
  247. __iom_t7(_MoneyT& __mon, bool __intl)
  248. : __mon_(__mon), __intl_(__intl) {}
  249. template <class _CharT, class _Traits, class _Mp>
  250. friend
  251. basic_istream<_CharT, _Traits>&
  252. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x);
  253. };
  254. template <class _CharT, class _Traits, class _MoneyT>
  255. basic_istream<_CharT, _Traits>&
  256. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
  257. {
  258. #ifndef _LIBCPP_NO_EXCEPTIONS
  259. try
  260. {
  261. #endif // _LIBCPP_NO_EXCEPTIONS
  262. typename basic_istream<_CharT, _Traits>::sentry __s(__is);
  263. if (__s)
  264. {
  265. typedef istreambuf_iterator<_CharT, _Traits> _Ip;
  266. typedef money_get<_CharT, _Ip> _Fp;
  267. ios_base::iostate __err = ios_base::goodbit;
  268. const _Fp& __mf = use_facet<_Fp>(__is.getloc());
  269. __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
  270. __is.setstate(__err);
  271. }
  272. #ifndef _LIBCPP_NO_EXCEPTIONS
  273. }
  274. catch (...)
  275. {
  276. __is.__set_badbit_and_consider_rethrow();
  277. }
  278. #endif // _LIBCPP_NO_EXCEPTIONS
  279. return __is;
  280. }
  281. template <class _MoneyT>
  282. inline _LIBCPP_INLINE_VISIBILITY
  283. __iom_t7<_MoneyT>
  284. get_money(_MoneyT& __mon, bool __intl = false)
  285. {
  286. return __iom_t7<_MoneyT>(__mon, __intl);
  287. }
  288. // put_money
  289. template <class _MoneyT> class __iom_t8;
  290. template <class _CharT, class _Traits, class _MoneyT>
  291. basic_ostream<_CharT, _Traits>&
  292. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
  293. template <class _MoneyT>
  294. class __iom_t8
  295. {
  296. const _MoneyT& __mon_;
  297. bool __intl_;
  298. public:
  299. _LIBCPP_INLINE_VISIBILITY
  300. __iom_t8(const _MoneyT& __mon, bool __intl)
  301. : __mon_(__mon), __intl_(__intl) {}
  302. template <class _CharT, class _Traits, class _Mp>
  303. friend
  304. basic_ostream<_CharT, _Traits>&
  305. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x);
  306. };
  307. template <class _CharT, class _Traits, class _MoneyT>
  308. basic_ostream<_CharT, _Traits>&
  309. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
  310. {
  311. #ifndef _LIBCPP_NO_EXCEPTIONS
  312. try
  313. {
  314. #endif // _LIBCPP_NO_EXCEPTIONS
  315. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  316. if (__s)
  317. {
  318. typedef ostreambuf_iterator<_CharT, _Traits> _Op;
  319. typedef money_put<_CharT, _Op> _Fp;
  320. const _Fp& __mf = use_facet<_Fp>(__os.getloc());
  321. if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
  322. __os.setstate(ios_base::badbit);
  323. }
  324. #ifndef _LIBCPP_NO_EXCEPTIONS
  325. }
  326. catch (...)
  327. {
  328. __os.__set_badbit_and_consider_rethrow();
  329. }
  330. #endif // _LIBCPP_NO_EXCEPTIONS
  331. return __os;
  332. }
  333. template <class _MoneyT>
  334. inline _LIBCPP_INLINE_VISIBILITY
  335. __iom_t8<_MoneyT>
  336. put_money(const _MoneyT& __mon, bool __intl = false)
  337. {
  338. return __iom_t8<_MoneyT>(__mon, __intl);
  339. }
  340. // get_time
  341. template <class _CharT> class __iom_t9;
  342. template <class _CharT, class _Traits>
  343. basic_istream<_CharT, _Traits>&
  344. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
  345. template <class _CharT>
  346. class __iom_t9
  347. {
  348. tm* __tm_;
  349. const _CharT* __fmt_;
  350. public:
  351. _LIBCPP_INLINE_VISIBILITY
  352. __iom_t9(tm* __tm, const _CharT* __fmt)
  353. : __tm_(__tm), __fmt_(__fmt) {}
  354. template <class _Cp, class _Traits>
  355. friend
  356. basic_istream<_Cp, _Traits>&
  357. operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x);
  358. };
  359. template <class _CharT, class _Traits>
  360. basic_istream<_CharT, _Traits>&
  361. operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
  362. {
  363. #ifndef _LIBCPP_NO_EXCEPTIONS
  364. try
  365. {
  366. #endif // _LIBCPP_NO_EXCEPTIONS
  367. typename basic_istream<_CharT, _Traits>::sentry __s(__is);
  368. if (__s)
  369. {
  370. typedef istreambuf_iterator<_CharT, _Traits> _Ip;
  371. typedef time_get<_CharT, _Ip> _Fp;
  372. ios_base::iostate __err = ios_base::goodbit;
  373. const _Fp& __tf = use_facet<_Fp>(__is.getloc());
  374. __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,
  375. __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
  376. __is.setstate(__err);
  377. }
  378. #ifndef _LIBCPP_NO_EXCEPTIONS
  379. }
  380. catch (...)
  381. {
  382. __is.__set_badbit_and_consider_rethrow();
  383. }
  384. #endif // _LIBCPP_NO_EXCEPTIONS
  385. return __is;
  386. }
  387. template <class _CharT>
  388. inline _LIBCPP_INLINE_VISIBILITY
  389. __iom_t9<_CharT>
  390. get_time(tm* __tm, const _CharT* __fmt)
  391. {
  392. return __iom_t9<_CharT>(__tm, __fmt);
  393. }
  394. // put_time
  395. template <class _CharT> class __iom_t10;
  396. template <class _CharT, class _Traits>
  397. basic_ostream<_CharT, _Traits>&
  398. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
  399. template <class _CharT>
  400. class __iom_t10
  401. {
  402. const tm* __tm_;
  403. const _CharT* __fmt_;
  404. public:
  405. _LIBCPP_INLINE_VISIBILITY
  406. __iom_t10(const tm* __tm, const _CharT* __fmt)
  407. : __tm_(__tm), __fmt_(__fmt) {}
  408. template <class _Cp, class _Traits>
  409. friend
  410. basic_ostream<_Cp, _Traits>&
  411. operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x);
  412. };
  413. template <class _CharT, class _Traits>
  414. basic_ostream<_CharT, _Traits>&
  415. operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
  416. {
  417. #ifndef _LIBCPP_NO_EXCEPTIONS
  418. try
  419. {
  420. #endif // _LIBCPP_NO_EXCEPTIONS
  421. typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
  422. if (__s)
  423. {
  424. typedef ostreambuf_iterator<_CharT, _Traits> _Op;
  425. typedef time_put<_CharT, _Op> _Fp;
  426. const _Fp& __tf = use_facet<_Fp>(__os.getloc());
  427. if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,
  428. __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
  429. __os.setstate(ios_base::badbit);
  430. }
  431. #ifndef _LIBCPP_NO_EXCEPTIONS
  432. }
  433. catch (...)
  434. {
  435. __os.__set_badbit_and_consider_rethrow();
  436. }
  437. #endif // _LIBCPP_NO_EXCEPTIONS
  438. return __os;
  439. }
  440. template <class _CharT>
  441. inline _LIBCPP_INLINE_VISIBILITY
  442. __iom_t10<_CharT>
  443. put_time(const tm* __tm, const _CharT* __fmt)
  444. {
  445. return __iom_t10<_CharT>(__tm, __fmt);
  446. }
  447. template <class _CharT, class _Traits, class _ForwardIterator>
  448. std::basic_ostream<_CharT, _Traits> &
  449. __quoted_output ( basic_ostream<_CharT, _Traits> &__os,
  450. _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
  451. {
  452. _VSTD::basic_string<_CharT, _Traits> __str;
  453. __str.push_back(__delim);
  454. for ( ; __first != __last; ++ __first )
  455. {
  456. if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
  457. __str.push_back(__escape);
  458. __str.push_back(*__first);
  459. }
  460. __str.push_back(__delim);
  461. return __put_character_sequence(__os, __str.data(), __str.size());
  462. }
  463. template <class _CharT, class _Traits, class _String>
  464. basic_istream<_CharT, _Traits> &
  465. __quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape )
  466. {
  467. __string.clear ();
  468. _CharT __c;
  469. __is >> __c;
  470. if ( __is.fail ())
  471. return __is;
  472. if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string
  473. {
  474. __is.unget ();
  475. __is >> __string;
  476. return __is;
  477. }
  478. __save_flags<_CharT, _Traits> sf(__is);
  479. noskipws (__is);
  480. while (true)
  481. {
  482. __is >> __c;
  483. if ( __is.fail ())
  484. break;
  485. if (_Traits::eq (__c, __escape))
  486. {
  487. __is >> __c;
  488. if ( __is.fail ())
  489. break;
  490. }
  491. else if (_Traits::eq (__c, __delim))
  492. break;
  493. __string.push_back ( __c );
  494. }
  495. return __is;
  496. }
  497. template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
  498. struct __quoted_output_proxy
  499. {
  500. _Iter __first;
  501. _Iter __last;
  502. _CharT __delim;
  503. _CharT __escape;
  504. __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
  505. : __first(__f), __last(__l), __delim(__d), __escape(__e) {}
  506. // This would be a nice place for a string_ref
  507. };
  508. template <class _CharT, class _Traits, class _Iter>
  509. basic_ostream<_CharT, _Traits>& operator<<(
  510. basic_ostream<_CharT, _Traits>& __os,
  511. const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
  512. {
  513. return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);
  514. }
  515. template <class _CharT, class _Traits, class _Allocator>
  516. struct __quoted_proxy
  517. {
  518. basic_string<_CharT, _Traits, _Allocator> &__string;
  519. _CharT __delim;
  520. _CharT __escape;
  521. __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e)
  522. : __string(__s), __delim(__d), __escape(__e) {}
  523. };
  524. template <class _CharT, class _Traits, class _Allocator>
  525. _LIBCPP_INLINE_VISIBILITY
  526. basic_ostream<_CharT, _Traits>& operator<<(
  527. basic_ostream<_CharT, _Traits>& __os,
  528. const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
  529. {
  530. return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);
  531. }
  532. // extractor for non-const basic_string& proxies
  533. template <class _CharT, class _Traits, class _Allocator>
  534. _LIBCPP_INLINE_VISIBILITY
  535. basic_istream<_CharT, _Traits>& operator>>(
  536. basic_istream<_CharT, _Traits>& __is,
  537. const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
  538. {
  539. return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
  540. }
  541. template <class _CharT>
  542. _LIBCPP_INLINE_VISIBILITY
  543. __quoted_output_proxy<_CharT, const _CharT *>
  544. quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\'))
  545. {
  546. const _CharT *__end = __s;
  547. while ( *__end ) ++__end;
  548. return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
  549. }
  550. template <class _CharT, class _Traits, class _Allocator>
  551. _LIBCPP_INLINE_VISIBILITY
  552. __quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
  553. __quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
  554. {
  555. return __quoted_output_proxy<_CharT,
  556. typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
  557. ( __s.cbegin(), __s.cend (), __delim, __escape );
  558. }
  559. template <class _CharT, class _Traits, class _Allocator>
  560. _LIBCPP_INLINE_VISIBILITY
  561. __quoted_proxy<_CharT, _Traits, _Allocator>
  562. __quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
  563. {
  564. return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
  565. }
  566. #if _LIBCPP_STD_VER > 11
  567. template <class _CharT, class _Traits, class _Allocator>
  568. _LIBCPP_INLINE_VISIBILITY
  569. __quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
  570. quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
  571. {
  572. return __quoted(__s, __delim, __escape);
  573. }
  574. template <class _CharT, class _Traits, class _Allocator>
  575. _LIBCPP_INLINE_VISIBILITY
  576. __quoted_proxy<_CharT, _Traits, _Allocator>
  577. quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
  578. {
  579. return __quoted(__s, __delim, __escape);
  580. }
  581. #endif
  582. _LIBCPP_END_NAMESPACE_STD
  583. #endif // !defined(_LIBCPP_SGX_CONFIG)
  584. #endif // _LIBCPP_IOMANIP