aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/ostream.tcc
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/bits/ostream.tcc')
-rw-r--r--libstdc++-v3/include/bits/ostream.tcc52
1 files changed, 31 insertions, 21 deletions
diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc
index e42eca29192..90df2c0647d 100644
--- a/libstdc++-v3/include/bits/ostream.tcc
+++ b/libstdc++-v3/include/bits/ostream.tcc
@@ -41,11 +41,19 @@ namespace std
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>::sentry::
sentry(basic_ostream<_CharT,_Traits>& __os)
- : _M_ok(__os.good()), _M_os(__os)
+ : _M_os(__os)
{
- // XXX MT
- if (_M_ok && __os.tie())
- __os.tie()->flush();
+ // XXX MT
+ if (__os.tie() && __os.good())
+ __os.tie()->flush();
+
+ if (__os.good())
+ _M_ok = true;
+ else
+ {
+ _M_ok = false;
+ __os.setstate(ios_base::failbit);
+ }
}
template<typename _CharT, typename _Traits>
@@ -62,7 +70,7 @@ namespace std
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -84,7 +92,7 @@ namespace std
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -106,7 +114,7 @@ namespace std
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -130,7 +138,7 @@ namespace std
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -157,7 +165,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -194,7 +202,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -219,7 +227,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -258,7 +266,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -283,7 +291,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -309,7 +317,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -334,7 +342,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -359,7 +367,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -485,7 +493,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -521,7 +529,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -556,7 +564,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -605,7 +613,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -644,7 +652,7 @@ namespace std
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -689,6 +697,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
@@ -710,4 +719,5 @@ namespace std
extern template wostream& operator<<(wostream&, const wchar_t*);
extern template wostream& operator<<(wostream&, const char*);
#endif
+#endif
} // namespace std