Main MRPT website > C++ reference
MRPT logo
containers_fixes.hpp
Go to the documentation of this file.
1 /*
2  The STL+ C++ Library Collection
3 
4  Website <http://stlplus.sourceforge.net/> Collection <index.html>
5 
6 
7  License Agreement
8 
9  <http://www.opensource.org/>
10 
11  * License for using the STLplus Library Collection <#license>
12  * The Intent of this License <#intent>
13  * How to Comply with this License <#compliance>
14  * Historical Note <#history>
15 
16 
17  License for using the STLplus Library Collection
18 
19  *© 1999-2008 Andy Rushton. All rights reserved.*
20 
21  Redistribution and use in source and binary forms, with or without
22  modification, are permitted provided that the following conditions are met:
23 
24  * Redistributions of source code must retain the above Copyright
25  notice, this list of conditions and the following disclaimer.
26  * Redistributions in binary form must reproduce the above Copyright
27  notice, this list of conditions and the following disclaimer in
28  the documentation and/or other materials provided with the
29  distribution.
30  * Neither the name of the STLplus library nor the names of its
31  contributors may be used to endorse or promote products derived
32  from this software without specific prior written permission.
33 
34  This software is provided by the Copyright holders and contributors "as
35  is" and any express or implied warranties, including, but not limited
36  to, the implied warranties of merchantability and fitness for a
37  particular purpose are disclaimed. In no event shall the Copyright owner
38  or contributors be liable for any direct, indirect, incidental, special,
39  exemplary, or consequential damages (including, but not limited to,
40  procurement of substitute goods or services; loss of use, data, or
41  profits; or business interruption) however caused and on any theory of
42  liability, whether in contract, strict liability, or tort (including
43  negligence or otherwise) arising in any way out of the use of this
44  software, even if advised of the possibility of such damage.
45 */
46 
47 #ifndef STLPLUS_CONTAINERS_FIXES
48 #define STLPLUS_CONTAINERS_FIXES
49 ////////////////////////////////////////////////////////////////////////////////
50 
51 // Author: Andy Rushton
52 // Copyright: (c) Andy Rushton, 2007
53 // License: BSD License, see ../docs/license.html
54 
55 // Contains work arounds for OS or Compiler specific problems with container
56 // templates
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 // Unnecessary compiler warnings
62 ////////////////////////////////////////////////////////////////////////////////
63 
64 #ifdef _MSC_VER
65 // Microsoft Visual Studio
66 // shut up the following irritating warnings
67 // 4275 - VC6, exported class was derived from a class that was not exported
68 // 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
69 // 4305 - VC6, identifier type was converted to a smaller type
70 // 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
71 // 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
72 // 4290 - VC6, C++ exception specification ignored
73 // 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
74 // 4355 - VC6, 'this' : used in base member initializer list
75 // 4675 - VC7.1, "change" in function overload resolution _might_ have altered program
76 // 4996 - VC8, 'xxxx' was declared deprecated
77 #pragma warning(push) // JLBC: Added for MRPT
78 #pragma warning(disable: 4275 4786 4305 4503 4309 4290 4800 4355 4675 4996)
79 #endif
80 
81 #ifdef __BORLANDC__
82 // Borland
83 // Shut up the following irritating warnings
84 // 8008 - Condition is always true.
85 // Whenever the compiler encounters a constant comparison that (due to
86 // the nature of the value being compared) is always true or false, it
87 // issues this warning and evaluates the condition at compile time.
88 // 8060 - Possibly incorrect assignment.
89 // This warning is generated when the compiler encounters an assignment
90 // operator as the main operator of a conditional expression (part of
91 // an if, while, or do-while statement). This is usually a
92 // typographical error for the equality operator.
93 // 8066 - Unreachable code.
94 // A break, continue, goto, or return statement was not followed by a
95 // label or the end of a loop or function. The compiler checks while,
96 // do, and for loops with a constant test condition, and attempts to
97 // recognize loops that can't fall through.
98 #pragma warn -8008
99 #pragma warn -8060
100 #pragma warn -8066
101 #endif
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 // Problems with the typename keyword
105 ////////////////////////////////////////////////////////////////////////////////
106 
107 // There are problems with using the 'typename' keyword. Technically, if you
108 // use a type member of a template class (i.e. a type declared within the
109 // template class by a local typedef), you need to tell the compiler that it
110 // is a type name. This is because the compiler cannot work out whether a
111 // member is a type, a method or a data field at compile time. However,
112 // support for the typename keyword has traditionally been incomplete in both
113 // gcc and Visual Studio. I have used macros to try to resolve this issue. The
114 // macros add the keyword for compiler versions that require it and omit it
115 // for compiler versions that do not support it
116 
117 // There are five places where typename keywords cause problems:
118 //
119 // 1) in a typedef where a template class's member type is being mapped onto
120 // a type definition within another template class or function
121 // e.g. template<typename T> fn () {
122 // typedef typename someclass<T>::member_type local_type;
123 // ^^^^^^^^
124 // 2) in a function parameter declaration, with similar rules to the above
125 // e.g. template<typename T> fn (typename someclass<T>::member_type)
126 // ^^^^^^^^
127 // 3) in instantiating a template, the parameter to the template, with similar rules to the above
128 // e.g. template_class<typename someclass<T>::member_type>
129 // ^^^^^^^^
130 // 4) Return expressions
131 // e.g. return typename ntree<T>::const_iterator(this,m_root);
132 // ^^^^^^^^
133 // 5) Creating temporary objects when passing arguments to a function or constructor
134 // e.g. return typename ntree<T>::const_prefix_iterator(typename ntree<T>::const_iterator(this,m_root));
135 // ^^^^^^^^
136 // Note that the typename keyword is only required when the type being referred to is a member of a template class
137 //
138 // So far it *seems* as if all compilers either require all of them or none of
139 // them, so this set of situations can be handled by a single macro
140 
141 // default values, overridden for individual problem cases below
142 #define TYPENAME typename
143 
144 #ifdef __GNUC__
145 // GCC
146 // - pre-version 3 didn't handle typename in any of these cases
147 // - version 3 onwards, typename is required for all three cases as per default
148 #if __GNUC__ < 3
149 // gcc prior to v3
150 #undef TYPENAME
151 #define TYPENAME
152 #endif
153 #endif
154 
155 #ifdef _MSC_VER
156 // Visual Studio
157 // - version 6 (compiler v.12) cannot handle typename in any of these cases
158 // - version 7 (.NET) (compiler v.13) requires a typename in a parameter specification but supports all
159 // - version 8 (2005) (compiler v.14) requires parameters and templates, supports all
160 #if _MSC_VER < 1300
161 // compiler version 12 and earlier
162 #undef TYPENAME
163 #define TYPENAME
164 #endif
165 #endif
166 
167 #ifdef _MSC_VER
168 #pragma warning(pop) // JLBC: Added for MRPT
169 #endif
170 
171 ////////////////////////////////////////////////////////////////////////////////
172 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013