138fd1498Szrj// Standard stream manipulators -*- C++ -*- 238fd1498Szrj 338fd1498Szrj// Copyright (C) 1997-2018 Free Software Foundation, Inc. 438fd1498Szrj// 538fd1498Szrj// This file is part of the GNU ISO C++ Library. This library is free 638fd1498Szrj// software; you can redistribute it and/or modify it under the 738fd1498Szrj// terms of the GNU General Public License as published by the 838fd1498Szrj// Free Software Foundation; either version 3, or (at your option) 938fd1498Szrj// any later version. 1038fd1498Szrj 1138fd1498Szrj// This library is distributed in the hope that it will be useful, 1238fd1498Szrj// but WITHOUT ANY WARRANTY; without even the implied warranty of 1338fd1498Szrj// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1438fd1498Szrj// GNU General Public License for more details. 1538fd1498Szrj 1638fd1498Szrj// Under Section 7 of GPL version 3, you are granted additional 1738fd1498Szrj// permissions described in the GCC Runtime Library Exception, version 1838fd1498Szrj// 3.1, as published by the Free Software Foundation. 1938fd1498Szrj 2038fd1498Szrj// You should have received a copy of the GNU General Public License and 2138fd1498Szrj// a copy of the GCC Runtime Library Exception along with this program; 2238fd1498Szrj// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2338fd1498Szrj// <http://www.gnu.org/licenses/>. 2438fd1498Szrj 2538fd1498Szrj/** @file include/iomanip 2638fd1498Szrj * This is a Standard C++ Library header. 2738fd1498Szrj */ 2838fd1498Szrj 2938fd1498Szrj// 3038fd1498Szrj// ISO C++ 14882: 27.6.3 Standard manipulators 3138fd1498Szrj// 3238fd1498Szrj 3338fd1498Szrj#ifndef _GLIBCXX_IOMANIP 3438fd1498Szrj#define _GLIBCXX_IOMANIP 1 3538fd1498Szrj 3638fd1498Szrj#pragma GCC system_header 3738fd1498Szrj 3838fd1498Szrj#include <bits/c++config.h> 3938fd1498Szrj#include <iosfwd> 4038fd1498Szrj#include <bits/ios_base.h> 4138fd1498Szrj 4238fd1498Szrj#if __cplusplus >= 201103L 4338fd1498Szrj#include <locale> 4438fd1498Szrj#if __cplusplus > 201103L 4538fd1498Szrj#include <bits/quoted_string.h> 4638fd1498Szrj#endif 4738fd1498Szrj#endif 4838fd1498Szrj 4938fd1498Szrjnamespace std _GLIBCXX_VISIBILITY(default) 5038fd1498Szrj{ 5138fd1498Szrj_GLIBCXX_BEGIN_NAMESPACE_VERSION 5238fd1498Szrj 5338fd1498Szrj // [27.6.3] standard manipulators 5438fd1498Szrj // Also see DR 183. 5538fd1498Szrj 5638fd1498Szrj struct _Resetiosflags { ios_base::fmtflags _M_mask; }; 5738fd1498Szrj 5838fd1498Szrj /** 5938fd1498Szrj * @brief Manipulator for @c setf. 6038fd1498Szrj * @param __mask A format flags mask. 6138fd1498Szrj * 6238fd1498Szrj * Sent to a stream object, this manipulator resets the specified flags, 6338fd1498Szrj * via @e stream.setf(0,__mask). 6438fd1498Szrj */ 6538fd1498Szrj inline _Resetiosflags 6638fd1498Szrj resetiosflags(ios_base::fmtflags __mask) 6738fd1498Szrj { return { __mask }; } 6838fd1498Szrj 6938fd1498Szrj template<typename _CharT, typename _Traits> 7038fd1498Szrj inline basic_istream<_CharT, _Traits>& 7138fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) 7238fd1498Szrj { 7338fd1498Szrj __is.setf(ios_base::fmtflags(0), __f._M_mask); 7438fd1498Szrj return __is; 7538fd1498Szrj } 7638fd1498Szrj 7738fd1498Szrj template<typename _CharT, typename _Traits> 7838fd1498Szrj inline basic_ostream<_CharT, _Traits>& 7938fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f) 8038fd1498Szrj { 8138fd1498Szrj __os.setf(ios_base::fmtflags(0), __f._M_mask); 8238fd1498Szrj return __os; 8338fd1498Szrj } 8438fd1498Szrj 8538fd1498Szrj 8638fd1498Szrj struct _Setiosflags { ios_base::fmtflags _M_mask; }; 8738fd1498Szrj 8838fd1498Szrj /** 8938fd1498Szrj * @brief Manipulator for @c setf. 9038fd1498Szrj * @param __mask A format flags mask. 9138fd1498Szrj * 9238fd1498Szrj * Sent to a stream object, this manipulator sets the format flags 9338fd1498Szrj * to @a __mask. 9438fd1498Szrj */ 9538fd1498Szrj inline _Setiosflags 9638fd1498Szrj setiosflags(ios_base::fmtflags __mask) 9738fd1498Szrj { return { __mask }; } 9838fd1498Szrj 9938fd1498Szrj template<typename _CharT, typename _Traits> 10038fd1498Szrj inline basic_istream<_CharT, _Traits>& 10138fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f) 10238fd1498Szrj { 10338fd1498Szrj __is.setf(__f._M_mask); 10438fd1498Szrj return __is; 10538fd1498Szrj } 10638fd1498Szrj 10738fd1498Szrj template<typename _CharT, typename _Traits> 10838fd1498Szrj inline basic_ostream<_CharT, _Traits>& 10938fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f) 11038fd1498Szrj { 11138fd1498Szrj __os.setf(__f._M_mask); 11238fd1498Szrj return __os; 11338fd1498Szrj } 11438fd1498Szrj 11538fd1498Szrj 11638fd1498Szrj struct _Setbase { int _M_base; }; 11738fd1498Szrj 11838fd1498Szrj /** 11938fd1498Szrj * @brief Manipulator for @c setf. 12038fd1498Szrj * @param __base A numeric base. 12138fd1498Szrj * 12238fd1498Szrj * Sent to a stream object, this manipulator changes the 12338fd1498Szrj * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base 12438fd1498Szrj * is 8, 10, or 16, accordingly, and to 0 if @a __base is any other value. 12538fd1498Szrj */ 12638fd1498Szrj inline _Setbase 12738fd1498Szrj setbase(int __base) 12838fd1498Szrj { return { __base }; } 12938fd1498Szrj 13038fd1498Szrj template<typename _CharT, typename _Traits> 13138fd1498Szrj inline basic_istream<_CharT, _Traits>& 13238fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f) 13338fd1498Szrj { 13438fd1498Szrj __is.setf(__f._M_base == 8 ? ios_base::oct : 13538fd1498Szrj __f._M_base == 10 ? ios_base::dec : 13638fd1498Szrj __f._M_base == 16 ? ios_base::hex : 13738fd1498Szrj ios_base::fmtflags(0), ios_base::basefield); 13838fd1498Szrj return __is; 13938fd1498Szrj } 14038fd1498Szrj 14138fd1498Szrj template<typename _CharT, typename _Traits> 14238fd1498Szrj inline basic_ostream<_CharT, _Traits>& 14338fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f) 14438fd1498Szrj { 14538fd1498Szrj __os.setf(__f._M_base == 8 ? ios_base::oct : 14638fd1498Szrj __f._M_base == 10 ? ios_base::dec : 14738fd1498Szrj __f._M_base == 16 ? ios_base::hex : 14838fd1498Szrj ios_base::fmtflags(0), ios_base::basefield); 14938fd1498Szrj return __os; 15038fd1498Szrj } 15138fd1498Szrj 15238fd1498Szrj 15338fd1498Szrj template<typename _CharT> 15438fd1498Szrj struct _Setfill { _CharT _M_c; }; 15538fd1498Szrj 15638fd1498Szrj /** 15738fd1498Szrj * @brief Manipulator for @c fill. 15838fd1498Szrj * @param __c The new fill character. 15938fd1498Szrj * 16038fd1498Szrj * Sent to a stream object, this manipulator calls @c fill(__c) for that 16138fd1498Szrj * object. 16238fd1498Szrj */ 16338fd1498Szrj template<typename _CharT> 16438fd1498Szrj inline _Setfill<_CharT> 16538fd1498Szrj setfill(_CharT __c) 16638fd1498Szrj { return { __c }; } 16738fd1498Szrj 16838fd1498Szrj template<typename _CharT, typename _Traits> 16938fd1498Szrj inline basic_istream<_CharT, _Traits>& 17038fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f) 17138fd1498Szrj { 17238fd1498Szrj __is.fill(__f._M_c); 17338fd1498Szrj return __is; 17438fd1498Szrj } 17538fd1498Szrj 17638fd1498Szrj template<typename _CharT, typename _Traits> 17738fd1498Szrj inline basic_ostream<_CharT, _Traits>& 17838fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f) 17938fd1498Szrj { 18038fd1498Szrj __os.fill(__f._M_c); 18138fd1498Szrj return __os; 18238fd1498Szrj } 18338fd1498Szrj 18438fd1498Szrj 18538fd1498Szrj struct _Setprecision { int _M_n; }; 18638fd1498Szrj 18738fd1498Szrj /** 18838fd1498Szrj * @brief Manipulator for @c precision. 18938fd1498Szrj * @param __n The new precision. 19038fd1498Szrj * 19138fd1498Szrj * Sent to a stream object, this manipulator calls @c precision(__n) for 19238fd1498Szrj * that object. 19338fd1498Szrj */ 19438fd1498Szrj inline _Setprecision 19538fd1498Szrj setprecision(int __n) 19638fd1498Szrj { return { __n }; } 19738fd1498Szrj 19838fd1498Szrj template<typename _CharT, typename _Traits> 19938fd1498Szrj inline basic_istream<_CharT, _Traits>& 20038fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f) 20138fd1498Szrj { 20238fd1498Szrj __is.precision(__f._M_n); 20338fd1498Szrj return __is; 20438fd1498Szrj } 20538fd1498Szrj 20638fd1498Szrj template<typename _CharT, typename _Traits> 20738fd1498Szrj inline basic_ostream<_CharT, _Traits>& 20838fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f) 20938fd1498Szrj { 21038fd1498Szrj __os.precision(__f._M_n); 21138fd1498Szrj return __os; 21238fd1498Szrj } 21338fd1498Szrj 21438fd1498Szrj 21538fd1498Szrj struct _Setw { int _M_n; }; 21638fd1498Szrj 21738fd1498Szrj /** 21838fd1498Szrj * @brief Manipulator for @c width. 21938fd1498Szrj * @param __n The new width. 22038fd1498Szrj * 22138fd1498Szrj * Sent to a stream object, this manipulator calls @c width(__n) for 22238fd1498Szrj * that object. 22338fd1498Szrj */ 22438fd1498Szrj inline _Setw 22538fd1498Szrj setw(int __n) 22638fd1498Szrj { return { __n }; } 22738fd1498Szrj 22838fd1498Szrj template<typename _CharT, typename _Traits> 22938fd1498Szrj inline basic_istream<_CharT, _Traits>& 23038fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f) 23138fd1498Szrj { 23238fd1498Szrj __is.width(__f._M_n); 23338fd1498Szrj return __is; 23438fd1498Szrj } 23538fd1498Szrj 23638fd1498Szrj template<typename _CharT, typename _Traits> 23738fd1498Szrj inline basic_ostream<_CharT, _Traits>& 23838fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f) 23938fd1498Szrj { 24038fd1498Szrj __os.width(__f._M_n); 24138fd1498Szrj return __os; 24238fd1498Szrj } 24338fd1498Szrj 24438fd1498Szrj#if __cplusplus >= 201103L 24538fd1498Szrj 24638fd1498Szrj template<typename _MoneyT> 24738fd1498Szrj struct _Get_money { _MoneyT& _M_mon; bool _M_intl; }; 24838fd1498Szrj 24938fd1498Szrj /** 25038fd1498Szrj * @brief Extended manipulator for extracting money. 25138fd1498Szrj * @param __mon Either long double or a specialization of @c basic_string. 25238fd1498Szrj * @param __intl A bool indicating whether international format 25338fd1498Szrj * is to be used. 25438fd1498Szrj * 25538fd1498Szrj * Sent to a stream object, this manipulator extracts @a __mon. 25638fd1498Szrj */ 25738fd1498Szrj template<typename _MoneyT> 25838fd1498Szrj inline _Get_money<_MoneyT> 25938fd1498Szrj get_money(_MoneyT& __mon, bool __intl = false) 26038fd1498Szrj { return { __mon, __intl }; } 26138fd1498Szrj 26238fd1498Szrj template<typename _CharT, typename _Traits, typename _MoneyT> 26338fd1498Szrj basic_istream<_CharT, _Traits>& 26438fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f) 26538fd1498Szrj { 26638fd1498Szrj typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false); 26738fd1498Szrj if (__cerb) 26838fd1498Szrj { 26938fd1498Szrj ios_base::iostate __err = ios_base::goodbit; 27038fd1498Szrj __try 27138fd1498Szrj { 27238fd1498Szrj typedef istreambuf_iterator<_CharT, _Traits> _Iter; 27338fd1498Szrj typedef money_get<_CharT, _Iter> _MoneyGet; 27438fd1498Szrj 27538fd1498Szrj const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc()); 27638fd1498Szrj __mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl, 27738fd1498Szrj __is, __err, __f._M_mon); 27838fd1498Szrj } 27938fd1498Szrj __catch(__cxxabiv1::__forced_unwind&) 28038fd1498Szrj { 28138fd1498Szrj __is._M_setstate(ios_base::badbit); 28238fd1498Szrj __throw_exception_again; 28338fd1498Szrj } 28438fd1498Szrj __catch(...) 28538fd1498Szrj { __is._M_setstate(ios_base::badbit); } 28638fd1498Szrj if (__err) 28738fd1498Szrj __is.setstate(__err); 28838fd1498Szrj } 28938fd1498Szrj return __is; 29038fd1498Szrj } 29138fd1498Szrj 29238fd1498Szrj 29338fd1498Szrj template<typename _MoneyT> 29438fd1498Szrj struct _Put_money { const _MoneyT& _M_mon; bool _M_intl; }; 29538fd1498Szrj 29638fd1498Szrj /** 29738fd1498Szrj * @brief Extended manipulator for inserting money. 29838fd1498Szrj * @param __mon Either long double or a specialization of @c basic_string. 29938fd1498Szrj * @param __intl A bool indicating whether international format 30038fd1498Szrj * is to be used. 30138fd1498Szrj * 30238fd1498Szrj * Sent to a stream object, this manipulator inserts @a __mon. 30338fd1498Szrj */ 30438fd1498Szrj template<typename _MoneyT> 30538fd1498Szrj inline _Put_money<_MoneyT> 30638fd1498Szrj put_money(const _MoneyT& __mon, bool __intl = false) 30738fd1498Szrj { return { __mon, __intl }; } 30838fd1498Szrj 30938fd1498Szrj template<typename _CharT, typename _Traits, typename _MoneyT> 31038fd1498Szrj basic_ostream<_CharT, _Traits>& 31138fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f) 31238fd1498Szrj { 31338fd1498Szrj typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os); 31438fd1498Szrj if (__cerb) 31538fd1498Szrj { 31638fd1498Szrj ios_base::iostate __err = ios_base::goodbit; 31738fd1498Szrj __try 31838fd1498Szrj { 31938fd1498Szrj typedef ostreambuf_iterator<_CharT, _Traits> _Iter; 32038fd1498Szrj typedef money_put<_CharT, _Iter> _MoneyPut; 32138fd1498Szrj 32238fd1498Szrj const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc()); 32338fd1498Szrj if (__mp.put(_Iter(__os.rdbuf()), __f._M_intl, __os, 32438fd1498Szrj __os.fill(), __f._M_mon).failed()) 32538fd1498Szrj __err |= ios_base::badbit; 32638fd1498Szrj } 32738fd1498Szrj __catch(__cxxabiv1::__forced_unwind&) 32838fd1498Szrj { 32938fd1498Szrj __os._M_setstate(ios_base::badbit); 33038fd1498Szrj __throw_exception_again; 33138fd1498Szrj } 33238fd1498Szrj __catch(...) 33338fd1498Szrj { __os._M_setstate(ios_base::badbit); } 33438fd1498Szrj if (__err) 33538fd1498Szrj __os.setstate(__err); 33638fd1498Szrj } 33738fd1498Szrj return __os; 33838fd1498Szrj } 33938fd1498Szrj 34038fd1498Szrj template<typename _CharT> 34138fd1498Szrj struct _Put_time 34238fd1498Szrj { 34338fd1498Szrj const std::tm* _M_tmb; 34438fd1498Szrj const _CharT* _M_fmt; 34538fd1498Szrj }; 34638fd1498Szrj 34738fd1498Szrj /** 34838fd1498Szrj * @brief Extended manipulator for formatting time. 34938fd1498Szrj * 35038fd1498Szrj * This manipulator uses time_put::put to format time. 35138fd1498Szrj * [ext.manip] 35238fd1498Szrj * 35338fd1498Szrj * @param __tmb struct tm time data to format. 35438fd1498Szrj * @param __fmt format string. 35538fd1498Szrj */ 35638fd1498Szrj template<typename _CharT> 35738fd1498Szrj inline _Put_time<_CharT> 35838fd1498Szrj put_time(const std::tm* __tmb, const _CharT* __fmt) 35938fd1498Szrj { return { __tmb, __fmt }; } 36038fd1498Szrj 36138fd1498Szrj template<typename _CharT, typename _Traits> 36238fd1498Szrj basic_ostream<_CharT, _Traits>& 36338fd1498Szrj operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_time<_CharT> __f) 36438fd1498Szrj { 36538fd1498Szrj typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os); 36638fd1498Szrj if (__cerb) 36738fd1498Szrj { 36838fd1498Szrj ios_base::iostate __err = ios_base::goodbit; 36938fd1498Szrj __try 37038fd1498Szrj { 37138fd1498Szrj typedef ostreambuf_iterator<_CharT, _Traits> _Iter; 37238fd1498Szrj typedef time_put<_CharT, _Iter> _TimePut; 37338fd1498Szrj 37438fd1498Szrj const _CharT* const __fmt_end = __f._M_fmt + 37538fd1498Szrj _Traits::length(__f._M_fmt); 37638fd1498Szrj 37738fd1498Szrj const _TimePut& __mp = use_facet<_TimePut>(__os.getloc()); 37838fd1498Szrj if (__mp.put(_Iter(__os.rdbuf()), __os, __os.fill(), 37938fd1498Szrj __f._M_tmb, __f._M_fmt, __fmt_end).failed()) 38038fd1498Szrj __err |= ios_base::badbit; 38138fd1498Szrj } 38238fd1498Szrj __catch(__cxxabiv1::__forced_unwind&) 38338fd1498Szrj { 38438fd1498Szrj __os._M_setstate(ios_base::badbit); 38538fd1498Szrj __throw_exception_again; 38638fd1498Szrj } 38738fd1498Szrj __catch(...) 38838fd1498Szrj { __os._M_setstate(ios_base::badbit); } 38938fd1498Szrj if (__err) 39038fd1498Szrj __os.setstate(__err); 39138fd1498Szrj } 39238fd1498Szrj return __os; 39338fd1498Szrj } 39438fd1498Szrj 39538fd1498Szrj template<typename _CharT> 39638fd1498Szrj struct _Get_time 39738fd1498Szrj { 39838fd1498Szrj std::tm* _M_tmb; 39938fd1498Szrj const _CharT* _M_fmt; 40038fd1498Szrj }; 40138fd1498Szrj 40238fd1498Szrj /** 40338fd1498Szrj * @brief Extended manipulator for extracting time. 40438fd1498Szrj * 40538fd1498Szrj * This manipulator uses time_get::get to extract time. 40638fd1498Szrj * [ext.manip] 40738fd1498Szrj * 40838fd1498Szrj * @param __tmb struct to extract the time data to. 40938fd1498Szrj * @param __fmt format string. 41038fd1498Szrj */ 41138fd1498Szrj template<typename _CharT> 41238fd1498Szrj inline _Get_time<_CharT> 41338fd1498Szrj get_time(std::tm* __tmb, const _CharT* __fmt) 41438fd1498Szrj { return { __tmb, __fmt }; } 41538fd1498Szrj 41638fd1498Szrj template<typename _CharT, typename _Traits> 41738fd1498Szrj basic_istream<_CharT, _Traits>& 41838fd1498Szrj operator>>(basic_istream<_CharT, _Traits>& __is, _Get_time<_CharT> __f) 41938fd1498Szrj { 42038fd1498Szrj typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false); 42138fd1498Szrj if (__cerb) 42238fd1498Szrj { 42338fd1498Szrj ios_base::iostate __err = ios_base::goodbit; 42438fd1498Szrj __try 42538fd1498Szrj { 42638fd1498Szrj typedef istreambuf_iterator<_CharT, _Traits> _Iter; 42738fd1498Szrj typedef time_get<_CharT, _Iter> _TimeGet; 42838fd1498Szrj 42938fd1498Szrj const _CharT* const __fmt_end = __f._M_fmt + 43038fd1498Szrj _Traits::length(__f._M_fmt); 43138fd1498Szrj 43238fd1498Szrj const _TimeGet& __mg = use_facet<_TimeGet>(__is.getloc()); 43338fd1498Szrj __mg.get(_Iter(__is.rdbuf()), _Iter(), __is, 43438fd1498Szrj __err, __f._M_tmb, __f._M_fmt, __fmt_end); 43538fd1498Szrj } 43638fd1498Szrj __catch(__cxxabiv1::__forced_unwind&) 43738fd1498Szrj { 43838fd1498Szrj __is._M_setstate(ios_base::badbit); 43938fd1498Szrj __throw_exception_again; 44038fd1498Szrj } 44138fd1498Szrj __catch(...) 44238fd1498Szrj { __is._M_setstate(ios_base::badbit); } 44338fd1498Szrj if (__err) 44438fd1498Szrj __is.setstate(__err); 44538fd1498Szrj } 44638fd1498Szrj return __is; 44738fd1498Szrj } 44838fd1498Szrj 449*58e805e6Szrj#if __cplusplus >= 201402L 45038fd1498Szrj 45138fd1498Szrj#define __cpp_lib_quoted_string_io 201304 45238fd1498Szrj 45338fd1498Szrj /** 45438fd1498Szrj * @brief Manipulator for quoted strings. 45538fd1498Szrj * @param __string String to quote. 45638fd1498Szrj * @param __delim Character to quote string with. 45738fd1498Szrj * @param __escape Escape character to escape itself or quote character. 45838fd1498Szrj */ 45938fd1498Szrj template<typename _CharT> 46038fd1498Szrj inline auto 46138fd1498Szrj quoted(const _CharT* __string, 46238fd1498Szrj _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) 46338fd1498Szrj { 46438fd1498Szrj return __detail::_Quoted_string<const _CharT*, _CharT>(__string, __delim, 46538fd1498Szrj __escape); 46638fd1498Szrj } 46738fd1498Szrj 46838fd1498Szrj template<typename _CharT, typename _Traits, typename _Alloc> 46938fd1498Szrj inline auto 47038fd1498Szrj quoted(const basic_string<_CharT, _Traits, _Alloc>& __string, 47138fd1498Szrj _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) 47238fd1498Szrj { 47338fd1498Szrj return __detail::_Quoted_string< 47438fd1498Szrj const basic_string<_CharT, _Traits, _Alloc>&, _CharT>( 47538fd1498Szrj __string, __delim, __escape); 47638fd1498Szrj } 47738fd1498Szrj 47838fd1498Szrj template<typename _CharT, typename _Traits, typename _Alloc> 47938fd1498Szrj inline auto 48038fd1498Szrj quoted(basic_string<_CharT, _Traits, _Alloc>& __string, 48138fd1498Szrj _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) 48238fd1498Szrj { 48338fd1498Szrj return __detail::_Quoted_string< 48438fd1498Szrj basic_string<_CharT, _Traits, _Alloc>&, _CharT>( 48538fd1498Szrj __string, __delim, __escape); 48638fd1498Szrj } 48738fd1498Szrj 488*58e805e6Szrj#if __cplusplus >= 201703L 489*58e805e6Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 490*58e805e6Szrj // 2785. quoted should work with basic_string_view 491*58e805e6Szrj template<typename _CharT, typename _Traits> 492*58e805e6Szrj inline auto 493*58e805e6Szrj quoted(basic_string_view<_CharT, _Traits> __sv, 494*58e805e6Szrj _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) 495*58e805e6Szrj { 496*58e805e6Szrj return __detail::_Quoted_string< 497*58e805e6Szrj basic_string_view<_CharT, _Traits>, _CharT>(__sv, __delim, __escape); 498*58e805e6Szrj } 499*58e805e6Szrj#endif // C++17 500*58e805e6Szrj#endif // C++14 50138fd1498Szrj 50238fd1498Szrj#endif // __cplusplus >= 201103L 50338fd1498Szrj 50438fd1498Szrj // Inhibit implicit instantiations for required instantiations, 50538fd1498Szrj // which are defined via explicit instantiations elsewhere. 50638fd1498Szrj // NB: This syntax is a GNU extension. 50738fd1498Szrj#if _GLIBCXX_EXTERN_TEMPLATE 50838fd1498Szrj extern template ostream& operator<<(ostream&, _Setfill<char>); 50938fd1498Szrj extern template ostream& operator<<(ostream&, _Setiosflags); 51038fd1498Szrj extern template ostream& operator<<(ostream&, _Resetiosflags); 51138fd1498Szrj extern template ostream& operator<<(ostream&, _Setbase); 51238fd1498Szrj extern template ostream& operator<<(ostream&, _Setprecision); 51338fd1498Szrj extern template ostream& operator<<(ostream&, _Setw); 51438fd1498Szrj extern template istream& operator>>(istream&, _Setfill<char>); 51538fd1498Szrj extern template istream& operator>>(istream&, _Setiosflags); 51638fd1498Szrj extern template istream& operator>>(istream&, _Resetiosflags); 51738fd1498Szrj extern template istream& operator>>(istream&, _Setbase); 51838fd1498Szrj extern template istream& operator>>(istream&, _Setprecision); 51938fd1498Szrj extern template istream& operator>>(istream&, _Setw); 52038fd1498Szrj 52138fd1498Szrj#ifdef _GLIBCXX_USE_WCHAR_T 52238fd1498Szrj extern template wostream& operator<<(wostream&, _Setfill<wchar_t>); 52338fd1498Szrj extern template wostream& operator<<(wostream&, _Setiosflags); 52438fd1498Szrj extern template wostream& operator<<(wostream&, _Resetiosflags); 52538fd1498Szrj extern template wostream& operator<<(wostream&, _Setbase); 52638fd1498Szrj extern template wostream& operator<<(wostream&, _Setprecision); 52738fd1498Szrj extern template wostream& operator<<(wostream&, _Setw); 52838fd1498Szrj extern template wistream& operator>>(wistream&, _Setfill<wchar_t>); 52938fd1498Szrj extern template wistream& operator>>(wistream&, _Setiosflags); 53038fd1498Szrj extern template wistream& operator>>(wistream&, _Resetiosflags); 53138fd1498Szrj extern template wistream& operator>>(wistream&, _Setbase); 53238fd1498Szrj extern template wistream& operator>>(wistream&, _Setprecision); 53338fd1498Szrj extern template wistream& operator>>(wistream&, _Setw); 53438fd1498Szrj#endif 53538fd1498Szrj#endif 53638fd1498Szrj 53738fd1498Szrj_GLIBCXX_END_NAMESPACE_VERSION 53838fd1498Szrj} // namespace 53938fd1498Szrj 54038fd1498Szrj#endif /* _GLIBCXX_IOMANIP */ 541