[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;
}
- [lmi-commits] [lmi] master updated (84e96df -> 47d6100), Greg Chicares, 2017/06/27
- [lmi-commits] [lmi] master b4420a3 3/7: Fix misspellings, Greg Chicares, 2017/06/27
- [lmi-commits] [lmi] master 7a09c77 2/7: Set 'badbit' for null stream,
Greg Chicares <=
- [lmi-commits] [lmi] master eb90054 4/7: Do not use value_cast in decimal_root(), Greg Chicares, 2017/06/27
- [lmi-commits] [lmi] master c80737e 1/7: Measure minimum_birthdate() speed in unit test, Greg Chicares, 2017/06/27
- [lmi-commits] [lmi] master 47d6100 7/7: Suppress all output to null stream in decimal_root(), Greg Chicares, 2017/06/27
- [lmi-commits] [lmi] master 1f03a06 5/7: Expunge max_stream_precision(), Greg Chicares, 2017/06/27
- [lmi-commits] [lmi] master f4d2b2c 6/7: Include headers iff used, stating reasons if not obvious, Greg Chicares, 2017/06/27