diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2025-02-05 05:17:47 +0100 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2025-02-05 06:22:43 +0100 | 
| commit | ab13ab5f71a5b09de3b9526feca2ed7c564cee7e (patch) | |
| tree | 1699d8de2dd8217b7133b19c1a9878494a2854ca | |
| parent | 867a22c2a989b3f3a2bc47044226f5f9df6a59fd (diff) | |
switch to Corrade pair impl from stl
| -rw-r--r-- | editor/app.hpp | 2 | ||||
| -rw-r--r-- | editor/events.cpp | 5 | ||||
| -rw-r--r-- | editor/inspect.cpp | 1 | ||||
| -rw-r--r-- | entity/constraints.hpp | 7 | ||||
| -rw-r--r-- | entity/erased-constraints.cpp | 12 | ||||
| -rw-r--r-- | entity/erased-constraints.hpp | 3 | ||||
| -rw-r--r-- | test/entity.cpp | 6 | 
7 files changed, 19 insertions, 17 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index 1e990f6c..800d3d10 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -116,7 +116,7 @@ private:      void on_mouse_up_down(const mouse_button_event& event, bool is_down, const sdl2::EvClick& ev) noexcept override;      void on_mouse_scroll(const mouse_scroll_event& event, const sdl2::EvScroll& ev) noexcept override;      void on_key_up_down(const key_event& event, bool is_down, const sdl2::EvKey& ev) noexcept override; -    std::tuple<key, int> resolve_keybinding(int k, int mods); +    Pair<key, int> resolve_keybinding(int k, int mods);      void on_text_input_event(const text_input_event& event) noexcept override;      //bool on_text_editing_event(const text_editing_event& event) noexcept override;      void on_viewport_event(const Magnum::Math::Vector2<int>& size) noexcept override; diff --git a/editor/events.cpp b/editor/events.cpp index b25cdb7e..6aaf1e70 100644 --- a/editor/events.cpp +++ b/editor/events.cpp @@ -7,7 +7,8 @@  #include "keys.hpp"  #include "editor.hpp"  #include "compat/enum-bitset.hpp" -#include <tuple> +#include <Corrade/Containers/Pair.h> +#include <Corrade/Containers/StructuredBindings.h>  #include <Magnum/Platform/Sdl2Application.h>  #include <Magnum/ImGuiIntegration/Context.hpp> @@ -141,7 +142,7 @@ void app::on_mouse_scroll(const mouse_scroll_event& event, const sdl2::EvScroll&      while (false);  } -auto app::resolve_keybinding(int k_, int mods_) -> std::tuple<key, int> +auto app::resolve_keybinding(int k_, int mods_) -> Pair<key, int>  {      [[maybe_unused]] constexpr int CTRL  = kmod_ctrl;      [[maybe_unused]] constexpr int SHIFT = kmod_shift; diff --git a/editor/inspect.cpp b/editor/inspect.cpp index ab177fda..7302f8bd 100644 --- a/editor/inspect.cpp +++ b/editor/inspect.cpp @@ -5,6 +5,7 @@  #include "imgui-raii.hpp"  #include <cstdio>  #include <utility> +#include <Corrade/Containers/StructuredBindings.h>  #include <Corrade/Containers/ArrayView.h>  #include <Corrade/Containers/String.h>  #include <Magnum/Math/Functions.h> diff --git a/entity/constraints.hpp b/entity/constraints.hpp index 6a5587d5..0bfc2f15 100644 --- a/entity/constraints.hpp +++ b/entity/constraints.hpp @@ -1,8 +1,7 @@  #pragma once  #include "compat/limits.hpp"  #include "erased-constraints.hpp" -#include <type_traits> -#include <utility> +#include <cr/Pair.h>  #include <mg/Vector.h>  namespace floormat::entities::limit_detail { @@ -52,7 +51,7 @@ template<typename T> struct range      T max = limit_detail::limit_traits<T>::max();      constexpr operator erased_constraints::range() const noexcept; -    constexpr operator std::pair<T, T>() const noexcept; +    constexpr operator Pair<T, T>() const noexcept;      constexpr bool operator==(const range&) const noexcept = default;  }; @@ -125,7 +124,7 @@ template<typename T>  constexpr range<T>::operator erased_constraints::range() const noexcept  { return erased_range_from_range(min, max); } -template<typename T> constexpr range<T>::operator std::pair<T, T>() const noexcept { return { min, max }; } +template<typename T> constexpr range<T>::operator Pair<T, T>() const noexcept { return { min, max }; }  template<> struct range<String> { constexpr operator erased_constraints::range() const noexcept { return {}; } };  template<> struct range<StringView> { constexpr operator erased_constraints::range() const noexcept { return {}; } }; diff --git a/entity/erased-constraints.cpp b/entity/erased-constraints.cpp index 6e81820a..4cb915dc 100644 --- a/entity/erased-constraints.cpp +++ b/entity/erased-constraints.cpp @@ -2,17 +2,17 @@  #include "compat/assert.hpp"  #include <cmath>  #include <limits> -#include <Magnum/Magnum.h> -#include <Magnum/Math/Vector2.h> -#include <Magnum/Math/Vector3.h> -#include <Magnum/Math/Vector4.h> +#include <cr/Pair.h> +#include <mg/Vector2.h> +#include <mg/Vector3.h> +#include <mg/Vector4.h>  namespace floormat::entities::erased_constraints {  static_assert(sizeof(size_t) == sizeof(uintptr_t));  static_assert(sizeof(size_t) == sizeof(ptrdiff_t)); -template<typename T> std::pair<T, T> range::convert() const +template<typename T> Pair<T, T> range::convert() const  {      static_assert(sizeof(T) <= sizeof(min)); @@ -103,7 +103,7 @@ template<typename T> std::pair<T, T> range::convert() const      }  } -template<typename T> using pair2 = std::pair<T, T>; +template<typename T> using pair2 = Pair<T, T>;  template pair2<uint8_t> range::convert() const;  template pair2<uint16_t> range::convert() const; diff --git a/entity/erased-constraints.hpp b/entity/erased-constraints.hpp index af050bd6..64b469a3 100644 --- a/entity/erased-constraints.hpp +++ b/entity/erased-constraints.hpp @@ -1,4 +1,5 @@  #pragma once +#include <utility>  #include <Corrade/Containers/StringView.h>  #include <Magnum/Math/Vector4.h> @@ -25,7 +26,7 @@ struct range final      element min, max;      type_ type = type_none; -    template<typename T> std::pair<T, T> convert() const; +    template<typename T> Pair<T, T> convert() const;      friend bool operator==(const range& a, const range& b);  }; diff --git a/test/entity.cpp b/test/entity.cpp index 2bbdf29a..97ffd7a7 100644 --- a/test/entity.cpp +++ b/test/entity.cpp @@ -258,7 +258,7 @@ void test_range2()      const auto A = m_foo.erased();      auto r = A.get_range(&x);      auto i = r.convert<int>(); -    fm_assert(i.second == rʹ.max); +    fm_assert(i.second() == rʹ.max);  }  constexpr bool test_range3() @@ -277,8 +277,8 @@ void test_range4()      constexpr auto rʹ = f.get_range(f.range, TestAccessors{});      const auto A = f.erased();      const auto r = A.get_range(&x).convert<Vector2i>(); -    fm_assert(r.first == rʹ.min); -    fm_assert(r.second == rʹ.max); +    fm_assert(r.first() == rʹ.min); +    fm_assert(r.second() == rʹ.max);  }  constexpr bool test_enum_range()  | 
