summarylogtreecommitdiffstats
path: root/vdr-fix-stl-conflicts.patch
blob: 51ee26dd171b587aad4ebff113fba2e7a6dfd84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
commit fa778ad89eac5418e7e9d167e3149fc0a765382b
Author: Manuel Reimer <manuel.reimer@gmx.de>
Date:   Tue May 25 11:47:57 2021 +0200

    Remove STL conflicts
    
    https://www.vdr-portal.de/forum/index.php?thread/134491-vdr-developer-version-2-5-4/&postID=1341152#post1341152

diff --git a/tools.h b/tools.h
index 5d1559a..588f0dd 100644
--- a/tools.h
+++ b/tools.h
@@ -51,19 +51,21 @@ template<class T> inline void DELETENULL(T *&p) { T *q = p; p = NULL; delete q;
 #define CHECK(s) { if ((s) < 0) LOG_ERROR; } // used for 'ioctl()' calls
 #define FATALERRNO (errno && errno != EAGAIN && errno != EINTR)
 
-// In case some plugin needs to use the STL and gets an error message regarding one
-// of these functions, you can #define DISABLE_TEMPLATES_COLLIDING_WITH_STL before
-// including tools.h.
-#if !defined(__STL_CONFIG_H) // for old versions of the STL
-#if !defined(DISABLE_TEMPLATES_COLLIDING_WITH_STL) && !defined(_STL_ALGOBASE_H)
+#if __cplusplus >= 201103L
+// any gcc >= 4.8.1; we have swap, min, max
+#include <algorithm> // std::min, std::max, (c++98: also swap)
+#include <utility> // std::swap (since c++11)
+using std::min;
+using std::max;
+using std::swap;
+#else
+// no c++11 and old compiler, let's include our own templates
 template<class T> inline T min(T a, T b) { return a <= b ? a : b; }
 template<class T> inline T max(T a, T b) { return a >= b ? a : b; }
-#endif
-template<class T> inline int sgn(T a) { return a < 0 ? -1 : a > 0 ? 1 : 0; }
-#if !defined(DISABLE_TEMPLATES_COLLIDING_WITH_STL) && !defined(_MOVE_H)
 template<class T> inline void swap(T &a, T &b) { T t = a; a = b; b = t; }
 #endif
-#endif
+
+template<class T> inline int sgn(T a) { return a < 0 ? -1 : a > 0 ? 1 : 0; }
 
 template<class T> inline T constrain(T v, T l, T h) { return v < l ? l : v > h ? h : v; }