From b5932c453742cdddfb7214540c55c962eb244a25 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 12 Dec 2016 17:06:55 +1100 Subject: [PATCH] extent: prefer constexpr functions over static variables --- extent.cpp | 13 ------------- extent.hpp | 4 ++-- extent.ipp | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/extent.cpp b/extent.cpp index 7c0b0b10..03b4becb 100644 --- a/extent.cpp +++ b/extent.cpp @@ -86,19 +86,6 @@ extent::empty (void) const } -/////////////////////////////////////////////////////////////////////////////// -template -const extent extent::MIN { 0 }; - - -//----------------------------------------------------------------------------- -template -const extent extent::MAX -{ - std::numeric_limits::max () -}; - - /////////////////////////////////////////////////////////////////////////////// template extent_range::extent_range (extent _target): diff --git a/extent.hpp b/extent.hpp index e983d74a..eeb804a6 100644 --- a/extent.hpp +++ b/extent.hpp @@ -51,8 +51,8 @@ namespace util { bool empty (void) const; - static const extent MAX; - static const extent MIN; + static constexpr extent max (void); + static constexpr extent min (void); }; template diff --git a/extent.ipp b/extent.ipp index 8c4ddecf..2f732d56 100644 --- a/extent.ipp +++ b/extent.ipp @@ -22,6 +22,7 @@ #define __UTIL_EXTENT_IPP #include +#include /////////////////////////////////////////////////////////////////////////////// @@ -76,3 +77,25 @@ util::extent::includes (point p) const return false; return true; } + + +/////////////////////////////////////////////////////////////////////////////// +template +constexpr +util::extent +util::extent::max (void) +{ + return extent { + std::numeric_limits::max () + }; +} + + +//----------------------------------------------------------------------------- +template +constexpr +util::extent +util::extent::min (void) +{ + return extent { 0 }; +}