NCBI C++ ToolKit
muParserFixes.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2008 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 
26 #ifndef MU_PARSER_FIXES_H
27 #define MU_PARSER_FIXES_H
28 
29 /** \file
30  \brief This file contains compatibility fixes for some platforms.
31 */
32 
33 //
34 // Compatibility fixes
35 //
36 
37 //---------------------------------------------------------------------------
38 //
39 // Intel Compiler
40 //
41 //---------------------------------------------------------------------------
42 
43 #ifdef __INTEL_COMPILER
44 
45 // remark #981: operands are evaluated in unspecified order
46 // disabled -> completely pointless if the functions do not have side effects
47 //
48 #pragma warning(disable:981)
49 
50 // remark #383: value copied to temporary, reference to temporary used
51 #pragma warning(disable:383)
52 
53 // remark #1572: floating-point equality and inequality comparisons are unreliable
54 // disabled -> everyone knows it, the parser passes this problem
55 // deliberately to the user
56 #pragma warning(disable:1572)
57 
58 #endif
59 
60 
61 //---------------------------------------------------------------------------
62 //
63 // MSVC6
64 //
65 //---------------------------------------------------------------------------
66 
67 
68 #if defined(_MSC_VER) && _MSC_VER==1200
69 
70 /** \brief Macro to replace the MSVC6 auto_ptr with the _my_auto_ptr class.
71 
72  Hijack auto_ptr and replace it with a version that actually does
73  what an auto_ptr normally does. If you use std::auto_ptr in your other code
74  might either explode or work much better. The original crap created
75  by Microsoft, called auto_ptr and bundled with MSVC6 is not standard compliant.
76 */
77 #define auto_ptr _my_auto_ptr
78 
79 // This is another stupidity that needs to be undone in order to de-pollute
80 // the global namespace!
81 #undef min
82 #undef max
83 
84 
85 namespace std
86 {
87  typedef ::size_t size_t;
88 
89  //---------------------------------------------------------------------------
90  /** \brief MSVC6 fix: Dummy function to put rand into namespace std.
91 
92  This is a hack for MSVC6 only. It's dirty, it's ugly and it works, provided
93  inlining is enabled. Necessary because I will not pollute or change my
94  code in order to adopt it to MSVC6 interpretation of how C++ should look like!
95  */
96  inline int rand(void)
97  {
98  return ::rand();
99  }
100 
101  //---------------------------------------------------------------------------
102  /** \brief MSVC6 fix: Dummy function to put strlen into namespace std.
103 
104  This is a hack for MSVC6 only. It's dirty, it's ugly and it works, provided
105  inlining is enabled. Necessary because I will not pollute or change my
106  code in order to adopt it to MSVC6 interpretation of how C++ should look like!
107  */
108  inline size_t strlen(const char *szMsg)
109  {
110  return ::strlen(szMsg);
111  }
112 
113  //---------------------------------------------------------------------------
114  /** \brief MSVC6 fix: Dummy function to put strncmp into namespace std.
115 
116  This is a hack for MSVC6 only. It's dirty, it's ugly and it works, provided
117  inlining is enabled. Necessary because I will not pollute or change my
118  code in order to adopt it to MSVC6 interpretation of how C++ should look like!
119  */
120  inline int strncmp(const char *a, const char *b, size_t len)
121  {
123  }
124 
125  //---------------------------------------------------------------------------
126  template<typename T>
127  T max(T a, T b)
128  {
129  return (a>b) ? a : b;
130  }
131 
132  //---------------------------------------------------------------------------
133  template<typename T>
134  T min(T a, T b)
135  {
136  return (a<b) ? a : b;
137  }
138 
139  //---------------------------------------------------------------------------
140  /** Standard compliant auto_ptr redefinition for MSVC6.
141 
142  The code is taken from VS.NET 2003, slightly modified to reduce
143  it's dependencies from other classes.
144  */
145  template<class _Ty>
146  class _my_auto_ptr
147  {
148  public:
149  typedef _Ty element_type;
150 
151  explicit _my_auto_ptr(_Ty *_Ptr = 0)
152  :_Myptr(_Ptr)
153  {}
154 
155  _my_auto_ptr(_my_auto_ptr<_Ty>& _Right)
156  :_Myptr(_Right.release())
157  {}
158 
159  template<class _Other>
160  operator _my_auto_ptr<_Other>()
161  {
162  return (_my_auto_ptr<_Other>(*this));
163  }
164 
165  template<class _Other>
166  _my_auto_ptr<_Ty>& operator=(_my_auto_ptr<_Other>& _Right)
167  {
168  reset(_Right.release());
169  return (*this);
170  }
171 
172  ~auto_ptr() { delete _Myptr; }
173  _Ty& operator*() const { return (*_Myptr); }
174  _Ty *operator->() const { return (&**this); }
175  _Ty *get() const { return (_Myptr); }
176 
177  _Ty *release()
178  {
179  _Ty *_Tmp = _Myptr;
180  _Myptr = 0;
181  return (_Tmp);
182  }
183 
184  void reset(_Ty* _Ptr = 0)
185  {
186  if (_Ptr != _Myptr)
187  delete _Myptr;
188  _Myptr = _Ptr;
189  }
190 
191  private:
192  _Ty *_Myptr;
193  }; // class _my_auto_ptr
194 } // namespace std
195 
196 #endif // Microsoft Visual Studio Version 6.0
197 
198 #endif // include guard
199 
200 
constexpr const tuple_element< _Index, ct_const_tuple< _Types... > >::type & get(const ct_const_tuple< _Types... > &_Tuple) noexcept
Definition: const_tuple.hpp:97
#define T(s)
Definition: common.h:230
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
Definition: globals.hpp:371
int len
int strncmp(const char *str1, const char *str2, size_t count)
Definition: odbc_utils.hpp:133
unsigned int a
Definition: ncbi_localip.c:102
T max(T x_, T y_)
T min(T x_, T y_)
Modified on Fri Sep 20 14:57:19 2024 by modify_doxy.py rev. 669887