aboutsummaryrefslogtreecommitdiff
path: root/third-party/boost-math/include/boost/math/tools/utility.hpp
blob: 3e22865780f6cbe844a8731dc40b5104eef055ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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