OSDN Git Service

2001-05-24 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / ostream.tcc
1 // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library.  This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING.  If not, write to the Free
16 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 // USA.
18
19 // As a special exception, you may use this file as part of a free software
20 // library without restriction.  Specifically, if other files instantiate
21 // templates or use macros or inline functions from this file, or you compile
22 // this file and link it with other files to produce an executable, this
23 // file does not by itself cause the resulting executable to be covered by
24 // the GNU General Public License.  This exception does not however
25 // invalidate any other reasons why the executable file might be covered by
26 // the GNU General Public License.
27
28 //
29 // ISO C++ 14882: 27.6.2  Output streams
30 //
31
32 #include <bits/std_locale.h>
33
34 namespace std 
35 {
36   template<typename _CharT, typename _Traits>
37     basic_ostream<_CharT, _Traits>::sentry::
38     sentry(basic_ostream<_CharT,_Traits>& __os)
39     : _M_ok(__os.good()), _M_os(__os)
40     {
41       // XXX MT 
42       if (_M_ok && __os.tie())
43         __os.tie()->flush();  
44     }
45   
46   template<typename _CharT, typename _Traits>
47     basic_ostream<_CharT, _Traits>& 
48     basic_ostream<_CharT, _Traits>::
49     operator<<(__ostream_type& (*__pf)(__ostream_type&))
50     {
51       sentry __cerb(*this);
52       if (__cerb)
53         { 
54           try 
55             { __pf(*this); }
56           catch(exception& __fail)
57             {
58               // 27.6.2.5.1 Common requirements.
59               // Turn this on without causing an ios::failure to be thrown.
60               this->setstate(ios_base::badbit);
61               if ((this->exceptions() & ios_base::badbit) != 0)
62                 __throw_exception_again;
63             }
64         }
65       return *this;
66     }
67   
68   template<typename _CharT, typename _Traits>
69     basic_ostream<_CharT, _Traits>& 
70     basic_ostream<_CharT, _Traits>::
71     operator<<(__ios_type& (*__pf)(__ios_type&))
72     {
73       sentry __cerb(*this);
74       if (__cerb)
75         { 
76           try 
77             { __pf(*this); }
78           catch(exception& __fail)
79             {
80               // 27.6.2.5.1 Common requirements.
81               // Turn this on without causing an ios::failure to be thrown.
82               this->setstate(ios_base::badbit);
83               if ((this->exceptions() & ios_base::badbit) != 0)
84                 __throw_exception_again;
85             }
86         }
87       return *this;
88     }
89
90   template<typename _CharT, typename _Traits>
91     basic_ostream<_CharT, _Traits>& 
92     basic_ostream<_CharT, _Traits>::
93     operator<<(ios_base& (*__pf)(ios_base&))
94     {
95       sentry __cerb(*this);
96       if (__cerb)
97         { 
98           try 
99             { __pf(*this); }
100           catch(exception& __fail)
101             {
102               // 27.6.2.5.1 Common requirements.
103               // Turn this on without causing an ios::failure to be thrown.
104               this->setstate(ios_base::badbit);
105               if ((this->exceptions() & ios_base::badbit) != 0)
106                 __throw_exception_again;
107             }
108         }
109       return *this;
110     }
111
112   template<typename _CharT, typename _Traits>
113     basic_ostream<_CharT, _Traits>& 
114     basic_ostream<_CharT, _Traits>::operator<<(bool __n)
115     {
116       sentry __cerb(*this);
117       if (__cerb) 
118         {
119           try 
120             {
121               if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
122                 this->setstate(ios_base::badbit);
123             }
124           catch(exception& __fail)
125             {
126               // 27.6.1.2.1 Common requirements.
127               // Turn this on without causing an ios::failure to be thrown.
128               this->setstate(ios_base::badbit);
129               if ((this->exceptions() & ios_base::badbit) != 0)
130                 __throw_exception_again;
131             }
132         }
133       return *this;
134     }
135
136   template<typename _CharT, typename _Traits>
137     basic_ostream<_CharT, _Traits>& 
138     basic_ostream<_CharT, _Traits>::operator<<(long __n)
139     {
140       sentry __cerb(*this);
141       if (__cerb) 
142         {
143           try 
144             {
145               bool __f;
146               ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
147               if (__fmt & ios_base::oct || __fmt & ios_base::hex)
148                 __f = _M_fnumput->put(*this, *this, this->fill(), 
149                                      static_cast<unsigned long>(__n)).failed();
150               else
151                 __f = _M_fnumput->put(*this, *this, this->fill(), __n).failed();
152
153               if (__f)  
154                 this->setstate(ios_base::badbit);
155             }
156           catch(exception& __fail)
157             {
158               // 27.6.1.2.1 Common requirements.
159               // Turn this on without causing an ios::failure to be thrown.
160               this->setstate(ios_base::badbit);
161               if ((this->exceptions() & ios_base::badbit) != 0)
162                 __throw_exception_again;
163             }
164         }
165       return *this;
166     }
167
168   template<typename _CharT, typename _Traits>
169     basic_ostream<_CharT, _Traits>& 
170     basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
171     {
172       sentry __cerb(*this);
173       if (__cerb) 
174         {
175           try 
176             {
177               if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
178                 this->setstate(ios_base::badbit);
179             }
180           catch(exception& __fail)
181             {
182               // 27.6.1.2.1 Common requirements.
183               // Turn this on without causing an ios::failure to be thrown.
184               this->setstate(ios_base::badbit);
185               if ((this->exceptions() & ios_base::badbit) != 0)
186                 __throw_exception_again;
187             }
188         }
189       return *this;
190     }
191
192 #ifdef _GLIBCPP_USE_LONG_LONG
193   template<typename _CharT, typename _Traits>
194     basic_ostream<_CharT, _Traits>& 
195     basic_ostream<_CharT, _Traits>::operator<<(long long __n)
196     {
197       sentry __cerb(*this);
198       if (__cerb) 
199         {
200           try 
201             {
202               bool __f;
203               ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
204               if (__fmt & ios_base::oct || __fmt & ios_base::hex)
205                 __f = _M_fnumput->put(*this, *this, this->fill(), 
206                                 static_cast<unsigned long long>(__n)).failed();
207               else
208                 __f = _M_fnumput->put(*this, *this, this->fill(), __n).failed();
209               if (__f)  
210                 this->setstate(ios_base::badbit);
211             }
212           catch(exception& __fail)
213             {
214               // 27.6.1.2.1 Common requirements.
215               // Turn this on without causing an ios::failure to be thrown.
216               this->setstate(ios_base::badbit);
217               if ((this->exceptions() & ios_base::badbit) != 0)
218                 __throw_exception_again;
219             }
220         }
221       return *this;
222     }
223
224   template<typename _CharT, typename _Traits>
225     basic_ostream<_CharT, _Traits>& 
226     basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
227     {
228       sentry __cerb(*this);
229       if (__cerb) 
230         {
231           try 
232             {
233               if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
234                 this->setstate(ios_base::badbit);
235             }
236           catch(exception& __fail)
237             {
238               // 27.6.1.2.1 Common requirements.
239               // Turn this on without causing an ios::failure to be thrown.
240               this->setstate(ios_base::badbit);
241               if ((this->exceptions() & ios_base::badbit) != 0)
242                 __throw_exception_again;
243             }
244         }
245       return *this;
246     }
247 #endif
248   
249   template<typename _CharT, typename _Traits>
250     basic_ostream<_CharT, _Traits>& 
251     basic_ostream<_CharT, _Traits>::operator<<(double __n)
252     {
253       sentry __cerb(*this);
254       if (__cerb) 
255         {
256           try 
257             {
258               if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
259                 this->setstate(ios_base::badbit);
260             }
261           catch(exception& __fail)
262             {
263               // 27.6.1.2.1 Common requirements.
264               // Turn this on without causing an ios::failure to be thrown.
265               this->setstate(ios_base::badbit);
266               if ((this->exceptions() & ios_base::badbit) != 0)
267                 __throw_exception_again;
268             }
269         }
270       return *this;
271     }
272   
273   template<typename _CharT, typename _Traits>
274     basic_ostream<_CharT, _Traits>& 
275     basic_ostream<_CharT, _Traits>::operator<<(long double __n)
276     {
277       sentry __cerb(*this);
278       if (__cerb) 
279         {
280           try 
281             {
282               if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
283                 this->setstate(ios_base::badbit);
284             }
285           catch(exception& __fail)
286             {
287               // 27.6.1.2.1 Common requirements.
288               // Turn this on without causing an ios::failure to be thrown.
289               this->setstate(ios_base::badbit);
290               if ((this->exceptions() & ios_base::badbit) != 0)
291                 __throw_exception_again;
292             }
293         }
294       return *this;
295     }
296
297   template<typename _CharT, typename _Traits>
298     basic_ostream<_CharT, _Traits>& 
299     basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
300     {
301       sentry __cerb(*this);
302       if (__cerb) 
303         {
304           try 
305             {
306               if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
307                 this->setstate(ios_base::badbit);
308             }
309           catch(exception& __fail)
310             {
311               // 27.6.1.2.1 Common requirements.
312               // Turn this on without causing an ios::failure to be thrown.
313               this->setstate(ios_base::badbit);
314               if ((this->exceptions() & ios_base::badbit) != 0)
315                 __throw_exception_again;
316             }
317         }
318       return *this;
319     }
320
321   template<typename _CharT, typename _Traits>
322     basic_ostream<_CharT, _Traits>& 
323     basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin)
324     {
325       streamsize __xtrct = 0;
326       __streambuf_type* __sbout = this->rdbuf();
327       sentry __cerb(*this);
328       if (__sbin && __cerb)
329         __xtrct = __copy_streambufs(*this, __sbin, __sbout);
330       if (!__sbin || !__xtrct)
331         this->setstate(ios_base::failbit);
332       return *this;
333     }
334
335   template<typename _CharT, typename _Traits>
336     basic_ostream<_CharT, _Traits>&
337     basic_ostream<_CharT, _Traits>::put(char_type __c)
338     { 
339       sentry __cerb(*this);
340       if (__cerb) 
341         {
342           int_type __put = rdbuf()->sputc(__c); 
343           if (__put != traits_type::to_int_type(__c))
344             this->setstate(ios_base::badbit);
345         }
346       return *this;
347     }
348
349   template<typename _CharT, typename _Traits>
350     basic_ostream<_CharT, _Traits>&
351     basic_ostream<_CharT, _Traits>::write(const _CharT* __s, streamsize __n)
352     {
353       sentry __cerb(*this);
354       if (__cerb)
355         {
356           streamsize __put = this->rdbuf()->sputn(__s, __n);
357           if ( __put != __n)
358             this->setstate(ios_base::badbit);
359         }
360       return *this;
361     }
362
363   template<typename _CharT, typename _Traits>
364     basic_ostream<_CharT, _Traits>&
365     basic_ostream<_CharT, _Traits>::flush()
366     {
367       sentry __cerb(*this);
368       if (__cerb) 
369         {
370           if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
371             this->setstate(ios_base::badbit);
372         }
373       return *this;
374     }
375   
376   template<typename _CharT, typename _Traits>
377     typename basic_ostream<_CharT, _Traits>::pos_type
378     basic_ostream<_CharT, _Traits>::tellp()
379     {
380       pos_type __ret = pos_type(-1);
381       bool __testok = this->fail() != true;
382       
383       if (__testok)
384         __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
385       return __ret;
386     }
387
388
389   template<typename _CharT, typename _Traits>
390     basic_ostream<_CharT, _Traits>&
391     basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
392     {
393       bool __testok = this->fail() != true;
394       
395       if (__testok)
396 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
397 // 136.  seekp, seekg setting wrong streams?
398         this->rdbuf()->pubseekpos(__pos, ios_base::out);
399 #endif
400       return *this;
401     }
402
403   template<typename _CharT, typename _Traits>
404     basic_ostream<_CharT, _Traits>&
405     basic_ostream<_CharT, _Traits>::
406     seekp(off_type __off, ios_base::seekdir __d)
407     {
408       bool __testok = this->fail() != true;
409       
410       if (__testok)
411 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
412 // 136.  seekp, seekg setting wrong streams?
413         this->rdbuf()->pubseekoff(__off, __d, ios_base::out);
414 #endif
415       return *this;
416     }
417
418   // 27.6.2.5.4 Character inserters
419
420   // Construct correctly padded string, as per 22.2.2.2.2
421   // Similar in theory to __pad_numeric, from num_put, but it doesn't
422   // use _S_fill: perhaps it should.
423   // Assumes 
424   // __newlen > __oldlen
425   // __news is allocated for __newlen size
426   template<typename _CharT, typename _Traits>
427     void
428     __pad_char(basic_ios<_CharT, _Traits>& __ios, 
429                _CharT* __news, const _CharT* __olds,
430                const streamsize __newlen, const streamsize __oldlen)
431     {
432       typedef _CharT    char_type;
433       typedef _Traits   traits_type;
434       typedef typename traits_type::int_type int_type;
435       
436       int_type __plen = static_cast<size_t>(__newlen - __oldlen); 
437       char_type* __pads = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __plen));
438       traits_type::assign(__pads, __plen, __ios.fill()); 
439
440       char_type* __beg;
441       char_type* __end;
442       size_t __mod = 0;
443       size_t __beglen; //either __plen or __oldlen
444       ios_base::fmtflags __fmt = __ios.flags() & ios_base::adjustfield;
445
446       if (__fmt == ios_base::left)
447         {
448           // Padding last.
449           __beg = const_cast<char_type*>(__olds);
450           __beglen = __oldlen;
451           __end = __pads;
452         }
453       else if (__fmt == ios_base::internal)
454         {
455           // Pad after the sign, if there is one.
456           // Pad after 0[xX], if there is one.
457           // Who came up with these rules, anyway? Jeeze.
458           typedef _Format_cache<_CharT> __cache_type;
459           __cache_type const* __fmt = __cache_type::_S_get(__ios);
460           const char_type* __minus = traits_type::find(__olds, __oldlen, 
461                                                        __fmt->_S_minus);
462           const char_type* __plus = traits_type::find(__olds, __oldlen, 
463                                                       __fmt->_S_plus);
464           bool __testsign = __minus || __plus;
465           bool __testhex = __olds[0] == '0' 
466                            && (__olds[1] == 'x' || __olds[1] == 'X');
467
468           if (__testhex)
469             {
470               __news[0] = __olds[0]; 
471               __news[1] = __olds[1];
472               __mod += 2;
473               __beg = const_cast<char_type*>(__olds + __mod);
474               __beglen = __oldlen - __mod;
475               __end = __pads;
476             }
477           else if (__testsign)
478             {
479               __mod += __plen;
480               const char_type* __sign = __minus ? __minus + 1: __plus + 1;
481               __beg = const_cast<char_type*>(__olds);
482               __beglen = __sign - __olds;
483               __end = const_cast<char_type*>(__sign + __plen);
484               traits_type::copy(__news + __beglen, __pads, __plen);
485             }
486           else
487             {
488               // Padding first.
489               __beg = __pads;
490               __beglen = __plen;
491               __end = const_cast<char_type*>(__olds);
492             }
493         }
494       else
495         {
496           // Padding first.
497           __beg = __pads;
498           __beglen = __plen;
499           __end = const_cast<char_type*>(__olds);
500         }
501
502       traits_type::copy(__news, __beg, __beglen);
503       traits_type::copy(__news + __beglen, __end, __newlen - __beglen - __mod);
504     }
505
506   template<typename _CharT, typename _Traits>
507     basic_ostream<_CharT, _Traits>&
508     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
509     {
510       typedef basic_ostream<_CharT, _Traits> __ostream_type;
511       typename __ostream_type::sentry __cerb(__out);
512       if (__cerb)
513         {
514           try 
515             {
516               streamsize __w = __out.width();
517               _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
518               __pads[0] = __c;
519               streamsize __len = 1;
520               if (__w > __len)
521                 {
522                   __pad_char(__out, __pads, &__c, __w, __len);
523                   __len = __w;
524                 }
525               __out.write(__pads, __len);
526               __out.width(0);
527             }
528           catch(exception& __fail)
529             {
530               // 27.6.1.2.1 Common requirements.
531               // Turn this on without causing an ios::failure to be thrown.
532               __out.setstate(ios_base::badbit);
533               if ((__out.exceptions() & ios_base::badbit) != 0)
534                 __throw_exception_again;
535             }
536         }
537       return __out;
538     }
539   
540   // Specialization
541   template <class _Traits> 
542     basic_ostream<char, _Traits>&
543     operator<<(basic_ostream<char, _Traits>& __out, char __c)
544     {
545       typedef basic_ostream<char, _Traits> __ostream_type;
546       typename __ostream_type::sentry __cerb(__out);
547       if (__cerb)
548         {
549           try 
550             {
551               streamsize __w = __out.width();
552               char* __pads = static_cast<char*>(__builtin_alloca(__w + 1));
553               __pads[0] = __c;
554               streamsize __len = 1;
555               if (__w > __len)
556                 {
557                   __pad_char(__out, __pads, &__c, __w, __len);
558                   __len = __w;
559                 }
560               __out.write(__pads, __len);
561               __out.width(0);
562             }
563           catch(exception& __fail)
564             {
565               // 27.6.1.2.1 Common requirements.
566               // Turn this on without causing an ios::failure to be thrown.
567               __out.setstate(ios_base::badbit);
568               if ((__out.exceptions() & ios_base::badbit) != 0)
569                 __throw_exception_again;
570             }
571         }
572       return __out;
573      }
574
575   template<typename _CharT, typename _Traits>
576     basic_ostream<_CharT, _Traits>&
577     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
578     {
579       typedef basic_ostream<_CharT, _Traits> __ostream_type;
580       typename __ostream_type::sentry __cerb(__out);
581       if (__cerb)
582         {
583           try 
584             {
585               streamsize __w = __out.width();
586               _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
587               streamsize __len = static_cast<streamsize>(_Traits::length(__s));
588               if (__w > __len)
589                 {
590                   __pad_char(__out, __pads, __s, __w, __len);
591                   __s = __pads;
592                   __len = __w;
593                 }
594               __out.write(__s, __len);
595               __out.width(0);
596             }
597           catch(exception& __fail)
598             {
599               // 27.6.1.2.1 Common requirements.
600               // Turn this on without causing an ios::failure to be thrown.
601               __out.setstate(ios_base::badbit);
602               if ((__out.exceptions() & ios_base::badbit) != 0)
603                 __throw_exception_again;
604             }
605         }
606       return __out;
607     }
608
609   template<typename _CharT, typename _Traits>
610     basic_ostream<_CharT, _Traits>&
611     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
612     {
613       typedef basic_ostream<_CharT, _Traits> __ostream_type;
614 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
615 // 167.  Improper use of traits_type::length()
616       typedef char_traits<char>              __ctraits_type;
617 #endif
618       typename __ostream_type::sentry __cerb(__out);
619       if (__cerb)
620         {
621           size_t __clen = __ctraits_type::length(__s);
622           _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__clen + 1)));
623           for (size_t  __i = 0; __i <= __clen; ++__i)
624             __ws[__i] = __out.widen(__s[__i]);
625           _CharT* __str = __ws;
626           
627           try 
628             {
629               streamsize __len = static_cast<streamsize>(__clen);
630               streamsize __w = __out.width();
631               _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
632               
633               if (__w > __len)
634                 {
635                   __pad_char(__out, __pads, __ws, __w, __len);
636                   __str = __pads;
637                   __len = __w;
638                 }
639               __out.write(__str, __len);
640               __out.width(0);
641             }
642           catch(exception& __fail)
643             {
644               // 27.6.1.2.1 Common requirements.
645               // Turn this on without causing an ios::failure to be thrown.
646               __out.setstate(ios_base::badbit);
647               if ((__out.exceptions() & ios_base::badbit) != 0)
648                 __throw_exception_again;
649             }
650         }
651       return __out;
652     }
653
654   // Partial specializationss
655   template<class _Traits>
656     basic_ostream<char, _Traits>&
657     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
658     {
659       typedef basic_ostream<char, _Traits> __ostream_type;
660       typename __ostream_type::sentry __cerb(__out);
661       if (__cerb)
662         {
663           try 
664             {
665               streamsize __w = __out.width();
666               char* __pads = static_cast<char*>(__builtin_alloca(__w));
667               streamsize __len = static_cast<streamsize>(_Traits::length(__s));
668               if (__w > __len)
669                 {
670                   __pad_char(__out, __pads, __s, __w, __len);
671                   __s = __pads;
672                   __len = __w;
673                 }
674               __out.write(__s, __len);
675               __out.width(0);
676             }
677           catch(exception& __fail)
678             {
679               // 27.6.1.2.1 Common requirements.
680               // Turn this on without causing an ios::failure to be thrown.
681               __out.setstate(ios_base::badbit);
682               if ((__out.exceptions() & ios_base::badbit) != 0)
683                 __throw_exception_again;
684             }
685         }
686       return __out;
687     }
688
689   // 21.3.7.9 basic_string::operator<<
690   template<typename _CharT, typename _Traits, typename _Alloc>
691     basic_ostream<_CharT, _Traits>&
692     operator<<(basic_ostream<_CharT, _Traits>& __out,
693                const basic_string<_CharT, _Traits, _Alloc>& __str)
694     { 
695       typedef basic_ostream<_CharT, _Traits> __ostream_type;
696       typename __ostream_type::sentry __cerb(__out);
697       if (__cerb)
698         {
699           const _CharT* __s = __str.data();
700           streamsize __w = __out.width();
701           _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
702           streamsize __len = static_cast<streamsize>(__str.size());
703 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
704           // 25. String operator<< uses width() value wrong
705 #endif
706           if (__w > __len)
707             {
708               __pad_char(__out, __pads, __s, __w, __len);
709               __s = __pads;
710               __len = __w;
711             }
712           streamsize __res = __out.rdbuf()->sputn(__s, __len);
713           __out.width(0);
714           if (__res != __len)
715             __out.setstate(ios_base::failbit);
716         }
717       return __out;
718     }
719 } // namespace std
720  
721 // Local Variables:
722 // mode:C++
723 // End:
724