stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r533832 - /incubator/stdcxx/trunk/doc/stdlibref/codecvt.html
Date Mon, 30 Apr 2007 19:26:14 GMT
Author: sebor
Date: Mon Apr 30 12:26:07 2007
New Revision: 533832

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

	STDCXX-399
	* codecvt.html: Zero-initialized mbstate_t variable in example code
	before passing it to codecvt::in() and codecvt::out() (as done in
	revision 533806. Replaced std::endl with '\n' for efficiency.

Modified:
    incubator/stdcxx/trunk/doc/stdlibref/codecvt.html

Modified: incubator/stdcxx/trunk/doc/stdlibref/codecvt.html
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/doc/stdlibref/codecvt.html?view=diff&rev=533832&r1=533831&r2=533832
==============================================================================
--- incubator/stdcxx/trunk/doc/stdlibref/codecvt.html (original)
+++ incubator/stdcxx/trunk/doc/stdlibref/codecvt.html Mon Apr 30 12:26:07 2007
@@ -357,14 +357,13 @@
 //
  
 #include &lt;iostream&gt;
-
 #include &lt;codecvte.h&gt;
 
 
 int main ()
 {
-    // not used, must be supplied to facet
-    std::mbstate_t state;
+    // not used, must be zero-initialized and supplied to facet
+    std::mbstate_t state = std::mbstate_t ();
 
     // three strings to use as buffers
     std::string 
@@ -375,9 +374,9 @@
 
     // Print initial contents of buffers
     std::cout &lt;&lt; "Before:\n"
-              &lt;&lt; ins &lt;&lt; std::endl
-              &lt;&lt; ins2 &lt;&lt; std::endl
-              &lt;&lt; outs &lt;&lt; std::endl &lt;&lt; std::endl;
+              &lt;&lt; ins &lt;&lt; '\n'
+              &lt;&lt; ins2 &lt;&lt; '\n'
+              &lt;&lt; outs &lt;&lt; "\n\n";
 
     // Create a user defined codecvt facet
     // This facet converts from ISO Latin Alphabet No. 1 
@@ -402,9 +401,12 @@
               outs.length(), out_next);
   
     std::cout &lt;&lt; "After in:\n"
-              &lt;&lt; ins &lt;&lt; std::endl
-              &lt;&lt; ins2 &lt;&lt; std::endl
-              &lt;&lt; outs &lt;&lt; std::endl &lt;&lt; std::endl;
+              &lt;&lt; ins &lt;&lt; '\n'
+              &lt;&lt; ins2 &lt;&lt; '\n'
+              &lt;&lt; outs &lt;&lt; "\n\n";
+
+    // zero-initialize (unused) state object
+    state = std::mbstate_t ();
 
     // Finally, convert back to the original codeset
 
@@ -413,9 +415,9 @@
                &amp;ins[0] + ins.length(), in_next);
   
     std::cout &lt;&lt; "After out:\n"
-              &lt;&lt; ins &lt;&lt; std::endl
-              &lt;&lt; ins2 &lt;&lt; std::endl
-              &lt;&lt; outs &lt;&lt; std::endl;
+              &lt;&lt; ins &lt;&lt; '\n'
+              &lt;&lt; ins2 &lt;&lt; '\n'
+              &lt;&lt; outs &lt;&lt; '\n';
 
     return 0;
 }



Mime
View raw message