stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r645701 - /stdcxx/trunk/examples/manual/fmtflags_manip.cpp
Date Mon, 07 Apr 2008 21:28:18 GMT
Author: sebor
Date: Mon Apr  7 14:28:17 2008
New Revision: 645701

URL: http://svn.apache.org/viewvc?rev=645701&view=rev
Log:
2008-04-07  Martin Sebor  <sebor@roguewave.com>

	STDCXX-831
	* exmaples/manual/fmtflags_manip.cpp (fmtflags_manip, saveflags): Avoid
	converting -1 to fmtflags due to the unspecified result of the operation
	and to silence HP aCC 6 warnings.

Modified:
    stdcxx/trunk/examples/manual/fmtflags_manip.cpp

Modified: stdcxx/trunk/examples/manual/fmtflags_manip.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/examples/manual/fmtflags_manip.cpp?rev=645701&r1=645700&r2=645701&view=diff
==============================================================================
--- stdcxx/trunk/examples/manual/fmtflags_manip.cpp (original)
+++ stdcxx/trunk/examples/manual/fmtflags_manip.cpp Mon Apr  7 14:28:17 2008
@@ -36,13 +36,15 @@
 // implementation class of the fmtflags manipulator that saves
 // a stream object's fmtflags state before optionally setting
 // their new value and restores the saved state when destroyed
+// uses ios::basefield as an invalid flags value (it's a valid
+// mask but not a valid flags value)
 class fmtflags_manip
 {
     std::ios_base           *strm_;
     std::ios_base::fmtflags  saved_;
 
 public:
-    fmtflags_manip (): strm_ (), saved_ (std::ios_base::fmtflags (-1)) { }
+    fmtflags_manip (): strm_ (), saved_ (std::ios_base::basefield) { }
 
     void operator() (std::ios_base           &strm,
                      std::ios_base::fmtflags  flags) const {
@@ -50,7 +52,7 @@
         const_cast<fmtflags_manip*>(this)->strm_  = &strm;
         const_cast<fmtflags_manip*>(this)->saved_ = strm.flags ();
 
-        if (flags != std::ios_base::fmtflags (-1))
+        if (flags != std::ios_base::basefield)
             strm.flags (flags);
     }
 
@@ -64,7 +66,7 @@
 // saveflags manipulator to temporarily set formatting flags and
 // restore their initial value at the end of an insertion statement
 inline std::__rw_smanip<fmtflags_manip, std::ios_base::fmtflags>
-saveflags (std::ios_base::fmtflags flags = std::ios_base::fmtflags (-1))
+saveflags (std::ios_base::fmtflags flags = std::ios_base::basefield)
 {
     typedef std::__rw_smanip<fmtflags_manip, std::ios_base::fmtflags> Manip;
 



Mime
View raw message