<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>containers_fixes.hpp Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> > <b>C++ reference</b> </div> <div align="right"> <a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a> </div> <!-- Generated by Doxygen 1.7.5 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <div class="left"> <form id="FSearchBox" action="search.php" method="get"> <img id="MSearchSelect" src="search/mag.png" alt=""/> <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"/> </form> </div><div class="right"></div> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">containers_fixes.hpp</div> </div> </div> <div class="contents"> <a href="containers__fixes_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> The STL+ C++ Library Collection</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> Website <http://stlplus.sourceforge.net/> Collection <index.html></span> <a name="l00005"></a>00005 <span class="comment"></span> <a name="l00006"></a>00006 <span class="comment"></span> <a name="l00007"></a>00007 <span class="comment"> License Agreement</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> <http://www.opensource.org/></span> <a name="l00010"></a>00010 <span class="comment"></span> <a name="l00011"></a>00011 <span class="comment"> * License for using the STLplus Library Collection <#license></span> <a name="l00012"></a>00012 <span class="comment"> * The Intent of this License <#intent></span> <a name="l00013"></a>00013 <span class="comment"> * How to Comply with this License <#compliance></span> <a name="l00014"></a>00014 <span class="comment"> * Historical Note <#history></span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment"> License for using the STLplus Library Collection</span> <a name="l00018"></a>00018 <span class="comment"></span> <a name="l00019"></a>00019 <span class="comment"> *© 1999-2008 Andy Rushton. All rights reserved.*</span> <a name="l00020"></a>00020 <span class="comment"></span> <a name="l00021"></a>00021 <span class="comment"> Redistribution and use in source and binary forms, with or without</span> <a name="l00022"></a>00022 <span class="comment"> modification, are permitted provided that the following conditions are met:</span> <a name="l00023"></a>00023 <span class="comment"></span> <a name="l00024"></a>00024 <span class="comment"> * Redistributions of source code must retain the above Copyright</span> <a name="l00025"></a>00025 <span class="comment"> notice, this list of conditions and the following disclaimer.</span> <a name="l00026"></a>00026 <span class="comment"> * Redistributions in binary form must reproduce the above Copyright</span> <a name="l00027"></a>00027 <span class="comment"> notice, this list of conditions and the following disclaimer in</span> <a name="l00028"></a>00028 <span class="comment"> the documentation and/or other materials provided with the</span> <a name="l00029"></a>00029 <span class="comment"> distribution.</span> <a name="l00030"></a>00030 <span class="comment"> * Neither the name of the STLplus library nor the names of its</span> <a name="l00031"></a>00031 <span class="comment"> contributors may be used to endorse or promote products derived</span> <a name="l00032"></a>00032 <span class="comment"> from this software without specific prior written permission.</span> <a name="l00033"></a>00033 <span class="comment"></span> <a name="l00034"></a>00034 <span class="comment"> This software is provided by the Copyright holders and contributors "as</span> <a name="l00035"></a>00035 <span class="comment"> is" and any express or implied warranties, including, but not limited</span> <a name="l00036"></a>00036 <span class="comment"> to, the implied warranties of merchantability and fitness for a</span> <a name="l00037"></a>00037 <span class="comment"> particular purpose are disclaimed. In no event shall the Copyright owner</span> <a name="l00038"></a>00038 <span class="comment"> or contributors be liable for any direct, indirect, incidental, special,</span> <a name="l00039"></a>00039 <span class="comment"> exemplary, or consequential damages (including, but not limited to,</span> <a name="l00040"></a>00040 <span class="comment"> procurement of substitute goods or services; loss of use, data, or</span> <a name="l00041"></a>00041 <span class="comment"> profits; or business interruption) however caused and on any theory of</span> <a name="l00042"></a>00042 <span class="comment"> liability, whether in contract, strict liability, or tort (including</span> <a name="l00043"></a>00043 <span class="comment"> negligence or otherwise) arising in any way out of the use of this</span> <a name="l00044"></a>00044 <span class="comment"> software, even if advised of the possibility of such damage.</span> <a name="l00045"></a>00045 <span class="comment">*/</span> <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="preprocessor">#ifndef STLPLUS_CONTAINERS_FIXES</span> <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#define STLPLUS_CONTAINERS_FIXES</span> <a name="l00049"></a>00049 <span class="preprocessor"></span><span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00050"></a>00050 <span class="comment"></span> <a name="l00051"></a>00051 <span class="comment">// Author: Andy Rushton</span> <a name="l00052"></a>00052 <span class="comment">// Copyright: (c) Andy Rushton, 2007</span> <a name="l00053"></a>00053 <span class="comment">// License: BSD License, see ../docs/license.html</span> <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="comment">// Contains work arounds for OS or Compiler specific problems with container</span> <a name="l00056"></a>00056 <span class="comment">// templates</span> <a name="l00057"></a>00057 <span class="comment"></span> <a name="l00058"></a>00058 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00059"></a>00059 <span class="comment"></span><span class="comment"></span> <a name="l00060"></a>00060 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00061"></a>00061 <span class="comment"></span><span class="comment">// Unnecessary compiler warnings</span><span class="comment"></span> <a name="l00062"></a>00062 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00063"></a>00063 <span class="comment"></span> <a name="l00064"></a>00064 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00065"></a>00065 <span class="preprocessor"></span><span class="comment">// Microsoft Visual Studio</span> <a name="l00066"></a>00066 <span class="comment">// shut up the following irritating warnings</span> <a name="l00067"></a>00067 <span class="comment">// 4275 - VC6, exported class was derived from a class that was not exported</span> <a name="l00068"></a>00068 <span class="comment">// 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)</span> <a name="l00069"></a>00069 <span class="comment">// 4305 - VC6, identifier type was converted to a smaller type</span> <a name="l00070"></a>00070 <span class="comment">// 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)</span> <a name="l00071"></a>00071 <span class="comment">// 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it</span> <a name="l00072"></a>00072 <span class="comment">// 4290 - VC6, C++ exception specification ignored</span> <a name="l00073"></a>00073 <span class="comment">// 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)</span> <a name="l00074"></a>00074 <span class="comment">// 4355 - VC6, 'this' : used in base member initializer list</span> <a name="l00075"></a>00075 <span class="comment">// 4675 - VC7.1, "change" in function overload resolution _might_ have altered program</span> <a name="l00076"></a>00076 <span class="comment">// 4996 - VC8, 'xxxx' was declared deprecated</span> <a name="l00077"></a>00077 <span class="preprocessor">#pragma warning(push) // JLBC: Added for MRPT</span> <a name="l00078"></a>00078 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(disable: 4275 4786 4305 4503 4309 4290 4800 4355 4675 4996)</span> <a name="l00079"></a>00079 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00080"></a>00080 <span class="preprocessor"></span> <a name="l00081"></a>00081 <span class="preprocessor">#ifdef __BORLANDC__</span> <a name="l00082"></a>00082 <span class="preprocessor"></span><span class="comment">// Borland</span> <a name="l00083"></a>00083 <span class="comment">// Shut up the following irritating warnings</span> <a name="l00084"></a>00084 <span class="comment">// 8008 - Condition is always true.</span> <a name="l00085"></a>00085 <span class="comment">// Whenever the compiler encounters a constant comparison that (due to</span> <a name="l00086"></a>00086 <span class="comment">// the nature of the value being compared) is always true or false, it</span> <a name="l00087"></a>00087 <span class="comment">// issues this warning and evaluates the condition at compile time.</span> <a name="l00088"></a>00088 <span class="comment">// 8060 - Possibly incorrect assignment.</span> <a name="l00089"></a>00089 <span class="comment">// This warning is generated when the compiler encounters an assignment</span> <a name="l00090"></a>00090 <span class="comment">// operator as the main operator of a conditional expression (part of</span> <a name="l00091"></a>00091 <span class="comment">// an if, while, or do-while statement). This is usually a</span> <a name="l00092"></a>00092 <span class="comment">// typographical error for the equality operator.</span> <a name="l00093"></a>00093 <span class="comment">// 8066 - Unreachable code.</span> <a name="l00094"></a>00094 <span class="comment">// A break, continue, goto, or return statement was not followed by a</span> <a name="l00095"></a>00095 <span class="comment">// label or the end of a loop or function. The compiler checks while,</span> <a name="l00096"></a>00096 <span class="comment">// do, and for loops with a constant test condition, and attempts to</span> <a name="l00097"></a>00097 <span class="comment">// recognize loops that can't fall through.</span> <a name="l00098"></a>00098 <span class="preprocessor">#pragma warn -8008</span> <a name="l00099"></a>00099 <span class="preprocessor"></span><span class="preprocessor">#pragma warn -8060</span> <a name="l00100"></a>00100 <span class="preprocessor"></span><span class="preprocessor">#pragma warn -8066</span> <a name="l00101"></a>00101 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00102"></a>00102 <span class="preprocessor"></span><span class="comment"></span> <a name="l00103"></a>00103 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00104"></a>00104 <span class="comment"></span><span class="comment">// Problems with the typename keyword</span><span class="comment"></span> <a name="l00105"></a>00105 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00106"></a>00106 <span class="comment"></span> <a name="l00107"></a>00107 <span class="comment">// There are problems with using the 'typename' keyword. Technically, if you</span> <a name="l00108"></a>00108 <span class="comment">// use a type member of a template class (i.e. a type declared within the</span> <a name="l00109"></a>00109 <span class="comment">// template class by a local typedef), you need to tell the compiler that it</span> <a name="l00110"></a>00110 <span class="comment">// is a type name. This is because the compiler cannot work out whether a</span> <a name="l00111"></a>00111 <span class="comment">// member is a type, a method or a data field at compile time. However,</span> <a name="l00112"></a>00112 <span class="comment">// support for the typename keyword has traditionally been incomplete in both</span> <a name="l00113"></a>00113 <span class="comment">// gcc and Visual Studio. I have used macros to try to resolve this issue. The</span> <a name="l00114"></a>00114 <span class="comment">// macros add the keyword for compiler versions that require it and omit it</span> <a name="l00115"></a>00115 <span class="comment">// for compiler versions that do not support it</span> <a name="l00116"></a>00116 <a name="l00117"></a>00117 <span class="comment">// There are five places where typename keywords cause problems:</span> <a name="l00118"></a>00118 <span class="comment">//</span> <a name="l00119"></a>00119 <span class="comment">// 1) in a typedef where a template class's member type is being mapped onto</span> <a name="l00120"></a>00120 <span class="comment">// a type definition within another template class or function </span> <a name="l00121"></a>00121 <span class="comment">// e.g. template<typename T> fn () {</span> <a name="l00122"></a>00122 <span class="comment">// typedef typename someclass<T>::member_type local_type;</span> <a name="l00123"></a>00123 <span class="comment">// ^^^^^^^^</span> <a name="l00124"></a>00124 <span class="comment">// 2) in a function parameter declaration, with similar rules to the above</span> <a name="l00125"></a>00125 <span class="comment">// e.g. template<typename T> fn (typename someclass<T>::member_type)</span> <a name="l00126"></a>00126 <span class="comment">// ^^^^^^^^</span> <a name="l00127"></a>00127 <span class="comment">// 3) in instantiating a template, the parameter to the template, with similar rules to the above</span> <a name="l00128"></a>00128 <span class="comment">// e.g. template_class<typename someclass<T>::member_type></span> <a name="l00129"></a>00129 <span class="comment">// ^^^^^^^^</span> <a name="l00130"></a>00130 <span class="comment">// 4) Return expressions</span> <a name="l00131"></a>00131 <span class="comment">// e.g. return typename ntree<T>::const_iterator(this,m_root);</span> <a name="l00132"></a>00132 <span class="comment">// ^^^^^^^^</span> <a name="l00133"></a>00133 <span class="comment">// 5) Creating temporary objects when passing arguments to a function or constructor</span> <a name="l00134"></a>00134 <span class="comment">// e.g. return typename ntree<T>::const_prefix_iterator(typename ntree<T>::const_iterator(this,m_root));</span> <a name="l00135"></a>00135 <span class="comment">// ^^^^^^^^</span> <a name="l00136"></a>00136 <span class="comment">// Note that the typename keyword is only required when the type being referred to is a member of a template class</span> <a name="l00137"></a>00137 <span class="comment">//</span> <a name="l00138"></a>00138 <span class="comment">// So far it *seems* as if all compilers either require all of them or none of</span> <a name="l00139"></a>00139 <span class="comment">// them, so this set of situations can be handled by a single macro</span> <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="comment">// default values, overridden for individual problem cases below</span> <a name="l00142"></a><a class="code" href="containers__fixes_8hpp.html#a17f2e729a629eee9f5b7371c357f5e25">00142</a> <span class="preprocessor">#define TYPENAME typename</span> <a name="l00143"></a>00143 <span class="preprocessor"></span> <a name="l00144"></a>00144 <span class="preprocessor">#ifdef __GNUC__</span> <a name="l00145"></a>00145 <span class="preprocessor"></span><span class="comment">// GCC </span> <a name="l00146"></a>00146 <span class="comment">// - pre-version 3 didn't handle typename in any of these cases</span> <a name="l00147"></a>00147 <span class="comment">// - version 3 onwards, typename is required for all three cases as per default</span> <a name="l00148"></a>00148 <span class="preprocessor">#if __GNUC__ < 3</span> <a name="l00149"></a>00149 <span class="preprocessor"></span><span class="comment">// gcc prior to v3</span> <a name="l00150"></a>00150 <span class="preprocessor">#undef TYPENAME</span> <a name="l00151"></a>00151 <span class="preprocessor"></span><span class="preprocessor">#define TYPENAME</span> <a name="l00152"></a>00152 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00153"></a>00153 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00154"></a>00154 <span class="preprocessor"></span> <a name="l00155"></a>00155 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00156"></a>00156 <span class="preprocessor"></span><span class="comment">// Visual Studio</span> <a name="l00157"></a>00157 <span class="comment">// - version 6 (compiler v.12) cannot handle typename in any of these cases</span> <a name="l00158"></a>00158 <span class="comment">// - version 7 (.NET) (compiler v.13) requires a typename in a parameter specification but supports all</span> <a name="l00159"></a>00159 <span class="comment">// - version 8 (2005) (compiler v.14) requires parameters and templates, supports all</span> <a name="l00160"></a>00160 <span class="preprocessor">#if _MSC_VER < 1300</span> <a name="l00161"></a>00161 <span class="preprocessor"></span><span class="comment">// compiler version 12 and earlier</span> <a name="l00162"></a>00162 <span class="preprocessor">#undef TYPENAME</span> <a name="l00163"></a>00163 <span class="preprocessor"></span><span class="preprocessor">#define TYPENAME</span> <a name="l00164"></a>00164 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00165"></a>00165 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00166"></a>00166 <span class="preprocessor"></span> <a name="l00167"></a>00167 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00168"></a>00168 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(pop) // JLBC: Added for MRPT</span> <a name="l00169"></a>00169 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00170"></a>00170 <span class="preprocessor"></span><span class="comment"></span> <a name="l00171"></a>00171 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span> <a name="l00172"></a>00172 <span class="comment"></span><span class="preprocessor">#endif</span> </pre></div></div> </div> <br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150"> </td></tr> </table> </body></html>