diff --git a/extent.cpp b/extent.cpp index a6bb2a47..df08e0eb 100644 --- a/extent.cpp +++ b/extent.cpp @@ -42,34 +42,6 @@ extent::extent (vector _v) } -/////////////////////////////////////////////////////////////////////////////// -template -T -extent::diameter (void) const -{ - return static_cast ( - std::sqrt ( - std::accumulate (std::begin (this->data), - std::end (this->data), - T {0}, - [] (auto a, auto b) { return a + b * b; }) - ) - ); -} - - -//----------------------------------------------------------------------------- -template -T -extent::area (void) const -{ - return std::accumulate (std::begin (this->data), - std::end (this->data), - T {1}, - std::multiplies ()); -} - - /////////////////////////////////////////////////////////////////////////////// template extent diff --git a/extent.hpp b/extent.hpp index ae220166..f700b04f 100644 --- a/extent.hpp +++ b/extent.hpp @@ -34,10 +34,11 @@ namespace util { extent () = default; explicit extent (vector); - T area (void) const; - T diameter (void) const; + constexpr T area (void) const; + constexpr T diameter (void) const; template + constexpr U aspect (void) const; template diff --git a/extent.ipp b/extent.ipp index 3e8cd83b..8c4ddecf 100644 --- a/extent.ipp +++ b/extent.ipp @@ -24,9 +24,40 @@ #include +/////////////////////////////////////////////////////////////////////////////// +template +constexpr +T +util::extent::diameter (void) const +{ + return static_cast ( + std::sqrt ( + std::accumulate (std::begin (this->data), + std::end (this->data), + T {0}, + [] (auto a, auto b) { return a + b * b; }) + ) + ); +} + + +/////////////////////////////////////////////////////////////////////////////// +template +constexpr +T +util::extent::area (void) const +{ + return std::accumulate (std::begin (this->data), + std::end (this->data), + T {1}, + std::multiplies ()); +} + + /////////////////////////////////////////////////////////////////////////////// template template +constexpr U util::extent::aspect (void) const {