region: constructors should be constexpr

This commit is contained in:
Danny Robson 2021-06-01 13:14:51 +10:00
parent 09d83b1b8a
commit aee3ee29d7
2 changed files with 9 additions and 29 deletions

View File

@ -18,33 +18,7 @@
using cruft::region;
//-----------------------------------------------------------------------------
template <size_t S, typename T>
cruft::region<S,T>::region (point_t _p,
extent_t _e):
p (_p),
e (_e)
{
CHECK_SANITY (*this);
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
cruft::region<S,T>::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 <size_t S, typename T>
typename cruft::region<S,T>::extent_t
cruft::region<S,T>::magnitude (void) const

View File

@ -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))
{ ; }
//---------------------------------------------------------------------