home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / OSTREAM.CC < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  37.3 KB  |  1,519 lines

  1. #ifndef __OSTREAM_CC
  2. #define __OSTREAM_CC
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. /***************************************************************************
  5.  *
  6.  * ostream.cc - Definitions for the Standard Library ostream classes
  7.  *
  8.  ***************************************************************************
  9.  *
  10.  * (c) Copyright 1994, 1998 Rogue Wave Software, Inc.
  11.  * ALL RIGHTS RESERVED
  12.  *
  13.  * The software and information contained herein are proprietary to, and
  14.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  15.  * intends to preserve as trade secrets such software and information.
  16.  * This software is furnished pursuant to a written license agreement and
  17.  * may be used, copied, transmitted, and stored only in accordance with
  18.  * the terms of such license and with the inclusion of the above copyright
  19.  * notice.  This software and information or any other copies thereof may
  20.  * not be provided or otherwise made available to any other person.
  21.  *
  22.  * Notwithstanding any other lease or license that may pertain to, or
  23.  * accompany the delivery of, this computer software and information, the
  24.  * rights of the Government regarding its use, reproduction and disclosure
  25.  * are as set forth in Section 52.227-19 of the FARS Computer
  26.  * Software-Restricted Rights clause.
  27.  * 
  28.  * Use, duplication, or disclosure by the Government is subject to
  29.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  30.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  31.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  32.  * P.O. Box 2328, Corvallis, Oregon 97339.
  33.  *
  34.  * This computer software and information is distributed with "restricted
  35.  * rights."  Use, duplication or disclosure is subject to restrictions as
  36.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  37.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  38.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  39.  * then the "Alternate III" clause applies.
  40.  *
  41.  **************************************************************************/
  42.  
  43. #include <streambuf>
  44.  
  45. #ifndef _RWSTD_NO_NAMESPACE
  46. namespace std {
  47. #endif
  48.  
  49.   /*
  50.    * basic_ostream(basic_streambuf *)
  51.    */
  52.  
  53.   template<class charT, class traits> 
  54.   basic_ostream<charT, traits>::basic_ostream(basic_streambuf<charT, traits> *sb)
  55.   {
  56.     if ( sb )
  57.     {
  58.       if ( sb->which_open_mode() & ios_base::out ) 
  59.         this->init(sb);
  60.       else
  61.         this->init(0);
  62.     } 
  63.     else
  64.       this->init(0);
  65.   }
  66.  
  67.   /*
  68.    * basic_ostream( )
  69.    */
  70.  
  71.   template<class charT, class traits>
  72.   basic_ostream<charT, traits>::basic_ostream( )
  73.   {
  74.   }
  75.  
  76.   /*
  77.    * ~basic_ostream()
  78.    */
  79.  
  80.   template<class charT, class traits>
  81.   basic_ostream<charT, traits>::~basic_ostream()
  82.   {
  83.  
  84.   }
  85.  
  86.   /*
  87.    * basic_ostream& flush()  
  88.    */
  89.  
  90.   template<class charT, class traits>
  91.   basic_ostream<charT, traits>&
  92.   basic_ostream<charT, traits>::flush()
  93.   {
  94.   
  95.     if(this->rdbuf())
  96.     {
  97. #ifdef _RWSTD_MULTI_THREAD
  98.       _RWSTDGuard guard(this->rdbuf()->buffer_mutex_);
  99. #endif
  100.       if(this->rdbuf()->pubsync() == -1)
  101.         this->setstate(ios_base::badbit);
  102.     }
  103.  
  104.     return *this;
  105.   }
  106.   
  107.   /*
  108.    * basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&))
  109.    *
  110.    * these are the ostream manipulators (endl, ends, flush)
  111.    */
  112.   template<class charT, class traits>
  113.   basic_ostream<charT, traits>&
  114.   basic_ostream<charT, traits>::
  115.   operator<<(basic_ostream<charT, traits>& (*pf)(basic_ostream<charT, traits>& ))
  116.   {
  117.     return (*pf)(*this);
  118.   }
  119.  
  120.   /*
  121.    * basic_ostream& operator<<(ios_base& (*pf)(ios_base&))
  122.    *
  123.    * outputs the ios_base manipulators
  124.    */
  125.  
  126.   template<class charT, class traits>
  127.   basic_ostream<charT, traits>&
  128.   basic_ostream<charT, traits>::
  129.   operator<<(ios_base& (*pf)(ios_base&))
  130.   {
  131.     (*pf)(*this);
  132.     return *this;
  133.   }
  134.  
  135.   /*
  136.    * basic_ostream& operator<<(basic_ios& (*pf)(basic_ios& ))
  137.    *
  138.    * these are the ios manipulators (dec, hex, ...)
  139.    */
  140.   template<class charT, class traits>
  141.   basic_ostream<charT, traits>&
  142.   basic_ostream<charT, traits>::
  143.   operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&))
  144.   {
  145.     (*pf)(*this);
  146.     return *this;
  147.   }
  148.  
  149.   /*
  150.    * basic_ostream& operator<< (basic_ostream<charT, traits>& os, const charT *)
  151.    *
  152.    */
  153.  
  154.   template<class charT, class traits>
  155.   basic_ostream<charT, traits>&
  156.   _RWSTDExportTemplate operator<< ( basic_ostream<charT, traits>& os, const charT *s)
  157.   {
  158.     ios_base::iostate err = 0;
  159.  
  160. #ifndef _RWSTD_NO_EXCEPTIONS
  161.     try {
  162. #endif
  163.   
  164.       if ( s )
  165.       {   
  166.         _TYPENAME basic_ostream<charT, traits>::sentry opfx(os);
  167.         if (opfx)
  168.         {
  169.           int   dlen = traits::length(s);
  170.           int   pad = os.width() - dlen;
  171.  
  172.           // place right padding
  173.           if( !(os.flags() & ios_base::adjustfield) ||  (os.flags() & ios_base::right) )
  174.           {
  175.             while(--pad >= 0)
  176.             {
  177.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  178.                 err = ios_base::badbit;
  179.                 break;
  180.               }
  181.             }
  182.           }
  183.          
  184.           // output internal padding
  185.           if(os.good() && (os.flags() & ios_base::internal))
  186.           {
  187.             while(--pad >= 0)
  188.             {
  189.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  190.               {
  191.                 err = ios_base::badbit;
  192.                 break;
  193.               }
  194.             }
  195.           }
  196.  
  197.           if(os.good() && dlen) {
  198.             if(os.rdbuf() && (os.rdbuf()->sputn(s, dlen) != dlen))
  199.               err = ios_base::badbit;
  200.           }
  201.  
  202.           // output left padding. 
  203.           if(os.good() && (os.flags() & ios_base::left))
  204.           {
  205.             while(--pad >= 0)
  206.             {
  207.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  208.               {
  209.                 err = ios_base::badbit;
  210.                 break;
  211.               }
  212.             }
  213.           }
  214.  
  215.           os.width(0);
  216.         }
  217.       }
  218.       else
  219.         err = ios_base::badbit;
  220.  
  221. #ifndef _RWSTD_NO_EXCEPTIONS
  222.     }
  223. #endif
  224.  
  225. #ifndef _RWSTD_NO_EXCEPTIONS
  226.     catch(...)
  227.     {
  228.       bool flag = false;
  229.       try {
  230.         os.setstate(ios_base::badbit);
  231.       }
  232.       catch( ios_base::failure ) { flag= true; }
  233.       if ( flag ) throw;
  234.     }
  235. #endif
  236.  
  237.     if ( err ) os.setstate(err);  
  238.  
  239.     return os;
  240.   }
  241.  
  242. #ifdef __BORLANDC__
  243. #pragma option -w-aus
  244. #endif
  245.   
  246.   /*
  247.    * basic_ostream& operator<< (basic_ostream<charT, traits>& os, const char *)
  248.    *
  249.    */
  250.  
  251. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  252.  
  253.   template<class charT, class traits>
  254.   basic_ostream<charT, traits>&
  255.   _RWSTDExportTemplate operator<< ( basic_ostream<charT, traits>& os, const char *s)
  256.   {
  257.     ios_base::iostate err = 0;
  258.  
  259. #ifndef _RWSTD_NO_EXCEPTIONS
  260.     try {
  261. #endif
  262.   
  263.       if ( s ) {   
  264.         _TYPENAME basic_ostream<charT, traits>::sentry opfx(os);
  265.         if (opfx)
  266.         {
  267.           int   dlen = char_traits<char>::length(s);
  268.           int   pad = os.width() - dlen;
  269.  
  270. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  271.           const ctype<charT>& ct = use_facet< ctype<charT> >(os.getloc());
  272. #else
  273.           const ctype<charT>& ct = use_facet(os.getloc(),(ctype<charT>*)0);
  274. #endif //  _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  275.  
  276.           // place right padding
  277.           if( !(os.flags() & ios_base::adjustfield) ||  (os.flags() & ios_base::right) )
  278.           {
  279.             while(--pad >= 0)
  280.             {
  281.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  282.               {
  283.                 err = ios_base::badbit;
  284.                 break;
  285.               }
  286.             }
  287.           }
  288.          
  289.           // output internal padding
  290.           if(os.good() && (os.flags() & ios_base::internal))
  291.           {
  292.             while(--pad >= 0) {
  293.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  294.               {
  295.                 err = ios_base::badbit;
  296.                 break;
  297.               }
  298.             }
  299.           }
  300.  
  301.           if(os.good() && dlen)
  302.           {
  303.             while ( dlen )
  304.             {
  305.               if( traits::eq_int_type(
  306.                   os.rdbuf()->sputc(ct.widen(*s)),
  307.                   traits::eof())) 
  308.               { 
  309.                 err = ios_base::badbit;    
  310.               }
  311.               s++;
  312.               dlen --;
  313.             }
  314.           }
  315.  
  316.           // output left padding. 
  317.           if(os.good() && (os.flags() & ios_base::left))
  318.           {
  319.             while(--pad >= 0) {
  320.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  321.               {
  322.                 err = ios_base::badbit;
  323.                 break;
  324.               }
  325.             }
  326.           }
  327.  
  328.           os.width(0);
  329.         }
  330.       }
  331.       else
  332.         err = ios_base::badbit;
  333.  
  334. #ifndef _RWSTD_NO_EXCEPTIONS
  335.     }
  336. #endif
  337.  
  338. #ifndef _RWSTD_NO_EXCEPTIONS
  339.     catch(...)
  340.     {
  341.       bool flag = false;
  342.       try {
  343.         os.setstate(ios_base::badbit);
  344.       }
  345.       catch( ios_base::failure ) { flag= true; }
  346.       if ( flag ) throw;
  347.     }
  348. #endif // _RWSTD_NO_EXCEPTIONS
  349.  
  350.     if ( err ) os.setstate(err);  
  351.  
  352.     return os;
  353.   }
  354. #endif // _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  355.  
  356.   /*
  357.    * basic_ostream& operator<< (basic_ostream<char, traits>& os, const char *)
  358.    *
  359.    */
  360.  
  361. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  362.  
  363. #ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
  364.   template<class traits>
  365.   basic_ostream<char, traits>&
  366.   _RWSTDExportTemplate operator<< ( basic_ostream<char, traits>& os, const char *s)
  367.   {
  368.     ios_base::iostate err = 0;
  369.  
  370. #ifndef _RWSTD_NO_EXCEPTIONS
  371.     try {
  372. #endif
  373.       if ( s )
  374.       {   
  375.         _TYPENAME basic_ostream<char, traits>::sentry opfx(os);
  376.         if (opfx)
  377.         {
  378.           int   dlen = traits::length(s);
  379.           int   pad = os.width() - dlen;
  380.  
  381.           // place right padding
  382.           if( !(os.flags() & ios_base::adjustfield) ||  (os.flags() & ios_base::right) )
  383.           {
  384.             while(--pad >= 0)
  385.             {
  386.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  387.               {
  388.                 err = ios_base::badbit;
  389.                 break;
  390.               }
  391.             }
  392.           }
  393.          
  394.           // output internal padding
  395.           if(os.good() && (os.flags() & ios_base::internal))
  396.           {
  397.             while(--pad >= 0) {
  398.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  399.               {
  400.                 err = ios_base::badbit;
  401.                 break;
  402.               }
  403.             }
  404.           }
  405.  
  406.           if(os.good() && dlen) {
  407.             if(os.rdbuf() && (os.rdbuf()->sputn(s, dlen) != dlen))
  408.               err = ios_base::badbit;
  409.           }
  410.  
  411.           // output left padding. 
  412.           if(os.good() && (os.flags() & ios_base::left))
  413.           {
  414.             while(--pad >= 0) {
  415.               if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  416.               {
  417.                 err = ios_base::badbit;
  418.                 break;
  419.               }
  420.             }
  421.           }
  422.  
  423.           os.width(0);
  424.         }
  425.       }
  426.       else
  427.         err = ios_base::badbit;
  428.  
  429. #ifndef _RWSTD_NO_EXCEPTIONS
  430.     }
  431. #endif
  432.  
  433. #ifndef _RWSTD_NO_EXCEPTIONS
  434.     catch(...)
  435.     {
  436.       bool flag = false;
  437.       try {
  438.         os.setstate(ios_base::badbit);
  439.       }
  440.       catch( ios_base::failure ) { flag= true; }
  441.       if ( flag ) throw;
  442.     }
  443. #endif
  444.  
  445.     if ( err ) os.setstate(err);  
  446.  
  447.     return os;
  448.   }
  449. #endif // _RWSTD_NO_FUNC_PARTIAL_SPEC
  450. #endif // _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  451.  
  452.   /*
  453.    * basic_ostream& operator<<( basic_ostream<charT, traits>&, charT )
  454.    */
  455.  
  456.   template<class charT, class traits>
  457.   basic_ostream<charT, traits>&
  458.   _RWSTDExportTemplate operator<< (basic_ostream<charT, traits>& os, charT c)
  459.   {
  460.     ios_base::iostate err = 0;
  461.  
  462. #ifndef _RWSTD_NO_EXCEPTIONS
  463.     try {
  464. #endif
  465.  
  466.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(os); 
  467.  
  468.       if(opfx) 
  469.       {
  470.         int   pad = os.width() - 1;
  471.  
  472.         // place right padding
  473.         if( !(os.flags() & ios_base::adjustfield) ||  (os.flags() & ios_base::right) )
  474.         {
  475.           while(--pad >= 0)
  476.           {
  477.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  478.             {
  479.               err = ios_base::badbit;
  480.               break;
  481.             }
  482.           }
  483.         }
  484.          
  485.         // output internal padding
  486.         if(os.good() && (os.flags() & ios_base::internal))
  487.         {
  488.           while(--pad >= 0)
  489.           {
  490.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  491.             {
  492.               err = ios_base::badbit;
  493.               break;
  494.             }
  495.           }
  496.         }
  497.  
  498.         if(os.good())
  499.         {
  500.           if( traits::eq_int_type(os.rdbuf()->sputc(c),traits::eof())) 
  501.             err = ios_base::badbit;    
  502.         }
  503.  
  504.         // output left padding. 
  505.         if(os.good() && (os.flags() & ios_base::left))
  506.         {
  507.           while(--pad >= 0)
  508.           {
  509.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  510.             {
  511.               err = ios_base::badbit;
  512.               break;
  513.             }
  514.           }
  515.         }
  516.  
  517.         os.width(0);
  518.      
  519.       }
  520.  
  521. #ifndef _RWSTD_NO_EXCEPTIONS
  522.     }
  523. #endif
  524.  
  525. #ifndef _RWSTD_NO_EXCEPTIONS
  526.     catch(...)
  527.     {
  528.       bool flag = false;
  529.       try {
  530.         os.setstate(ios_base::failbit);
  531.       }
  532.       catch( ios_base::failure ) { flag= true; }
  533.       if ( flag ) throw;
  534.     }
  535. #endif
  536.     if ( err ) os.setstate(err); 
  537.     return os;
  538.   }
  539.  
  540.   /*
  541.    * basic_ostream& operator<<( basic_ostream<charT, traits>&, char )
  542.    */
  543.  
  544. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  545.  
  546.   template<class charT, class traits>
  547.   basic_ostream<charT, traits>&
  548.   _RWSTDExportTemplate operator<< (basic_ostream<charT, traits>& os, char c)
  549.   {
  550.     ios_base::iostate err = 0;
  551.  
  552. #ifndef _RWSTD_NO_EXCEPTIONS
  553.     try {
  554. #endif
  555.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(os); 
  556.  
  557.       if(opfx) 
  558.       {
  559. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  560.         const ctype<charT>& ct = use_facet< ctype<charT> >(os.getloc());
  561. #else
  562.         const ctype<charT>& ct = use_facet(os.getloc(),(ctype<charT>*)0);
  563. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  564.  
  565.         int   pad = os.width() - 1;
  566.  
  567.         // place right padding
  568.         if( !(os.flags() & ios_base::adjustfield) ||  (os.flags() & ios_base::right) )
  569.         {
  570.           while(--pad >= 0)
  571.           {
  572.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  573.             {
  574.               err = ios_base::badbit;
  575.               break;
  576.             }
  577.           }
  578.         }
  579.          
  580.         // output internal padding
  581.         if(os.good() && (os.flags() & ios_base::internal))
  582.         {
  583.           while(--pad >= 0)
  584.           {
  585.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  586.             {
  587.               err = ios_base::badbit;
  588.               break;
  589.             }
  590.           }
  591.         }
  592.  
  593.         if(os.good())
  594.         {
  595.           if( traits::eq_int_type(os.rdbuf()->sputc(ct.widen(c)),traits::eof())) 
  596.             err = ios_base::badbit;      
  597.         }
  598.  
  599.         // output left padding. 
  600.         if(os.good() && (os.flags() & ios_base::left))
  601.         {
  602.           while(--pad >= 0)
  603.           {
  604.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  605.             {
  606.               err = ios_base::badbit;
  607.               break;
  608.             }
  609.           }
  610.         }
  611.         os.width(0);    
  612.       }
  613.  
  614. #ifndef _RWSTD_NO_EXCEPTIONS
  615.     }
  616. #endif
  617.  
  618. #ifndef _RWSTD_NO_EXCEPTIONS
  619.     catch(...)
  620.     {
  621.       bool flag = false;
  622.       try {
  623.         os.setstate(ios_base::failbit);
  624.       }
  625.       catch( ios_base::failure ) { flag= true; }
  626.       if ( flag ) throw;
  627.     }
  628. #endif
  629.  
  630.     if ( err ) os.setstate(err); 
  631.  
  632.     return os;
  633.   }
  634. #endif // _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION 
  635.  
  636.   /*
  637.    * basic_ostream& operator<<( basic_ostream<char, traits>&, char )
  638.    *
  639.    */
  640.  
  641. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  642. #ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
  643.  
  644.   template<class traits>
  645.   basic_ostream<char, traits>&
  646.   _RWSTDExportTemplate operator<< (basic_ostream<char, traits>& os, char c)
  647.   {
  648.     ios_base::iostate err = 0;
  649.  
  650. #ifndef _RWSTD_NO_EXCEPTIONS
  651.     try {
  652. #endif
  653.  
  654.       _TYPENAME basic_ostream<char, traits>::sentry opfx(os); 
  655.  
  656.       if(opfx) 
  657.       {
  658.         int   pad = os.width() - 1;
  659.  
  660.         // place right padding
  661.         if( !(os.flags() & ios_base::adjustfield) ||  (os.flags() & ios_base::right) )
  662.         {
  663.           while(--pad >= 0)
  664.           {
  665.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  666.             {
  667.               err = ios_base::badbit;
  668.               break;
  669.             }
  670.           }
  671.         }
  672.          
  673.         // output internal padding
  674.         if(os.good() && (os.flags() & ios_base::internal))
  675.         {
  676.           while(--pad >= 0)
  677.           {
  678.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  679.             {
  680.               err = ios_base::badbit;
  681.               break;
  682.             }
  683.           }
  684.         }
  685.  
  686.         if(os.good()) {
  687.           if( traits::eq_int_type(os.rdbuf()->sputc(c),traits::eof())) 
  688.             err = ios_base::badbit;       
  689.         }
  690.  
  691.         // output left padding. 
  692.         if(os.good() && (os.flags() & ios_base::left))
  693.         {
  694.           while(--pad >= 0)
  695.           {
  696.             if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof()))
  697.             {
  698.               err = ios_base::badbit;
  699.               break;
  700.             }
  701.           }
  702.         }
  703.         os.width(0);    
  704.       }
  705.  
  706. #ifndef _RWSTD_NO_EXCEPTIONS
  707.     }
  708. #endif
  709.  
  710. #ifndef _RWSTD_NO_EXCEPTIONS
  711.     catch(...)
  712.     {
  713.       bool flag = false;
  714.       try {
  715.         os.setstate(ios_base::failbit);
  716.       }
  717.       catch( ios_base::failure ) { flag= true; }
  718.       if ( flag ) throw;
  719.     }
  720. #endif
  721.  
  722.     if ( err ) os.setstate(err); 
  723.  
  724.     return os;
  725.   }
  726. #endif // _RWSTD_NO_FUNC_PARTIAL_SPEC 
  727. #endif // _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION 
  728.  
  729. #ifndef _RWSTD_NO_SIGNED_CHAR_IN_STREAMS
  730.  
  731.   /*
  732.    * ostream& operator<<(basic_ostream<char,traits>&,unsigned char )
  733.    */
  734.  
  735.   template <class traits>
  736.   basic_ostream<char, traits>&
  737.   _RWSTDExportTemplate operator<<(basic_ostream<char, traits>& os,unsigned char uc)
  738.   {
  739.     return (os << (char)uc);
  740.   }
  741.  
  742.   /*
  743.    * ostream& operator<<(basic_ostream<char, traits>&,signed char )
  744.    */
  745.  
  746.   template <class traits>
  747.   basic_ostream<char, traits>&
  748.   _RWSTDExportTemplate operator<<(basic_ostream<char, traits>& os,signed char sc)
  749.   {
  750.     return (os << (char)sc);
  751.   }
  752.  
  753.   /*
  754.    * ostream& operator<<(basic_ostream<char, traits>&,const unsigned char* )
  755.    */
  756.  
  757.   template <class traits>
  758.   basic_ostream<char, traits>&
  759.   _RWSTDExportTemplate operator<<(basic_ostream<char, traits>& os,const unsigned char* uc)
  760.   {
  761.     return (os << (char *)uc);
  762.   }
  763.  
  764.   /*
  765.    * ostream& operator<<(basic_ostream<char, traits>&,const signed char* )
  766.    */
  767.  
  768.   template <class traits>
  769.   basic_ostream<char, traits>&
  770.   _RWSTDExportTemplate operator<<(basic_ostream<char, traits>& os,const signed char* sc)
  771.   {
  772.     return (os << (char *)sc);
  773.   }
  774. #endif // _RWSTD_NO_SIGNED_CHAR_IN_STREAMS
  775.   /*
  776.    * basic_ostream& operator<<(bool n)
  777.    */
  778.  
  779. #ifndef _RWSTD_NO_BOOL
  780.  
  781.   template<class charT, class traits>
  782.   basic_ostream<charT, traits>& 
  783.   basic_ostream<charT, traits>::operator<<(bool n)
  784.   {
  785.     ios_base::iostate err = 0;
  786.  
  787. #ifndef _RWSTD_NO_EXCEPTIONS
  788.     try {
  789. #endif
  790.  
  791.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  792.       if (opfx)
  793.       {
  794.         if (
  795. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  796.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  797. #else
  798.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  799. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  800.             .put(ostreambuf_iterator<charT,traits>(*this),*this,this->fill(),n).failed() )
  801.           err = ios_base::badbit;
  802.         this->width(0);
  803.       }
  804.  
  805. #ifndef _RWSTD_NO_EXCEPTIONS
  806.     }
  807. #endif
  808.  
  809. #ifndef _RWSTD_NO_EXCEPTIONS
  810.     catch(...)
  811.     {
  812.       bool flag = false;
  813.       try {
  814.         this->setstate(ios_base::badbit);
  815.       }
  816.       catch( ios_base::failure ) { flag= true; }
  817.       if ( flag ) throw;
  818.     }
  819. #endif // _RWSTD_NO_EXCEPTIONS 
  820.     if ( err ) this->setstate(err);
  821.     return *this;
  822.   }
  823.  
  824. #endif // _RWSTD_NO_BOOL
  825.  
  826.   /*
  827.    * basic_ostream& operator<<(short)
  828.    */
  829.  
  830.   template<class charT, class traits>
  831.   basic_ostream<charT, traits>&
  832.   basic_ostream<charT, traits>::operator<<(short n)
  833.   {
  834.     ios_base::iostate err = 0;
  835.  
  836. #ifndef _RWSTD_NO_EXCEPTIONS
  837.     try {
  838. #endif  
  839.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  840.       if (opfx)
  841.       {
  842.         if (
  843. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  844.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  845. #else
  846.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  847. #endif
  848.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  849.           err = ios_base::badbit;
  850.         this->width(0);
  851.       }
  852.  
  853. #ifndef _RWSTD_NO_EXCEPTIONS
  854.     }
  855. #endif
  856.  
  857. #ifndef _RWSTD_NO_EXCEPTIONS
  858.     catch(...)
  859.     {
  860.       bool flag = false;
  861.       try {
  862.         this->setstate(ios_base::badbit);
  863.       }
  864.       catch( ios_base::failure ) { flag= true; }
  865.       if ( flag ) throw;
  866.     }
  867. #endif
  868.     if ( err ) this->setstate(err);
  869.     return *this;
  870.   }
  871.  
  872.   /*
  873.    * basic_ostream& operator<<(unsigned short)
  874.    */
  875.  
  876.   template<class charT, class traits>
  877.   basic_ostream<charT, traits>&
  878.   basic_ostream<charT, traits>::operator<<(unsigned short n)
  879.   {
  880.     ios_base::iostate err = 0;
  881.  
  882. #ifndef _RWSTD_NO_EXCEPTIONS
  883.     try {
  884. #endif  
  885.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  886.       if (opfx)
  887.       {
  888.         if (
  889. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  890.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  891. #else
  892.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  893. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  894.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  895.           err = ios_base::badbit;
  896.         this->width(0);
  897.       }
  898.  
  899. #ifndef _RWSTD_NO_EXCEPTIONS
  900.     }
  901. #endif
  902.  
  903. #ifndef _RWSTD_NO_EXCEPTIONS
  904.     catch(...)
  905.     {
  906.       bool flag = false;
  907.       try {
  908.         this->setstate(ios_base::badbit);
  909.       }
  910.       catch( ios_base::failure ) { flag= true; }
  911.       if ( flag ) throw;
  912.     }
  913. #endif // _RWSTD_NO_EXCEPTIONS 
  914.     if ( err ) this->setstate(err);
  915.     return *this; 
  916.   }
  917.   /*
  918.    * basic_ostream& operator<<(int)
  919.    */
  920.  
  921.   template<class charT, class traits>
  922.   basic_ostream<charT, traits>&
  923.   basic_ostream<charT, traits>::operator<<(int n)
  924.   {
  925.     ios_base::iostate err = 0;
  926.  
  927. #ifndef _RWSTD_NO_EXCEPTIONS
  928.     try {
  929. #endif  
  930.  
  931.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  932.       if (opfx)
  933.       {
  934.         if ( 
  935. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  936.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  937. #else
  938.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  939. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  940.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  941.           err = ios_base::badbit;
  942.         this->width(0);
  943.       }
  944.  
  945. #ifndef _RWSTD_NO_EXCEPTIONS
  946.     }
  947. #endif
  948.  
  949. #ifndef _RWSTD_NO_EXCEPTIONS
  950.     catch(...)
  951.     {
  952.       bool flag = false;
  953.       try {
  954.         this->setstate(ios_base::badbit);
  955.       }
  956.       catch( ios_base::failure ) { flag= true; }
  957.       if ( flag ) throw;
  958.     }
  959. #endif
  960.     if ( err ) this->setstate(err);  
  961.     return *this; 
  962.   }
  963.   /*
  964.    * basic_ostream& operator<<(unsigned int)
  965.    */
  966.  
  967.   template<class charT, class traits>
  968.   basic_ostream<charT, traits>&
  969.   basic_ostream<charT, traits>::operator<<(unsigned int n)
  970.   {
  971.     ios_base::iostate err = 0;
  972.  
  973. #ifndef _RWSTD_NO_EXCEPTIONS
  974.     try {
  975. #endif 
  976.  
  977.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  978.       if (opfx)
  979.       {
  980.         if (
  981. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  982.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  983. #else
  984.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  985. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  986.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  987.           err = ios_base::badbit;
  988.         this->width(0);
  989.       }
  990.  
  991. #ifndef _RWSTD_NO_EXCEPTIONS
  992.     }
  993. #endif
  994.  
  995. #ifndef _RWSTD_NO_EXCEPTIONS
  996.     catch(...)
  997.     {
  998.       bool flag = false;
  999.       try {
  1000.         this->setstate(ios_base::badbit);
  1001.       }
  1002.       catch( ios_base::failure ) { flag= true; }
  1003.       if ( flag ) throw;
  1004.     }
  1005. #endif
  1006.     if ( err ) this->setstate(err);
  1007.     return *this; 
  1008.   }
  1009.  
  1010.   /*
  1011.    * basic_ostream& operator<<(long)
  1012.    */
  1013.  
  1014.   template<class charT, class traits>
  1015.   basic_ostream<charT, traits>&
  1016.   basic_ostream<charT, traits>::operator<<(long n)
  1017.   {
  1018.     ios_base::iostate err = 0;
  1019.  
  1020. #ifndef _RWSTD_NO_EXCEPTIONS
  1021.     try {
  1022. #endif
  1023.  
  1024.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1025.       if (opfx)
  1026.       {
  1027.         if (
  1028. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1029.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1030. #else
  1031.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1032. #endif
  1033.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1034.           err = ios_base::badbit;
  1035.         this->width(0);
  1036.       } 
  1037.  
  1038. #ifndef _RWSTD_NO_EXCEPTIONS
  1039.     }
  1040. #endif
  1041.  
  1042. #ifndef _RWSTD_NO_EXCEPTIONS
  1043.     catch(...)
  1044.     {
  1045.       bool flag = false;
  1046.       try {
  1047.         this->setstate(ios_base::badbit);
  1048.       }
  1049.       catch( ios_base::failure ) { flag= true; }
  1050.       if ( flag ) throw;
  1051.     }
  1052. #endif // _RWSTD_NO_EXCEPTIONS 
  1053.     if ( err ) this->setstate(err);
  1054.     return *this; 
  1055.   }
  1056.  
  1057.   /*
  1058.    * basic_ostream& operator<<(unsigned long)
  1059.    */
  1060.  
  1061.   template<class charT, class traits>
  1062.   basic_ostream<charT, traits>&
  1063.   basic_ostream<charT, traits>::operator<<(unsigned long n)
  1064.   {
  1065.     ios_base::iostate err = 0;
  1066.  
  1067. #ifndef _RWSTD_NO_EXCEPTIONS
  1068.     try {
  1069. #endif
  1070.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1071.       if (opfx)
  1072.       {
  1073.         if (
  1074. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1075.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1076. #else
  1077.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1078. #endif
  1079.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1080.           err = ios_base::badbit;
  1081.         this->width(0);
  1082.       }
  1083.  
  1084. #ifndef _RWSTD_NO_EXCEPTIONS
  1085.     }
  1086. #endif
  1087.  
  1088. #ifndef _RWSTD_NO_EXCEPTIONS
  1089.     catch(...)
  1090.     {
  1091.       bool flag = false;
  1092.       try {
  1093.         this->setstate(ios_base::badbit);
  1094.       }
  1095.       catch( ios_base::failure ) { flag= true; }
  1096.       if ( flag ) throw;
  1097.     }
  1098. #endif
  1099.     if ( err ) this->setstate(err);
  1100.     return *this; 
  1101.   }
  1102.  
  1103.   /*
  1104.    * basic_ostream& operator<<(float)
  1105.    */
  1106.  
  1107.   template<class charT, class traits>
  1108.   basic_ostream<charT, traits>&
  1109.   basic_ostream<charT, traits>::operator<<(float n)
  1110.   {
  1111.     ios_base::iostate err = 0;
  1112.  
  1113. #ifndef _RWSTD_NO_EXCEPTIONS
  1114.     try {
  1115. #endif
  1116.  
  1117.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1118.       if (opfx)
  1119.       {
  1120.         if (
  1121. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1122.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1123. #else
  1124.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1125. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1126.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),(double)n).failed() )
  1127.           err = ios_base::badbit;
  1128.         this->width(0);
  1129.       }
  1130.  
  1131. #ifndef _RWSTD_NO_EXCEPTIONS
  1132.     }
  1133. #endif
  1134.  
  1135. #ifndef _RWSTD_NO_EXCEPTIONS
  1136.     catch(...)
  1137.     {
  1138.       bool flag = false;
  1139.       try {
  1140.         this->setstate(ios_base::badbit);
  1141.       }
  1142.       catch( ios_base::failure ) { flag= true; }
  1143.       if ( flag ) throw;
  1144.     }
  1145. #endif
  1146.     if ( err ) this->setstate(err);
  1147.     return *this;
  1148.   }
  1149.  
  1150.   /*
  1151.    * basic_ostream& operator<<(double)
  1152.    */
  1153.  
  1154.   template<class charT, class traits>
  1155.   basic_ostream<charT, traits>&
  1156.   basic_ostream<charT, traits>::operator<<(double n)
  1157.   {
  1158.     ios_base::iostate err = 0;
  1159.  
  1160. #ifndef _RWSTD_NO_EXCEPTIONS
  1161.     try {
  1162. #endif
  1163.  
  1164.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1165.       if (opfx)
  1166.       {
  1167.         if (
  1168. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1169.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1170. #else
  1171.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1172. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1173.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1174.           err = ios_base::badbit;
  1175.         this->width(0);
  1176.       }
  1177.  
  1178. #ifndef _RWSTD_NO_EXCEPTIONS
  1179.     }
  1180. #endif
  1181.  
  1182. #ifndef _RWSTD_NO_EXCEPTIONS
  1183.     catch(...)
  1184.     {
  1185.       bool flag = false;
  1186.       try {
  1187.         this->setstate(ios_base::badbit);
  1188.       }
  1189.       catch( ios_base::failure ) { flag= true; }
  1190.       if ( flag ) throw;
  1191.     }
  1192. #endif
  1193.     if ( err ) this->setstate(err);
  1194.     return *this;
  1195.   }
  1196.  
  1197.   /*
  1198.    * basic_ostream& operator<<(long double)
  1199.    */
  1200.  
  1201.   template<class charT, class traits>
  1202.   basic_ostream<charT, traits>&
  1203.   basic_ostream<charT, traits>::operator<<(long double n)
  1204.   {
  1205.     ios_base::iostate err = 0;
  1206.  
  1207. #ifndef _RWSTD_NO_EXCEPTIONS
  1208.     try {
  1209. #endif
  1210.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1211.       if (opfx)
  1212.       {
  1213.         if (
  1214. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1215.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1216. #else
  1217.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1218. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1219.             .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1220.           err = ios_base::badbit;
  1221.         this->width(0);
  1222.       }
  1223.  
  1224. #ifndef _RWSTD_NO_EXCEPTIONS
  1225.     }
  1226. #endif
  1227.  
  1228. #ifndef _RWSTD_NO_EXCEPTIONS
  1229.     catch(...)
  1230.     {
  1231.       bool flag = false;
  1232.       try {
  1233.         this->setstate(ios_base::badbit);
  1234.       }
  1235.       catch( ios_base::failure ) { flag= true; }
  1236.       if ( flag ) throw;
  1237.     }
  1238. #endif
  1239.     if ( err ) this->setstate(err);
  1240.     return *this;
  1241.   }
  1242.  
  1243. /*
  1244.  * basic_ostream& operator<<(_RWSTD_LONG_LONG)
  1245.  */
  1246.  
  1247. #ifdef _RWSTD_LONG_LONG
  1248.  
  1249.   template<class charT, class traits>
  1250.   basic_ostream<charT, traits>&
  1251.   basic_ostream<charT, traits>::operator<<(_RWSTD_LONG_LONG n)
  1252.   {
  1253.     ios_base::iostate err = 0;
  1254.  
  1255. #ifndef _RWSTD_NO_EXCEPTIONS
  1256.     try {
  1257. #endif
  1258.  
  1259.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1260.       if (opfx)
  1261.       {
  1262.     if (
  1263. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1264.         use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1265. #else
  1266.         use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1267. #endif
  1268.         .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1269.       err = ios_base::badbit;
  1270.    
  1271.     this->width(0);
  1272.  
  1273.       }
  1274.  
  1275. #ifndef _RWSTD_NO_EXCEPTIONS
  1276.     }
  1277. #endif
  1278.  
  1279. #ifndef _RWSTD_NO_EXCEPTIONS
  1280.     catch(...)
  1281.     {
  1282.       bool flag = false;
  1283.       try {
  1284.     this->setstate(ios_base::badbit);
  1285.       }
  1286.       catch( ios_base::failure ) { flag= true; }
  1287.       if ( flag ) throw;
  1288.     }
  1289. #endif
  1290.  
  1291.     if ( err ) this->setstate(err);
  1292.  
  1293.     return *this;
  1294.   }
  1295.  
  1296. /*
  1297.  * basic_ostream& operator<<(unsigned _RWSTD_LONG_LONG)
  1298.  */
  1299.  
  1300.   template<class charT, class traits>
  1301.   basic_ostream<charT, traits>&
  1302.   basic_ostream<charT, traits>::operator<<(unsigned _RWSTD_LONG_LONG n)
  1303.   {
  1304.     ios_base::iostate err = 0;
  1305.  
  1306. #ifndef _RWSTD_NO_EXCEPTIONS
  1307.     try {
  1308. #endif
  1309.  
  1310.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1311.       if (opfx)
  1312.       {
  1313.     if (
  1314. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1315.         use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1316. #else
  1317.         use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1318. #endif
  1319.         .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1320.       err = ios_base::badbit;
  1321.    
  1322.     this->width(0);
  1323.  
  1324.       }
  1325.  
  1326. #ifndef _RWSTD_NO_EXCEPTIONS
  1327.     }
  1328. #endif
  1329.  
  1330. #ifndef _RWSTD_NO_EXCEPTIONS
  1331.     catch(...)
  1332.     {
  1333.       bool flag = false;
  1334.       try {
  1335.     this->setstate(ios_base::badbit);
  1336.       }
  1337.       catch( ios_base::failure ) { flag= true; }
  1338.       if ( flag ) throw;
  1339.     }
  1340. #endif
  1341.  
  1342.     if ( err ) this->setstate(err);
  1343.  
  1344.     return *this;
  1345.   }
  1346. #endif //_RWSTD_LONG_LONG
  1347.  
  1348.   /*
  1349.    * basic_ostream& operator<<(const void *)
  1350.    */
  1351.  
  1352.   template<class charT, class traits>
  1353.   basic_ostream<charT, traits>&
  1354.   basic_ostream<charT, traits>::operator<<(const void *p)
  1355.   {
  1356.     ios_base::iostate err = 0;
  1357.  
  1358. #ifndef _RWSTD_NO_EXCEPTIONS
  1359.     try {
  1360. #endif
  1361.  
  1362.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1363.       if (opfx)
  1364.       {
  1365.         if (
  1366. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1367.             use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1368. #else
  1369.             use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1370. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1371.             .put(ostreambuf_iterator<charT,traits>(*this),*this,this->fill(),p).failed() )
  1372.           err = ios_base::badbit;
  1373.         this->width(0);
  1374.       }
  1375.  
  1376. #ifndef _RWSTD_NO_EXCEPTIONS
  1377.     }
  1378. #endif
  1379.  
  1380. #ifndef _RWSTD_NO_EXCEPTIONS
  1381.     catch(...)
  1382.     {
  1383.       bool flag = false;
  1384.       try {
  1385.         this->setstate(ios_base::badbit);
  1386.       }
  1387.       catch( ios_base::failure ) { flag= true; }
  1388.       if ( flag ) throw;
  1389.     }
  1390. #endif
  1391.     if ( err ) this->setstate(err);
  1392.     return *this;
  1393.   }
  1394.  
  1395.   /*
  1396.    * basic_ostream& put(char_type)
  1397.    */
  1398.  
  1399.   template<class charT, class traits>
  1400.   basic_ostream<charT, traits>&
  1401.   basic_ostream<charT, traits>::put(char_type c)
  1402.   {
  1403.     ios_base::iostate err = 0; 
  1404.  
  1405. #ifndef _RWSTD_NO_EXCEPTIONS
  1406.     try {
  1407. #endif
  1408.       _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1409.       if(opfx)
  1410.       {
  1411.         if( traits::eq_int_type(this->rdbuf()->sputc(c),traits::eof()) )  
  1412.           err = ios_base::badbit;    
  1413.       }
  1414.  
  1415. #ifndef _RWSTD_NO_EXCEPTIONS
  1416.     }
  1417. #endif
  1418.  
  1419. #ifndef _RWSTD_NO_EXCEPTIONS
  1420.     catch(...)
  1421.     {
  1422.       bool flag = false;
  1423.       try {
  1424.         this->setstate(ios_base::badbit);
  1425.       }
  1426.       catch( ios_base::failure ) { flag= true; }
  1427.       if ( flag ) throw;
  1428.     }
  1429. #endif
  1430.     if ( err ) this->setstate(err);
  1431.     return *this;
  1432.   }
  1433.  
  1434.   /*
  1435.    * basic_ostream& write(const char_type *, streamsize)
  1436.    */
  1437.  
  1438.   template<class charT, class traits>
  1439.   basic_ostream<charT, traits>&
  1440.   basic_ostream<charT, traits>::write(const char_type *s, streamsize n)
  1441.   {
  1442.     ios_base::iostate err = 0; 
  1443.  
  1444. #ifndef _RWSTD_NO_EXCEPTIONS
  1445.     try {
  1446. #endif 
  1447.  
  1448.       if(s)
  1449.       {
  1450.         _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1451.         if(opfx)
  1452.         {
  1453.           if(this->rdbuf()->sputn(s, n)!=n) 
  1454.             err = ios_base::badbit;
  1455.         }
  1456.       }
  1457.       else
  1458.         err = ios_base::badbit;
  1459.  
  1460. #ifndef _RWSTD_NO_EXCEPTIONS
  1461.     }
  1462. #endif
  1463.  
  1464. #ifndef _RWSTD_NO_EXCEPTIONS
  1465.     catch(...)
  1466.     {
  1467.       bool flag = false;
  1468.       try {
  1469.         this->setstate(ios_base::badbit);
  1470.       }
  1471.       catch( ios_base::failure ) { flag= true; }
  1472.       if ( flag ) throw;
  1473.     }
  1474. #endif
  1475.     if ( err ) this->setstate(err);
  1476.     return *this;
  1477.   }
  1478.   template<class charT, class traits>
  1479.   basic_ostream<charT, traits>&
  1480.   basic_ostream<charT, traits>::seekp(off_type off, ios_base::seekdir dir)
  1481.   {
  1482. #ifdef _RWSTD_MULTI_THREAD
  1483.     if ( this->rdbuf() )
  1484.       _RWSTDGuard guard(this->rdbuf()->buffer_mutex_);
  1485. #endif
  1486.     if ( this->bad() ) return *this;
  1487.     if(this->rdbuf()->pubseekoff(off, dir, ios_base::out) == pos_type(off_type(-1)))
  1488.       this->setstate(ios_base::failbit);
  1489.     else
  1490.       clear(this->rdstate() & ~(ios_base::eofbit | ios_base::failbit));
  1491.  
  1492.     return *this;
  1493.   }
  1494.  
  1495.   template<class charT, class traits>
  1496.   _TYPENAME basic_ostream<charT,traits>::pos_type
  1497.   basic_ostream<charT, traits>::tellp()
  1498.   {
  1499.     pos_type    p;
  1500.  
  1501. #ifdef _RWSTD_MULTI_THREAD
  1502.     if ( this->rdbuf() )
  1503.       _RWSTDGuard guard(this->rdbuf()->buffer_mutex_);
  1504. #endif // _RWSTD_MULTI_THREAD 
  1505.  
  1506.     if ( this->bad() ) return pos_type(-1);
  1507.  
  1508.     if((p = this->rdbuf()->pubseekoff(0, ios_base::cur,ios_base::out)) ==
  1509.        pos_type(off_type(-1)))
  1510.       this->setstate(ios_base::failbit);
  1511.  
  1512.     return p;
  1513.   }
  1514. #ifndef _RWSTD_NO_NAMESPACE
  1515. }
  1516. #endif
  1517. #pragma option pop
  1518. #endif /* __OSTREAM_CC */
  1519.