item about Borland C++ dislike for objects in ternary operator added
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3871 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -50,6 +50,7 @@ C++ portability guide</A> by David Williams.
 | 
				
			|||||||
    <LI><A HREF="#no_stl">Don't use STL</A></LI>
 | 
					    <LI><A HREF="#no_stl">Don't use STL</A></LI>
 | 
				
			||||||
    <LI><A HREF="#no_fordecl">Don't declare variables inside <TT>for()</TT></A></LI>
 | 
					    <LI><A HREF="#no_fordecl">Don't declare variables inside <TT>for()</TT></A></LI>
 | 
				
			||||||
    <LI><A HREF="#no_nestedclasses">Don't use nested classes</A></LI>
 | 
					    <LI><A HREF="#no_nestedclasses">Don't use nested classes</A></LI>
 | 
				
			||||||
 | 
					    <LI><A HREF="#no_ternarywithobjects">Use ternary operator ?: carefully</A></LI>
 | 
				
			||||||
  </OL>
 | 
					  </OL>
 | 
				
			||||||
  <BR>
 | 
					  <BR>
 | 
				
			||||||
  <LI>General recommendations</LI>
 | 
					  <LI>General recommendations</LI>
 | 
				
			||||||
@@ -332,6 +333,25 @@ you can try the following:
 | 
				
			|||||||
<P>A nice side effect is that you don't need to recompile all the files
 | 
					<P>A nice side effect is that you don't need to recompile all the files
 | 
				
			||||||
including the header if you change the PrivateLibClass declaration (it's
 | 
					including the header if you change the PrivateLibClass declaration (it's
 | 
				
			||||||
an example of a more general interface/implementation separation idea).
 | 
					an example of a more general interface/implementation separation idea).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <P><LI><A NAME="no_ternarywithobjects"></A><B>Use ternary operator ?: carefully</B></LI><P>
 | 
				
			||||||
 | 
					  The ternary operator <TT>?:</TT> shouldn't be used with objects (i.e. if any
 | 
				
			||||||
 | 
					of its operands are objects) because some compilers (notable Borland C++) fail
 | 
				
			||||||
 | 
					to compile such code.
 | 
				
			||||||
 | 
					<P><U>Workaround</U>: use <TT>if/else</TT> instead.
 | 
				
			||||||
 | 
					<PRE>
 | 
				
			||||||
 | 
					    wxString s1, s2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Borland C++ won't compile the line below
 | 
				
			||||||
 | 
					    wxString s = s1.Len() < s2.Len() ? s1 : s2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // but any C++ compiler will compile this
 | 
				
			||||||
 | 
					    wxString s;
 | 
				
			||||||
 | 
					    if ( s1.Len() < s2.Len() )
 | 
				
			||||||
 | 
					        s = s1;
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        s = s2;
 | 
				
			||||||
 | 
					</PRE>
 | 
				
			||||||
</OL>
 | 
					</OL>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <BR>
 | 
					  <BR>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user