From 13b91ad30633cb50275b1ca4a25522da23107e34 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Wed, 2 Oct 2024 19:53:17 +0200 Subject: Add a lot of more constexpr; use constants for accessing vector indices in vector math classes (#2766) --- indra/llcommon/lldefs.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/lldefs.h') 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 -inline bool llless(T0 d0, T1 d1) +constexpr bool llless(T0 d0, T1 d1) { if constexpr (std::is_signed_v && ! std::is_signed_v) { @@ -204,13 +204,13 @@ inline bool llless(T0 d0, T1 d1) // recursion tail template -inline auto llmax(T data) +constexpr auto llmax(T data) { return data; } template -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 -inline auto llmin(T data) +constexpr auto llmin(T data) { return data; } template -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 -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 -inline LLDATATYPE llclampf(LLDATATYPE a) +constexpr LLDATATYPE llclampf(LLDATATYPE a) { return llmin(llmax(a, LLDATATYPE(0)), LLDATATYPE(1)); } template -inline LLDATATYPE llclampb(LLDATATYPE a) +constexpr LLDATATYPE llclampb(LLDATATYPE a) { return llmin(llmax(a, LLDATATYPE(0)), LLDATATYPE(255)); } -- cgit v1.2.3