From 457effabf51a527efa25c70ca39bdeb36ed3073b Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 22 Jun 2020 12:58:21 +1000 Subject: [PATCH] coords/ops: add ceil for coords --- coord/ops.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/coord/ops.hpp b/coord/ops.hpp index 33d172a0..fa96b53c 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -1400,10 +1400,26 @@ namespace cruft { } + //------------------------------------------------------------------------- + template < + typename K, + typename = std::enable_if_t< + is_coord_v && std::is_floating_point_v + > + > constexpr auto + ceil (K const &k) + { + K res {}; + for (std::size_t i = 0; i < K::elements; ++i) + res[i] = std::ceil (k[i]); + return res; + } + + ///------------------------------------------------------------------------ /// Return the fractional part of a real value. /// - /// This is an extraodinarily naive implementation. We avoid doing + /// This is an extraordinarily naive implementation. We avoid doing /// explicit casts here in the hope that floor and sub is more efficient /// (ie, keeps floats as floats in registers). template <