From 25b309fe83eece0bb794355a1c9f8fd820053c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 19 Apr 2025 11:15:03 +0200 Subject: [PATCH] Math: document why certain Range constructors are impossible to add. I think I tried this at least once in the past already, and failed the same way. So just document that it's missing to prevent me from wasting time on this again in the future. --- src/Magnum/Math/Range.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Magnum/Math/Range.h b/src/Magnum/Math/Range.h index 4afe39673..c7ebf415a 100644 --- a/src/Magnum/Math/Range.h +++ b/src/Magnum/Math/Range.h @@ -477,6 +477,9 @@ template class Range2D: public Range<2, T> { */ constexpr /*implicit*/ Range2D(const Containers::Pair, Vector<2, T>>& minmax) noexcept: Range<2, T>{minmax.first(), minmax.second()} {} + /* Cannot have a constructor from X and Y range as + Range2D{{0, 1}, {2, 3}} would then be ambiguous :/ */ + /** @copydoc Range(const Range&) */ template constexpr explicit Range2D(const Range2D& other) noexcept: Range<2, T>(other) {} @@ -609,6 +612,13 @@ template class Range3D: public Range<3, T> { /** @copydoc Range(const VectorType&, const VectorType&) */ constexpr /*implicit*/ Range3D(const Vector3& min, const Vector3& max) noexcept: Range<3, T>(min, max) {} + /* A Range2D constructor from X and Y range would cause + Range2D{{0, 1}, {2, 3}} to be ambiguous, thus for consistency + there's no Range3D constructor from a X, Y and Z range even though + it wouldn't be ambiguous. Similarly there is no constructor from a + XY and Z range because then Range3D{{}, {1, 2}} would be ambiguous + as well :/ */ + /** * @brief Construct a range from a pair of minimal and maximal coordinates * @m_since{2020,06}