summaryrefslogtreecommitdiff
path: root/third-party/boost-math/include/boost/math/tools/utility.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'third-party/boost-math/include/boost/math/tools/utility.hpp')
-rw-r--r--third-party/boost-math/include/boost/math/tools/utility.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/third-party/boost-math/include/boost/math/tools/utility.hpp b/third-party/boost-math/include/boost/math/tools/utility.hpp
new file mode 100644
index 000000000000..3e22865780f6
--- /dev/null
+++ b/third-party/boost-math/include/boost/math/tools/utility.hpp
@@ -0,0 +1,69 @@
+// Copyright (c) 2024 Matt Borland
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_MATH_TOOLS_UTILITY
+#define BOOST_MATH_TOOLS_UTILITY
+
+#include <boost/math/tools/config.hpp>
+
+#ifndef BOOST_MATH_HAS_GPU_SUPPORT
+
+#include <utility>
+
+namespace boost {
+namespace math {
+
+template <typename T>
+constexpr T min BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)
+{
+ return (std::min)(a, b);
+}
+
+template <typename T>
+constexpr T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)
+{
+ return (std::max)(a, b);
+}
+
+template <typename T>
+void swap BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (T& a, T& b)
+{
+ return (std::swap)(a, b);
+}
+
+} // namespace math
+} // namespace boost
+
+#else
+
+namespace boost {
+namespace math {
+
+template <typename T>
+BOOST_MATH_GPU_ENABLED constexpr T min BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)
+{
+ return a < b ? a : b;
+}
+
+template <typename T>
+BOOST_MATH_GPU_ENABLED constexpr T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)
+{
+ return a > b ? a : b;
+}
+
+template <typename T>
+BOOST_MATH_GPU_ENABLED constexpr void swap BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (T& a, T& b)
+{
+ T t(a);
+ a = b;
+ b = t;
+}
+
+} // namespace math
+} // namespace boost
+
+#endif // BOOST_MATH_HAS_GPU_SUPPORT
+
+#endif // BOOST_MATH_TOOLS_UTILITY