12345678910111213141516171819202122232425262728
template<typename _CharT, typename _Traits> template<typename _ValueT> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>:: _M_insert(_ValueT __v) { sentry __cerb(*this);//the sentry is a class that's used for chacking for I/O errors if (__cerb)//every thing is OK { ios_base::iostate __err = ios_base::goodbit;//good untill proved bad try { const __num_put_type& __np = __check_facet(this->_M_num_put); //the locale facet's number put if (__np.put(*this, *this, this->fill(), __v).failed())//if failed __err |= ios_base::badbit;//it's bad } catch(__cxxabiv1::__forced_unwind&)//dunno { this->_M_setstate(ios_base::badbit);//bad __throw_exception_again;//throw exception } catch(...) { this->_M_setstate(ios_base::badbit); }//bad if (__err) this->setstate(__err);//error } return *this; }