]> Dogcows Code - chaz/yoink/blob - src/stlplus/containers/containers_fixes.hpp
fixes for newer versions of g++
[chaz/yoink] / src / stlplus / containers / containers_fixes.hpp
1 #ifndef STLPLUS_CONTAINERS_FIXES
2 #define STLPLUS_CONTAINERS_FIXES
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // Contains work arounds for OS or Compiler specific problems with container
11 // templates
12
13 ////////////////////////////////////////////////////////////////////////////////
14
15 ////////////////////////////////////////////////////////////////////////////////
16 // Unnecessary compiler warnings
17 ////////////////////////////////////////////////////////////////////////////////
18
19 #ifdef _MSC_VER
20 // Microsoft Visual Studio
21 // shut up the following irritating warnings
22 // 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
23 // 4305 - VC6, identifier type was converted to a smaller type
24 // 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
25 // 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
26 // 4290 - VC6, C++ exception specification ignored
27 // 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
28 // 4355 - VC6, 'this' : used in base member initializer list
29 // 4675 - VC7.1, "change" in function overload resolution _might_ have altered program
30 // 4996 - VC8, 'xxxx' was declared deprecated
31 #pragma warning(disable: 4786 4305 4503 4309 4290 4800 4355 4675 4996)
32 #endif
33
34 #ifdef __BORLANDC__
35 // Borland
36 // Shut up the following irritating warnings
37 // 8026 - Functions with exception specifications are not expanded inline
38 // 8027 - Functions with xxx are not expanded inline
39 #pragma warn -8026
40 #pragma warn -8027
41 #endif
42
43 ////////////////////////////////////////////////////////////////////////////////
44 // Problems with the typename keyword
45 ////////////////////////////////////////////////////////////////////////////////
46
47 // There are problems with using the 'typename' keyword. Technically, if you
48 // use a type member of a template class (i.e. a type declared within the
49 // template class by a local typedef), you need to tell the compiler that it
50 // is a type name. This is because the compiler cannot work out whether a
51 // member is a type, a method or a data field at compile time. However,
52 // support for the typename keyword has traditionally been incomplete in both
53 // gcc and Visual Studio. I have used macros to try to resolve this issue. The
54 // macros add the keyword for compiler versions that require it and omit it
55 // for compiler versions that do not support it
56
57 // There are five places where typename keywords cause problems:
58 //
59 // 1) in a typedef where a template class's member type is being mapped onto
60 // a type definition within another template class or function
61 // e.g. template<typename T> fn () {
62 // typedef typename someclass<T>::member_type local_type;
63 // ^^^^^^^^
64 // 2) in a function parameter declaration, with similar rules to the above
65 // e.g. template<typename T> fn (typename someclass<T>::member_type)
66 // ^^^^^^^^
67 // 3) in instantiating a template, the parameter to the template, with similar rules to the above
68 // e.g. template_class<typename someclass<T>::member_type>
69 // ^^^^^^^^
70 // 4) Return expressions
71 // e.g. return typename ntree<T>::const_iterator(this,m_root);
72 // ^^^^^^^^
73 // 5) Creating temporary objects when passing arguments to a function or constructor
74 // e.g. return typename ntree<T>::const_prefix_iterator(typename ntree<T>::const_iterator(this,m_root));
75 // ^^^^^^^^
76 // Note that the typename keyword is only required when the type being referred to is a member of a template class
77 //
78 // So far it *seems* as if all compilers either require all of them or none of
79 // them, so this set of situations can be handled by a single macro
80
81 // default values, overridden for individual problem cases below
82 #define TYPENAME typename
83
84 // GCC
85 // - pre-version 3 didn't handle typename in any of these cases
86 // - version 3 onwards, typename is required for all three cases as per default
87 #ifdef __GNUC__
88 #if __GNUC__ < 3
89 #undef TYPENAME
90 #define TYPENAME
91 #endif
92 #endif
93
94 // Visual Studio
95 // - version 6 (compiler v.12) cannot handle typename in any of these cases
96 // - version 7 (.NET) (compiler v.13) requires a typename in a parameter specification but supports all
97 // - version 8 (2005) (compiler v.14) requires parameters and templates, supports all
98 #ifdef _MSC_VER
99 #if _MSC_VER <= 1200
100 #undef TYPENAME
101 #define TYPENAME
102 #endif
103 #endif
104
105 // Borland
106 // - doesn't handle typename in 5.5, does in 5.82, not sure about other cases
107 #ifdef __BORLANDC__
108 #if __BORLANDC__ <= 0x550
109 #undef TYPENAME
110 #define TYPENAME
111 #endif
112 #endif
113
114 ////////////////////////////////////////////////////////////////////////////////
115 // Member templates
116 // e.g. a template function in a template class
117
118 // Not all compilers support them - this fix can be used to disable member
119 // templates for compilers that don't. Unfortunately that means that some
120 // functionality will be missing for those compilers.
121
122 #define STLPLUS_MEMBER_TEMPLATES
123
124 // Visual Studio v6 (compiler version 12) does not support them
125 #ifdef _MSC_VER
126 #if _MSC_VER <= 1200
127 #undef STLPLUS_MEMBER_TEMPLATES
128 #endif
129 #endif
130
131 ////////////////////////////////////////////////////////////////////////////////
132 #endif
This page took 0.035966 seconds and 4 git commands to generate.