diff --git a/include/hyprutils/math/Edges.hpp b/include/hyprutils/math/Edges.hpp index 304a3d6..8161be5 100644 --- a/include/hyprutils/math/Edges.hpp +++ b/include/hyprutils/math/Edges.hpp @@ -20,7 +20,7 @@ namespace Hyprutils::Math { CEdges() = default; CEdges(eEdges edges) : m_edges(edges) {} - CEdges(uint8_t edges) : m_edges(sc(edges)) {} + CEdges(uint8_t edges) : m_edges(Memory::sc(edges)) {} bool operator==(const CEdges& other) { return m_edges == other.m_edges; @@ -82,28 +82,28 @@ namespace Hyprutils::Math { * @param top The state the top edge should be set to. */ void setTop(bool top) { - m_edges = sc((m_edges & ~TOP) | (TOP * top)); + m_edges = Memory::sc((m_edges & ~TOP) | (TOP * top)); } /** * @param left The state the left edge should be set to. */ void setLeft(bool left) { - m_edges = sc((m_edges & ~LEFT) | (LEFT * left)); + m_edges = Memory::sc((m_edges & ~LEFT) | (LEFT * left)); } /** * @param bottom The state the bottom edge should be set to. */ void setBottom(bool bottom) { - m_edges = sc((m_edges & ~BOTTOM) | (BOTTOM * bottom)); + m_edges = Memory::sc((m_edges & ~BOTTOM) | (BOTTOM * bottom)); } /** * @param right The state the right edge should be set to. */ void setRight(bool right) { - m_edges = sc((m_edges & ~RIGHT) | (RIGHT * right)); + m_edges = Memory::sc((m_edges & ~RIGHT) | (RIGHT * right)); } eEdges m_edges = NONE; diff --git a/include/hyprutils/memory/Casts.hpp b/include/hyprutils/memory/Casts.hpp index 04078b7..6f76d63 100644 --- a/include/hyprutils/memory/Casts.hpp +++ b/include/hyprutils/memory/Casts.hpp @@ -1,28 +1,29 @@ #pragma once #include #include +namespace Hyprutils::Memory { + template + constexpr To sc(From&& from) noexcept { + return static_cast(std::forward(from)); + } -template -constexpr To sc(From&& from) noexcept { - return static_cast(std::forward(from)); -} + template + constexpr To cc(From&& from) noexcept { + return const_cast(std::forward(from)); + } -template -constexpr To cc(From&& from) noexcept { - return const_cast(std::forward(from)); -} + template + constexpr To rc(From&& from) noexcept { + return reinterpret_cast(std::forward(from)); + } -template -constexpr To rc(From&& from) noexcept { - return reinterpret_cast(std::forward(from)); -} + template + constexpr To dc(From&& from) { + return dynamic_cast(std::forward(from)); + } -template -constexpr To dc(From&& from) { - return dynamic_cast(std::forward(from)); -} - -template -constexpr To bc(const From& from) noexcept { - return std::bit_cast(from); + template + constexpr To bc(const From& from) noexcept { + return std::bit_cast(from); + } } \ No newline at end of file diff --git a/include/hyprutils/signal/Signal.hpp b/include/hyprutils/signal/Signal.hpp index 9e7885e..425c36f 100644 --- a/include/hyprutils/signal/Signal.hpp +++ b/include/hyprutils/signal/Signal.hpp @@ -37,7 +37,7 @@ namespace Hyprutils { if constexpr (sizeof...(Args) == 1) // NOLINTNEXTLINE: const is reapplied by handler invocation if required - emitInternal(cc(sc(&std::get<0>(argsTuple)))); + emitInternal(Memory::cc(Memory::sc(&std::get<0>(argsTuple)))); else emitInternal(&argsTuple); } @@ -94,9 +94,9 @@ namespace Hyprutils { if constexpr (sizeof...(Args) == 0) handler(); else if constexpr (sizeof...(Args) == 1) - handler(*sc...>>>*>(args)); + handler(*Memory::sc...>>>*>(args)); else - std::apply(handler, *sc...>*>(args)); + std::apply(handler, *Memory::sc...>*>(args)); }; } }; diff --git a/src/animation/BezierCurve.cpp b/src/animation/BezierCurve.cpp index ca8f21a..005d7a8 100644 --- a/src/animation/BezierCurve.cpp +++ b/src/animation/BezierCurve.cpp @@ -6,6 +6,7 @@ using namespace Hyprutils::Animation; using namespace Hyprutils::Math; +using namespace Hyprutils::Memory; void CBezierCurve::setup(const std::array& pVec) { // Avoid reallocations by reserving enough memory upfront diff --git a/src/math/Mat3x3.cpp b/src/math/Mat3x3.cpp index e592683..b91cf1e 100644 --- a/src/math/Mat3x3.cpp +++ b/src/math/Mat3x3.cpp @@ -7,6 +7,7 @@ #include using namespace Hyprutils::Math; +using namespace Hyprutils::Memory; static std::unordered_map transforms = { {HYPRUTILS_TRANSFORM_NORMAL, std::array{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}}, diff --git a/src/math/Region.cpp b/src/math/Region.cpp index d4ed602..5f9d1a6 100644 --- a/src/math/Region.cpp +++ b/src/math/Region.cpp @@ -3,6 +3,7 @@ #include using namespace Hyprutils::Math; +using namespace Hyprutils::Memory; constexpr const int64_t MAX_REGION_SIDE = 10000000; diff --git a/src/math/Vector2D.cpp b/src/math/Vector2D.cpp index 053379f..99f93d2 100644 --- a/src/math/Vector2D.cpp +++ b/src/math/Vector2D.cpp @@ -5,6 +5,7 @@ #include using namespace Hyprutils::Math; +using namespace Hyprutils::Memory; Hyprutils::Math::Vector2D::Vector2D(double xx, double yy) : x(xx), y(yy) { ; diff --git a/src/os/Process.cpp b/src/os/Process.cpp index a2442b4..3982b62 100644 --- a/src/os/Process.cpp +++ b/src/os/Process.cpp @@ -1,6 +1,7 @@ #include #include using namespace Hyprutils::OS; +using namespace Hyprutils::Memory; #include #include