Main MRPT website > C++ reference for MRPT 1.4.0
containers_fixes.hpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef STLPLUS_CONTAINERS_FIXES
11 #define STLPLUS_CONTAINERS_FIXES
12 ////////////////////////////////////////////////////////////////////////////////
13 
14 // Author: Andy Rushton
15 // Copyright: (c) Andy Rushton, 2007
16 // License: BSD License, see ../docs/license.html
17 
18 // Contains work arounds for OS or Compiler specific problems with container
19 // templates
20 
21 ////////////////////////////////////////////////////////////////////////////////
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 // Unnecessary compiler warnings
25 ////////////////////////////////////////////////////////////////////////////////
26 
27 #ifdef _MSC_VER
28 // Microsoft Visual Studio
29 // shut up the following irritating warnings
30 // 4275 - VC6, exported class was derived from a class that was not exported
31 // 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
32 // 4305 - VC6, identifier type was converted to a smaller type
33 // 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
34 // 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
35 // 4290 - VC6, C++ exception specification ignored
36 // 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
37 // 4355 - VC6, 'this' : used in base member initializer list
38 // 4675 - VC7.1, "change" in function overload resolution _might_ have altered program
39 // 4996 - VC8, 'xxxx' was declared deprecated
40 #pragma warning(push) // JLBC: Added for MRPT
41 #pragma warning(disable: 4275 4786 4305 4503 4309 4290 4800 4355 4675 4996)
42 #endif
43 
44 #ifdef __BORLANDC__
45 // Borland
46 // Shut up the following irritating warnings
47 // 8008 - Condition is always true.
48 // Whenever the compiler encounters a constant comparison that (due to
49 // the nature of the value being compared) is always true or false, it
50 // issues this warning and evaluates the condition at compile time.
51 // 8060 - Possibly incorrect assignment.
52 // This warning is generated when the compiler encounters an assignment
53 // operator as the main operator of a conditional expression (part of
54 // an if, while, or do-while statement). This is usually a
55 // typographical error for the equality operator.
56 // 8066 - Unreachable code.
57 // A break, continue, goto, or return statement was not followed by a
58 // label or the end of a loop or function. The compiler checks while,
59 // do, and for loops with a constant test condition, and attempts to
60 // recognize loops that can't fall through.
61 #pragma warn -8008
62 #pragma warn -8060
63 #pragma warn -8066
64 #endif
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 // Problems with the typename keyword
68 ////////////////////////////////////////////////////////////////////////////////
69 
70 // There are problems with using the 'typename' keyword. Technically, if you
71 // use a type member of a template class (i.e. a type declared within the
72 // template class by a local typedef), you need to tell the compiler that it
73 // is a type name. This is because the compiler cannot work out whether a
74 // member is a type, a method or a data field at compile time. However,
75 // support for the typename keyword has traditionally been incomplete in both
76 // gcc and Visual Studio. I have used macros to try to resolve this issue. The
77 // macros add the keyword for compiler versions that require it and omit it
78 // for compiler versions that do not support it
79 
80 // There are five places where typename keywords cause problems:
81 //
82 // 1) in a typedef where a template class's member type is being mapped onto
83 // a type definition within another template class or function
84 // e.g. template<typename T> fn () {
85 // typedef typename someclass<T>::member_type local_type;
86 // ^^^^^^^^
87 // 2) in a function parameter declaration, with similar rules to the above
88 // e.g. template<typename T> fn (typename someclass<T>::member_type)
89 // ^^^^^^^^
90 // 3) in instantiating a template, the parameter to the template, with similar rules to the above
91 // e.g. template_class<typename someclass<T>::member_type>
92 // ^^^^^^^^
93 // 4) Return expressions
94 // e.g. return typename ntree<T>::const_iterator(this,m_root);
95 // ^^^^^^^^
96 // 5) Creating temporary objects when passing arguments to a function or constructor
97 // e.g. return typename ntree<T>::const_prefix_iterator(typename ntree<T>::const_iterator(this,m_root));
98 // ^^^^^^^^
99 // Note that the typename keyword is only required when the type being referred to is a member of a template class
100 //
101 // So far it *seems* as if all compilers either require all of them or none of
102 // them, so this set of situations can be handled by a single macro
103 
104 // default values, overridden for individual problem cases below
105 #define TYPENAME typename
106 
107 #ifdef __GNUC__
108 // GCC
109 // - pre-version 3 didn't handle typename in any of these cases
110 // - version 3 onwards, typename is required for all three cases as per default
111 #if __GNUC__ < 3
112 // gcc prior to v3
113 #undef TYPENAME
114 #define TYPENAME
115 #endif
116 #endif
117 
118 #ifdef _MSC_VER
119 // Visual Studio
120 // - version 6 (compiler v.12) cannot handle typename in any of these cases
121 // - version 7 (.NET) (compiler v.13) requires a typename in a parameter specification but supports all
122 // - version 8 (2005) (compiler v.14) requires parameters and templates, supports all
123 #if _MSC_VER < 1300
124 // compiler version 12 and earlier
125 #undef TYPENAME
126 #define TYPENAME
127 #endif
128 #endif
129 
130 #ifdef _MSC_VER
131 #pragma warning(pop) // JLBC: Added for MRPT
132 #endif
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 #endif



Page generated by Doxygen 1.9.1 for MRPT 1.4.0 SVN: at Mon Apr 18 03:56:21 UTC 2022