[Scummvm-git-logs] scummvm master -> e36abe967ec3c2fe71687e6014986321d68bb5c3
criezy
noreply at scummvm.org
Sun Sep 4 22:22:10 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e36abe967e COMMON: Move std::initializer_list to scummsys.h
Commit: e36abe967ec3c2fe71687e6014986321d68bb5c3
https://github.com/scummvm/scummvm/commit/e36abe967ec3c2fe71687e6014986321d68bb5c3
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-09-04T23:20:17+01:00
Commit Message:
COMMON: Move std::initializer_list to scummsys.h
Changed paths:
R common/initializer_list.h
common/array.h
common/scummsys.h
engines/ags/lib/std/initializer_list.h
engines/ags/lib/std/vector.h
diff --git a/common/array.h b/common/array.h
index 461f2ffc862..ceba46bc434 100644
--- a/common/array.h
+++ b/common/array.h
@@ -26,7 +26,6 @@
#include "common/algorithm.h"
#include "common/textconsole.h" // For error()
#include "common/memory.h"
-#include "common/initializer_list.h"
namespace Common {
diff --git a/common/initializer_list.h b/common/initializer_list.h
deleted file mode 100644
index 024215c96a3..00000000000
--- a/common/initializer_list.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef COMMON_INITIALIZER_LIST_H
-#define COMMON_INITIALIZER_LIST_H
-
-// Some compiler only have partial support for C++11 and we provide replacements for reatures not available.
-#ifdef NO_CXX11_INITIALIZER_LIST
-namespace std {
- template<class T> class initializer_list {
- public:
- typedef T value_type;
- typedef const T& reference;
- typedef const T& const_reference;
- typedef size_t size_type;
- typedef const T* iterator;
- typedef const T* const_iterator;
-
- constexpr initializer_list() noexcept = default;
- constexpr size_t size() const noexcept { return m_size; };
- constexpr const T* begin() const noexcept { return m_begin; };
- constexpr const T* end() const noexcept { return m_begin + m_size; }
-
- private:
- // Note: begin has to be first or the compiler gets very upset
- const T* m_begin = { nullptr };
- size_t m_size = { 0 };
-
- // The compiler is allowed to call this constructor
- constexpr initializer_list(const T* t, size_t s) noexcept : m_begin(t) , m_size(s) {}
- };
-
- template<class T> constexpr const T* begin(initializer_list<T> il) noexcept {
- return il.begin();
- }
-
- template<class T> constexpr const T* end(initializer_list<T> il) noexcept {
- return il.end();
- }
-}
-
-#else
-
-#include <initializer_list>
-
-#endif // NO_CXX11_INITIALIZER_LIST
-
-#endif // COMMON_INITIALIZER_LIST_H
diff --git a/common/scummsys.h b/common/scummsys.h
index 10384dc73d1..0bf4a262b05 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -504,6 +504,50 @@ namespace std {
}
#endif
+//
+// std::initializer_list
+// Provide replacement when not available
+//
+#if defined(NO_CXX11_INITIALIZER_LIST)
+namespace std {
+ template<class T> class initializer_list {
+ public:
+ typedef T value_type;
+ typedef const T &reference;
+ typedef const T &const_reference;
+ typedef size_t size_type;
+ typedef const T *iterator;
+ typedef const T *const_iterator;
+
+ constexpr initializer_list() noexcept = default;
+ constexpr size_t size() const noexcept { return _size; };
+ constexpr const T *begin() const noexcept { return _begin; };
+ constexpr const T *end() const noexcept { return _begin + _size; }
+
+ private:
+ // Note: begin has to be first or the compiler may get very upset
+ const T *_begin = { nullptr };
+ size_t _size = { 0 };
+
+ // The compiler is allowed to call this constructor
+ constexpr initializer_list(const T* t, size_t s) noexcept : _begin(t) , _size(s) {}
+ };
+
+ template<class T> constexpr const T* begin(initializer_list<T> il) noexcept {
+ return il.begin();
+ }
+
+ template<class T> constexpr const T* end(initializer_list<T> il) noexcept {
+ return il.end();
+ }
+}
+
+#else
+
+#include <initializer_list>
+
+#endif // NO_CXX11_INITIALIZER_LIST
+
#include "common/forbidden.h"
#endif
diff --git a/engines/ags/lib/std/initializer_list.h b/engines/ags/lib/std/initializer_list.h
index 4aad91d3b49..efe34c83d5a 100644
--- a/engines/ags/lib/std/initializer_list.h
+++ b/engines/ags/lib/std/initializer_list.h
@@ -23,7 +23,6 @@
#define AGS_STD_INITIALIZER_LIST_H
#include "common/scummsys.h"
-#include "common/initializer_list.h"
namespace AGS3 {
namespace std {
diff --git a/engines/ags/lib/std/vector.h b/engines/ags/lib/std/vector.h
index d46b84023f2..57f0c65d2f8 100644
--- a/engines/ags/lib/std/vector.h
+++ b/engines/ags/lib/std/vector.h
@@ -27,7 +27,6 @@
#include "common/scummsys.h"
#include "common/algorithm.h"
#include "common/memory.h"
-#include "common/initializer_list.h"
namespace AGS3 {
namespace std {
More information about the Scummvm-git-logs
mailing list