summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio/integer_math.h
diff options
context:
space:
mode:
authorjapm48 <japm48@users.noreply.github.com>2020-04-10 23:35:30 +0200
committerMarcus Müller <marcus@hostalia.de>2020-04-11 02:47:13 +0200
commit2c767bb260a25b415e8c9c4b3ea37280b2127cec (patch)
tree911eefff59b6f791f814c341b8b923b7ff2e19fc /gnuradio-runtime/include/gnuradio/integer_math.h
parent60144c3e2fc6e36a9a1a6ebefbbebe41adc79c2c (diff)
boost: remove deprecated math/common_factor.hpp
Remove deprecation warning and prefer using std::{lcm,gcd} to Boost. Fixes #2712.
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/integer_math.h')
-rw-r--r--gnuradio-runtime/include/gnuradio/integer_math.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/gnuradio-runtime/include/gnuradio/integer_math.h b/gnuradio-runtime/include/gnuradio/integer_math.h
new file mode 100644
index 0000000000..15141049fa
--- /dev/null
+++ b/gnuradio-runtime/include/gnuradio/integer_math.h
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#ifndef INCLUDED_GR_INTEGER_MATH_H
+#define INCLUDED_GR_INTEGER_MATH_H
+
+#if (__cplusplus >= 201703L)
+
+// Prefer C++17 goodness.
+#include <numeric>
+#define GR_GCD std::gcd
+#define GR_LCM std::lcm
+
+#elif (BOOST_VERSION >= 105800)
+
+// Fallback: newer boost API (introduced in Boost 1.58.0).
+#include <boost/integer/common_factor_rt.hpp>
+#define GR_GCD boost::integer::gcd
+#define GR_LCM boost::integer::lcm
+
+#else
+
+// Last resort: old deprecated boost API.
+#include <boost/math/common_factor_rt.hpp>
+#define GR_GCD boost::math::gcd
+#define GR_LCM boost::math::lcm
+
+#endif /* __cplusplus >= 201703L */
+#endif /* INCLUDED_GR_INTEGER_MATH_H */