lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 7a09c77 2/7: Set 'badbit' for null stream


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 7a09c77 2/7: Set 'badbit' for null stream
Date: Tue, 27 Jun 2017 17:13:47 -0400 (EDT)

branch: master
commit 7a09c770a612e5992f2f27055c51f6e24b4ab49f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Set 'badbit' for null stream
    
    It is natural to set 'badbit' for an ostream that is intended to serve
    as a black hole.
---
 null_stream.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/null_stream.cpp b/null_stream.cpp
index c2ad1a6..1a18f84 100644
--- a/null_stream.cpp
+++ b/null_stream.cpp
@@ -23,6 +23,7 @@
 
 #include "null_stream.hpp"
 
+#include <ios>
 #include <ostream>
 #include <streambuf>
 #include <string>
@@ -33,9 +34,9 @@
 ///   http://groups.google.com/address@hidden
 /// which bears no copyright notice, as is usual in usenet.
 ///
-/// GWC modified this class in 2007, and in any later year, as
-/// described in 'ChangeLog'; any defect in it should not reflect on
-/// Dietmar Kuehl's reputation.
+/// GWC modified this class in 2007, and in any later year as
+/// described in `git log`; any defect in it should not reflect on
+/// Dietmar Kühl's reputation.
 
 template<typename CharType, typename traits = std::char_traits<CharType>>
 class dev_null_stream_buffer
@@ -71,6 +72,7 @@ std::streambuf& null_streambuf()
 std::ostream& null_stream()
 {
     static std::ostream z(&null_streambuf());
+    z.setstate(std::ios::badbit);
     return z;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]