Main MRPT website > C++ reference
MRPT logo

containers_fixes.hpp

Go to the documentation of this file.
00001 /*
00002     The STL+ C++ Library Collection
00003 
00004     Website <http://stlplus.sourceforge.net/> Collection <index.html>
00005 
00006 
00007       License Agreement
00008 
00009     <http://www.opensource.org/>
00010 
00011         * License for using the STLplus Library Collection <#license>
00012         * The Intent of this License <#intent>
00013         * How to Comply with this License <#compliance>
00014         * Historical Note <#history>
00015 
00016 
00017         License for using the STLplus Library Collection
00018 
00019     *© 1999-2008 Andy Rushton. All rights reserved.*
00020 
00021     Redistribution and use in source and binary forms, with or without
00022     modification, are permitted provided that the following conditions are met:
00023 
00024         * Redistributions of source code must retain the above Copyright
00025           notice, this list of conditions and the following disclaimer.
00026         * Redistributions in binary form must reproduce the above Copyright
00027           notice, this list of conditions and the following disclaimer in
00028           the documentation and/or other materials provided with the
00029           distribution.
00030         * Neither the name of the STLplus library nor the names of its
00031           contributors may be used to endorse or promote products derived
00032           from this software without specific prior written permission.
00033 
00034     This software is provided by the Copyright holders and contributors "as
00035     is" and any express or implied warranties, including, but not limited
00036     to, the implied warranties of merchantability and fitness for a
00037     particular purpose are disclaimed. In no event shall the Copyright owner
00038     or contributors be liable for any direct, indirect, incidental, special,
00039     exemplary, or consequential damages (including, but not limited to,
00040     procurement of substitute goods or services; loss of use, data, or
00041     profits; or business interruption) however caused and on any theory of
00042     liability, whether in contract, strict liability, or tort (including
00043     negligence or otherwise) arising in any way out of the use of this
00044     software, even if advised of the possibility of such damage.
00045 */
00046 
00047 #ifndef STLPLUS_CONTAINERS_FIXES
00048 #define STLPLUS_CONTAINERS_FIXES
00049 ////////////////////////////////////////////////////////////////////////////////
00050 
00051 //   Author:    Andy Rushton
00052 //   Copyright: (c) Andy Rushton, 2007
00053 //   License:   BSD License, see ../docs/license.html
00054 
00055 //   Contains work arounds for OS or Compiler specific problems with container
00056 //   templates
00057 
00058 ////////////////////////////////////////////////////////////////////////////////
00059 
00060 ////////////////////////////////////////////////////////////////////////////////
00061 // Unnecessary compiler warnings
00062 ////////////////////////////////////////////////////////////////////////////////
00063 
00064 #ifdef _MSC_VER
00065 // Microsoft Visual Studio
00066 // shut up the following irritating warnings
00067 //   4275 - VC6, exported class was derived from a class that was not exported
00068 //   4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
00069 //   4305 - VC6, identifier type was converted to a smaller type
00070 //   4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
00071 //   4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
00072 //   4290 - VC6, C++ exception specification ignored
00073 //   4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
00074 //   4355 - VC6, 'this' : used in base member initializer list
00075 //   4675 - VC7.1, "change" in function overload resolution _might_ have altered program
00076 //   4996 - VC8, 'xxxx' was declared deprecated
00077 #pragma warning(push)  // JLBC: Added for MRPT
00078 #pragma warning(disable: 4275 4786 4305 4503 4309 4290 4800 4355 4675 4996)
00079 #endif
00080 
00081 #ifdef __BORLANDC__
00082 // Borland
00083 // Shut up the following irritating warnings
00084 //   8008 - Condition is always true.
00085 //          Whenever the compiler encounters a constant comparison that (due to
00086 //          the nature of the value being compared) is always true or false, it
00087 //          issues this warning and evaluates the condition at compile time.
00088 //   8060 - Possibly incorrect assignment.
00089 //          This warning is generated when the compiler encounters an assignment
00090 //          operator as the main operator of a conditional expression (part of
00091 //          an if, while, or do-while statement). This is usually a
00092 //          typographical error for the equality operator.
00093 //   8066 - Unreachable code.
00094 //          A break, continue, goto, or return statement was not followed by a
00095 //          label or the end of a loop or function. The compiler checks while,
00096 //          do, and for loops with a constant test condition, and attempts to
00097 //          recognize loops that can't fall through.
00098 #pragma warn -8008
00099 #pragma warn -8060
00100 #pragma warn -8066
00101 #endif
00102 
00103 ////////////////////////////////////////////////////////////////////////////////
00104 // Problems with the typename keyword
00105 ////////////////////////////////////////////////////////////////////////////////
00106 
00107 // There are problems with using the 'typename' keyword. Technically, if you
00108 // use a type member of a template class (i.e. a type declared within the
00109 // template class by a local typedef), you need to tell the compiler that it
00110 // is a type name. This is because the compiler cannot work out whether a
00111 // member is a type, a method or a data field at compile time. However,
00112 // support for the typename keyword has traditionally been incomplete in both
00113 // gcc and Visual Studio. I have used macros to try to resolve this issue. The
00114 // macros add the keyword for compiler versions that require it and omit it
00115 // for compiler versions that do not support it
00116 
00117 // There are five places where typename keywords cause problems:
00118 //
00119 //   1) in a typedef where a template class's member type is being mapped onto
00120 //      a type definition within another template class or function 
00121 //      e.g. template<typename T> fn () {
00122 //             typedef typename someclass<T>::member_type local_type;
00123 //                     ^^^^^^^^
00124 //   2) in a function parameter declaration, with similar rules to the above
00125 //      e.g. template<typename T> fn (typename someclass<T>::member_type)
00126 //                                    ^^^^^^^^
00127 //   3) in instantiating a template, the parameter to the template, with similar rules to the above
00128 //      e.g. template_class<typename someclass<T>::member_type>
00129 //                          ^^^^^^^^
00130 //   4) Return expressions
00131 //      e.g. return typename ntree<T>::const_iterator(this,m_root);
00132 //                  ^^^^^^^^
00133 //   5) Creating temporary objects when passing arguments to a function or constructor
00134 //      e.g. return typename ntree<T>::const_prefix_iterator(typename ntree<T>::const_iterator(this,m_root));
00135 //                                                           ^^^^^^^^
00136 // Note that the typename keyword is only required when the type being referred to is a member of a template class
00137 //
00138 // So far it *seems* as if all compilers either require all of them or none of
00139 // them, so this set of situations can be handled by a single macro
00140 
00141 // default values, overridden for individual problem cases below
00142 #define TYPENAME typename
00143 
00144 #ifdef __GNUC__
00145 // GCC 
00146 //   - pre-version 3 didn't handle typename in any of these cases
00147 //   - version 3 onwards, typename is required for all three cases as per default
00148 #if __GNUC__ < 3
00149 // gcc prior to v3
00150 #undef TYPENAME
00151 #define TYPENAME
00152 #endif
00153 #endif
00154 
00155 #ifdef _MSC_VER
00156 // Visual Studio
00157 //   - version 6 (compiler v.12) cannot handle typename in any of these cases
00158 //   - version 7 (.NET) (compiler v.13) requires a typename in a parameter specification but supports all
00159 //   - version 8 (2005) (compiler v.14) requires parameters and templates, supports all
00160 #if _MSC_VER < 1300
00161 // compiler version 12 and earlier
00162 #undef TYPENAME
00163 #define TYPENAME
00164 #endif
00165 #endif
00166 
00167 #ifdef _MSC_VER
00168 #pragma warning(pop)  // JLBC: Added for MRPT
00169 #endif
00170 
00171 ////////////////////////////////////////////////////////////////////////////////
00172 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011