summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-12 18:56:17 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-12 18:56:17 +0100
commit6b0741306964f3a5220acb2b375b09cf1814443b (patch)
treed5b24fab133847e2cb53507e081974e54238bc39
parentfcf1619d1d13242ff316cf5232ef933cf58e04be (diff)
OptionalStl, we hardly knew you
-rw-r--r--compat/optional.hpp25
-rw-r--r--editor/app.hpp2
-rw-r--r--editor/editor.hpp2
m---------external/corrade0
-rw-r--r--src/precomp.hpp2
5 files changed, 28 insertions, 3 deletions
diff --git a/compat/optional.hpp b/compat/optional.hpp
new file mode 100644
index 00000000..9c1f9f6c
--- /dev/null
+++ b/compat/optional.hpp
@@ -0,0 +1,25 @@
+#pragma once
+#include <type_traits>
+#include <Corrade/Containers/Optional.h>
+
+namespace std {
+template<class T> struct tuple_size<Corrade::Containers::Optional<T>> : std::integral_constant<std::size_t, 2> {};
+template<class T> struct tuple_element<0, Corrade::Containers::Optional<T>> { using type = T; };
+template<class T> struct tuple_element<1, Corrade::Containers::Optional<T>> { using type = bool; };
+}
+
+namespace Corrade::Containers {
+
+template<std::size_t N, class T>
+std::tuple_element_t<N, Optional<T>>
+get(const Optional<T>& value) noexcept(std::is_nothrow_default_constructible_v<T> && std::is_nothrow_copy_constructible_v<T>)
+{
+ static_assert(N < 2);
+ static_assert(std::is_default_constructible_v<T> && std::is_copy_constructible_v<T>);
+ if constexpr (N == 0)
+ return value ? *value : T{};
+ if constexpr (N == 1)
+ return bool(value);
+}
+
+} // namespace Corrade::Containers
diff --git a/editor/app.hpp b/editor/app.hpp
index 6be1eed3..5a52ef58 100644
--- a/editor/app.hpp
+++ b/editor/app.hpp
@@ -13,7 +13,7 @@
#include <memory>
#include <Corrade/Containers/Pointer.h>
-#include <Corrade/Containers/OptionalStl.h>
+#include "compat/optional.hpp"
#include <Magnum/ImGuiIntegration/Context.h>
namespace floormat {
diff --git a/editor/editor.hpp b/editor/editor.hpp
index e40e695a..1093aa8d 100644
--- a/editor/editor.hpp
+++ b/editor/editor.hpp
@@ -10,7 +10,7 @@
#include <map>
#include <memory>
-#include <Corrade/Containers/OptionalStl.h>
+#include "compat/optional.hpp"
#include <Corrade/Containers/StringView.h>
namespace floormat {
diff --git a/external/corrade b/external/corrade
-Subproject d5cb9286d35e133435af69b0e196d837cb4c27a
+Subproject 0c88d8dc75a1151285fdd7c2d97ddb6aeadd499
diff --git a/src/precomp.hpp b/src/precomp.hpp
index 5ec01fe0..bdd5a380 100644
--- a/src/precomp.hpp
+++ b/src/precomp.hpp
@@ -35,7 +35,7 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/EnumSet.h>
-#include <Corrade/Containers/OptionalStl.h>
+#include "compat/optional.hpp"
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringStl.h>
#include <Corrade/Containers/StringStlHash.h>