summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-10-26 06:52:25 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-10-26 06:55:34 +0200
commit9c4e1586334b2e978d3993c97031d79f079f9650 (patch)
tree53b50a8947a2cfa5e7d0a41bfab33e4cd3408a50
parent4b8ffd3f999e2b8ac9f431fbd9b1235527762d7a (diff)
compat/util: introduce "iround" for round to integer
-rw-r--r--compat/util.hpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/compat/util.hpp b/compat/util.hpp
index 80ab4270..528ae1a8 100644
--- a/compat/util.hpp
+++ b/compat/util.hpp
@@ -3,6 +3,7 @@
#include "make-unique.hpp"
#include <memory>
+#include <cmath>
#include <utility>
#include <type_traits>
#include <thread>
@@ -21,6 +22,12 @@ template<typename t> using ptr = std::unique_ptr<t>;
# define DEFUN_WARN_UNUSED __attribute__((warn_unused_result))
#endif
+template<typename t>
+int iround(const t& val)
+{
+ return int(std::round(val));
+}
+
namespace detail {
template<typename n>