summaryrefslogtreecommitdiff
path: root/indra/llcommon/lldefs.h
diff options
context:
space:
mode:
authorAnsariel Hiller <Ansariel@users.noreply.github.com>2024-10-02 19:53:17 +0200
committerGitHub <noreply@github.com>2024-10-02 20:53:17 +0300
commit13b91ad30633cb50275b1ca4a25522da23107e34 (patch)
tree313d1f20a077d1095aa6d40f9f7c4b5c1393ce3a /indra/llcommon/lldefs.h
parent1d045d7d11118835bb9d5421f71a1b3b9a61cb38 (diff)
Add a lot of more constexpr; use constants for accessing vector indices in vector math classes (#2766)
Diffstat (limited to 'indra/llcommon/lldefs.h')
-rw-r--r--indra/llcommon/lldefs.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index d4b063f88c..96b48c1532 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -176,7 +176,7 @@ constexpr U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 +
// the negative value to a huge positive value, producing the wrong answer!
// llless() specifically addresses that case.
template <typename T0, typename T1>
-inline bool llless(T0 d0, T1 d1)
+constexpr bool llless(T0 d0, T1 d1)
{
if constexpr (std::is_signed_v<T0> && ! std::is_signed_v<T1>)
{
@@ -204,13 +204,13 @@ inline bool llless(T0 d0, T1 d1)
// recursion tail
template <typename T>
-inline auto llmax(T data)
+constexpr auto llmax(T data)
{
return data;
}
template <typename T0, typename T1, typename... Ts>
-inline auto llmax(T0 d0, T1 d1, Ts... rest)
+constexpr auto llmax(T0 d0, T1 d1, Ts... rest)
{
auto maxrest = llmax(d1, rest...);
return llless(maxrest, d0)? d0 : maxrest;
@@ -218,20 +218,20 @@ inline auto llmax(T0 d0, T1 d1, Ts... rest)
// recursion tail
template <typename T>
-inline auto llmin(T data)
+constexpr auto llmin(T data)
{
return data;
}
template <typename T0, typename T1, typename... Ts>
-inline auto llmin(T0 d0, T1 d1, Ts... rest)
+constexpr auto llmin(T0 d0, T1 d1, Ts... rest)
{
auto minrest = llmin(d1, rest...);
return llless(d0, minrest) ? d0 : minrest;
}
template <typename A, typename MIN, typename MAX>
-inline A llclamp(A a, MIN minval, MAX maxval)
+constexpr A llclamp(A a, MIN minval, MAX maxval)
{
// The only troublesome case is if A is unsigned and either minval or
// maxval is both signed and negative. Casting a negative number to
@@ -262,13 +262,13 @@ inline A llclamp(A a, MIN minval, MAX maxval)
}
template <class LLDATATYPE>
-inline LLDATATYPE llclampf(LLDATATYPE a)
+constexpr LLDATATYPE llclampf(LLDATATYPE a)
{
return llmin(llmax(a, LLDATATYPE(0)), LLDATATYPE(1));
}
template <class LLDATATYPE>
-inline LLDATATYPE llclampb(LLDATATYPE a)
+constexpr LLDATATYPE llclampb(LLDATATYPE a)
{
return llmin(llmax(a, LLDATATYPE(0)), LLDATATYPE(255));
}