]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/bits/std_iomanip.h
1 // Standard stream manipulators -*- C++ -*-
3 // Copyright (C) 1997-1999 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // ISO C++ 14882: 27.6.3 Standard manipulators
35 #define _CPP_IOMANIP 1
37 #include <bits/c++config.h>
38 #include <bits/std_istream.h>
39 #include <bits/std_functional.h>
43 struct _Resetiosflags
{ ios_base::fmtflags _M_mask
; };
46 resetiosflags(ios_base::fmtflags __mask
)
53 template <class _CharT
, class _Traits
>
54 basic_istream
<_CharT
,_Traits
>&
55 operator>>(basic_istream
<_CharT
,_Traits
>& __is
, _Resetiosflags __f
)
57 __is
.setf(ios_base::fmtflags(0), __f
._M_mask
);
61 template <class _CharT
, class _Traits
>
62 basic_ostream
<_CharT
,_Traits
>&
63 operator<<(basic_ostream
<_CharT
,_Traits
>& __os
, _Resetiosflags __f
)
65 __os
.setf(ios_base::fmtflags(0), __f
._M_mask
);
70 struct _Setiosflags
{ ios_base::fmtflags _M_mask
; };
73 setiosflags (ios_base::fmtflags __mask
)
80 template <class _CharT
, class _Traits
>
81 basic_istream
<_CharT
,_Traits
>&
82 operator>>(basic_istream
<_CharT
,_Traits
>& __is
, _Setiosflags __f
)
84 __is
.setf(__f
._M_mask
);
88 template <class _CharT
, class _Traits
>
89 basic_ostream
<_CharT
,_Traits
>&
90 operator<<(basic_ostream
<_CharT
,_Traits
>& __os
, _Setiosflags __f
)
92 __os
.setf(__f
._M_mask
);
97 struct _Setbase
{ int _M_base
; };
103 __x
._M_base
= __base
;
107 template <class _CharT
, class _Traits
>
108 basic_istream
<_CharT
,_Traits
>&
109 operator>>(basic_istream
<_CharT
,_Traits
>& __is
, _Setbase __f
)
111 __is
.setf(__f
._M_base
== 8 ? ios_base::oct
:
112 __f
._M_base
== 10 ? ios_base::dec
:
113 __f
._M_base
== 16 ? ios_base::hex
:
114 ios_base::fmtflags(0), ios_base::basefield
);
118 template <class _CharT
, class _Traits
>
119 basic_ostream
<_CharT
,_Traits
>&
120 operator<<(basic_ostream
<_CharT
,_Traits
>& __os
, _Setbase __f
)
122 __os
.setf(__f
._M_base
== 8 ? ios_base::oct
:
123 __f
._M_base
== 10 ? ios_base::dec
:
124 __f
._M_base
== 16 ? ios_base::hex
:
125 ios_base::fmtflags(0), ios_base::basefield
);
130 template<class _CharT
>
131 struct _Setfill
{ _CharT _M_c
; };
133 template<class _CharT
>
137 _Setfill
<_CharT
> __x
;
142 template <class _CharT
, class _Traits
>
143 basic_istream
<_CharT
,_Traits
>&
144 operator>>(basic_istream
<_CharT
,_Traits
>& __is
, _Setfill
<_CharT
> __f
)
150 template <class _CharT
, class _Traits
>
151 basic_ostream
<_CharT
,_Traits
>&
152 operator<<(basic_ostream
<_CharT
,_Traits
>& __os
, _Setfill
<_CharT
> __f
)
159 struct _Setprecision
{ int _M_n
; };
162 setprecision(int __n
)
169 template <class _CharT
, class _Traits
>
170 basic_istream
<_CharT
,_Traits
>&
171 operator>>(basic_istream
<_CharT
,_Traits
>& __is
, _Setprecision __f
)
173 __is
.precision(__f
._M_n
);
177 template <class _CharT
, class _Traits
>
178 basic_ostream
<_CharT
,_Traits
>&
179 operator<<(basic_ostream
<_CharT
,_Traits
>& __os
, _Setprecision __f
)
181 __os
.precision(__f
._M_n
);
186 struct _Setw
{ int _M_n
; };
196 template <class _CharT
, class _Traits
>
197 basic_istream
<_CharT
,_Traits
>&
198 operator>>(basic_istream
<_CharT
,_Traits
>& __is
, _Setw __f
)
200 __is
.width(__f
._M_n
);
204 template <class _CharT
, class _Traits
>
205 basic_ostream
<_CharT
,_Traits
>&
206 operator<<(basic_ostream
<_CharT
,_Traits
>& __os
, _Setw __f
)
208 __os
.width(__f
._M_n
);
214 #endif /* __IOMANIP */