Difference between revisions of "Talk:Writing warning-free code"

From Apache OpenOffice Wiki
Jump to: navigation, search
(integer cast)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
BM:
  
<div style="overflow: auto; height: 1px;">
+
About this:
[http://www.mp3.com/users/nokia-ringtone/profile.php  free nokia ringtones]
+
 
[http://www.mp3.com/users/verizonringtone/ verizon ringtones]
+
<pre>
[http://www.mp3.com/users/sprintringtones/ free sprint ringtones]
+
  1.     sal_Int32 n;
[http://www.buddy4u.com/view/?u=xanax-xr Xanax XR]
+
  2.     std::vector<char> v;
[http://www.mp3.com/users/benny--benassi/ Benny Benassi]
+
  3.     if (n >= 0 && sal::static_int_cast<sal_uInt32>(n) == v.size()) ...  
[http://www.mp3.com/users/crazy-frog-mp3/ Crazy Frog mp3]
+
</pre>
[http://www.mp3.com/users/madonna-mp3/ Madonna mp3]
+
 
[http://www.mp3.com/users/monkey-business/ Black Eyed Peas Monkey Business]
+
Wouldn't it be correct to do a
[http://www.mp3.com/users/eminem-mp3/ Eminem mp3]
+
 
[http://www.mp3.com/users/madonna-confess/ Confessions on a Dance Floor]
+
<pre>
[http://www.mp3.com/users/hilary-duff-mp3/ Hilary Duff mp3]
+
  3.      if (n >= 0 && sal::static_int_cast< std::vector<char>::size_type >(n) == v.size()) ...  
[http://www.oreck.com/postcards/postcard-show.cfm?oreckstamp=3966 Air Purifier]
+
</pre>
</div>
+
 
 +
instead of a cast to <code>sal_uInt32</code> or the suggested macro <code>sal::static_int_cast(n)</code>. Or does the STL guarantee that all STL-types use the same <code>size_type</code>?

Latest revision as of 09:43, 4 May 2006

BM:

About this:

   1.      sal_Int32 n;
   2.      std::vector<char> v;
   3.      if (n >= 0 && sal::static_int_cast<sal_uInt32>(n) == v.size()) ... 

Wouldn't it be correct to do a

   3.      if (n >= 0 && sal::static_int_cast< std::vector<char>::size_type >(n) == v.size()) ... 

instead of a cast to sal_uInt32 or the suggested macro sal::static_int_cast(n). Or does the STL guarantee that all STL-types use the same size_type?

Personal tools