From aee3ee29d71d15579fc76104b2ee6726c92206a2 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 1 Jun 2021 13:14:51 +1000 Subject: [PATCH] region: constructors should be constexpr --- region.cpp | 28 +--------------------------- region.hpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/region.cpp b/region.cpp index ce49fcd2..f864ec20 100644 --- a/region.cpp +++ b/region.cpp @@ -18,33 +18,7 @@ using cruft::region; -//----------------------------------------------------------------------------- -template -cruft::region::region (point_t _p, - extent_t _e): - p (_p), - e (_e) -{ - CHECK_SANITY (*this); -} - - -//----------------------------------------------------------------------------- -template -cruft::region::region (point_t _a, - point_t _b): - region (_a, extent_t { _b - _a }) -{ - // This check must allow for zero area (but non-zero dimension) regions. - // Some code paths need to support this degenerate case. It's ugly but - // simplifies generalisation. eg, vertical linear bezier curves. - CHECK (all (_a <= _b)); - - CHECK_SANITY (*this); -} - - -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// template typename cruft::region::extent_t cruft::region::magnitude (void) const diff --git a/region.hpp b/region.hpp index 042def9d..9e6bb65d 100644 --- a/region.hpp +++ b/region.hpp @@ -37,8 +37,14 @@ namespace cruft { //--------------------------------------------------------------------- region () = default; - region (point_t, extent_t); - region (point_t, point_t); + constexpr region (point_t _p, extent_t _e) + : p (_p) + , e (_e) + { ; } + + constexpr region (point_t _a, point_t _b) + : region (_a, extent_t (_b - _a)) + { ; } //---------------------------------------------------------------------