70 lines · plain
1// Copyright (c) 2024 Matt Borland2// Use, modification and distribution are subject to the3// Boost Software License, Version 1.0. (See accompanying file4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_TOOLS_UTILITY7#define BOOST_MATH_TOOLS_UTILITY8 9#include <boost/math/tools/config.hpp>10 11#ifndef BOOST_MATH_HAS_GPU_SUPPORT12 13#include <utility>14 15namespace boost {16namespace math {17 18template <typename T>19constexpr T min BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)20{21 return (std::min)(a, b);22}23 24template <typename T>25constexpr T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)26{27 return (std::max)(a, b);28}29 30template <typename T>31void swap BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (T& a, T& b)32{33 return (std::swap)(a, b);34}35 36} // namespace math37} // namespace boost38 39#else40 41namespace boost {42namespace math {43 44template <typename T>45BOOST_MATH_GPU_ENABLED constexpr T min BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)46{ 47 return a < b ? a : b; 48}49 50template <typename T>51BOOST_MATH_GPU_ENABLED constexpr T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (const T& a, const T& b)52{ 53 return a > b ? a : b;54}55 56template <typename T>57BOOST_MATH_GPU_ENABLED constexpr void swap BOOST_MATH_PREVENT_MACRO_SUBSTITUTION (T& a, T& b)58{ 59 T t(a); 60 a = b; 61 b = t;62}63 64} // namespace math65} // namespace boost66 67#endif // BOOST_MATH_HAS_GPU_SUPPORT68 69#endif // BOOST_MATH_TOOLS_UTILITY70