Skip to content

Commit 2261822

Browse files
committed
Formatting
Signed-off-by: Ian <[email protected]>
1 parent b697a3e commit 2261822

File tree

142 files changed

+881
-1153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+881
-1153
lines changed

include/ccmath/ext/clamp.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,40 @@
1010

1111
#pragma once
1212

13-
#include "ccmath/math/basic/min.hpp"
1413
#include "ccmath/math/basic/max.hpp"
14+
#include "ccmath/math/basic/min.hpp"
1515

1616
#include <type_traits>
1717

1818
namespace ccm::ext
1919
{
2020
/**
21-
* @brief Clamps a value between a minimum and maximum value.
22-
* @tparam T Type of the input and output.
23-
* @param v Value to clamp.
24-
* @param lo Minimum value.
25-
* @param hi Maximum value.
26-
* @return The clamped value.
27-
*/
28-
template<typename T>
29-
constexpr T clamp(T v, T lo = T{0}, T hi = T{1})
30-
{
31-
return ccm::min(ccm::max(v, lo), hi);
32-
}
21+
* @brief Clamps a value between a minimum and maximum value.
22+
* @tparam T Type of the input and output.
23+
* @param v Value to clamp.
24+
* @param lo Minimum value.
25+
* @param hi Maximum value.
26+
* @return The clamped value.
27+
*/
28+
template <typename T>
29+
constexpr T clamp(T v, T lo = T{0}, T hi = T{1})
30+
{
31+
return ccm::min(ccm::max(v, lo), hi);
32+
}
3333

3434
/**
35-
* @brief Clamps a value between a minimum and maximum value.
36-
* @tparam TVal Type of the input value.
37-
* @tparam TLow Type of the lower bound.
38-
* @tparam THigh Type of the upper bound.
39-
* @param v Value to clamp.
40-
* @param lo Minimum value.
41-
* @param hi Maximum value.
42-
* @return The clamped value.
43-
*/
44-
template<typename TVal, typename TLow, typename THigh>
45-
constexpr std::common_type_t<TVal, TLow, THigh> clamp(TVal v, TLow lo = TLow{0}, THigh hi = THigh{1})
46-
{
47-
return ccm::min(ccm::max(v, lo), hi);
48-
}
35+
* @brief Clamps a value between a minimum and maximum value.
36+
* @tparam TVal Type of the input value.
37+
* @tparam TLow Type of the lower bound.
38+
* @tparam THigh Type of the upper bound.
39+
* @param v Value to clamp.
40+
* @param lo Minimum value.
41+
* @param hi Maximum value.
42+
* @return The clamped value.
43+
*/
44+
template <typename TVal, typename TLow, typename THigh>
45+
constexpr std::common_type_t<TVal, TLow, THigh> clamp(TVal v, TLow lo = TLow{0}, THigh hi = THigh{1})
46+
{
47+
return ccm::min(ccm::max(v, lo), hi);
48+
}
4949
} // namespace ccm::ext

include/ccmath/ext/cubic.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ccm::ext
2424
* @param t The interpolation value.
2525
* @return The interpolated value.
2626
*/
27-
template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
27+
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
2828
constexpr T cubic(T y0, T y1, T y2, T y3, T t)
2929
{
3030
const T a0 = y3 - y2 - y0 + y1;

include/ccmath/ext/degrees.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace ccm::ext
2323
* @return Angle in degrees.
2424
*/
2525
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
26-
constexpr T degrees(T radians) noexcept
27-
{
28-
return (static_cast<T>(180) * radians) / ccm::numbers::pi_v<T>;
29-
}
26+
constexpr T degrees(T radians) noexcept
27+
{
28+
return (static_cast<T>(180) * radians) / ccm::numbers::pi_v<T>;
29+
}
3030
} // namespace ccm::ext

include/ccmath/ext/fract.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ namespace ccm::ext
2222
* @param x Value to get the fractional part of.
2323
* @return The fractional part of the input.
2424
*/
25-
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
26-
constexpr T fract(T x) noexcept
25+
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
26+
constexpr T fract(T x) noexcept
2727
{
28-
return x - ccm::floor(x);
28+
return x - ccm::floor(x);
2929
}
3030
} // namespace ccm::ext

include/ccmath/ext/lerp_smooth.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ namespace ccm::ext
2525
*
2626
* @warning Currently waiting on ccm::exp2 to be implemented. Till then this will NOT work.
2727
*/
28-
template<typename T>
29-
constexpr T lerp_smooth(T a, T b, T t, T h)
30-
{
31-
// ReSharper disable once CppRedundantParentheses
32-
return b + ((a - b) * ccm::exp2<T>(-t / h));
33-
}
28+
template <typename T>
29+
constexpr T lerp_smooth(T a, T b, T t, T h)
30+
{
31+
// ReSharper disable once CppRedundantParentheses
32+
return b + ((a - b) * ccm::exp2<T>(-t / h));
33+
}
3434
} // namespace ccm::ext

include/ccmath/ext/mix.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ namespace ccm::ext
2222
* @param a The value to use to interpolate between x and y.
2323
* @return The interpolated value.
2424
*/
25-
template <typename T>
26-
constexpr T mix(T x, T y, T a) noexcept
25+
template <typename T>
26+
constexpr T mix(T x, T y, T a) noexcept
2727
{
2828
// ReSharper disable once CppRedundantParentheses
2929
return (x * (1 - a)) + (y * a);
30-
}
30+
}
3131

3232
/**
3333
* @brief Performs a linear interpolation between x and y using a to weight between them.
@@ -41,7 +41,7 @@ namespace ccm::ext
4141
*/
4242
template <typename TStart, typename TEnd, typename TAplha>
4343
constexpr std::common_type_t<TStart, TEnd, TAplha> mix(TStart x, TEnd y, TAplha a) noexcept
44-
{
45-
return (x * (1 - a)) + (y * a);
46-
}
44+
{
45+
return (x * (1 - a)) + (y * a);
46+
}
4747
} // namespace ccm::ext

include/ccmath/ext/normalize.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ccm::ext
2424
* @param max The maximum value of the range.
2525
* @return The normalized value.
2626
*/
27-
template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
27+
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
2828
constexpr T normalize(T value, T min = T(0), T max = T(1))
2929
{
3030
return ext::clamp((value - min) / (max - min), static_cast<T>(0), static_cast<T>(1));

include/ccmath/ext/ping_pong.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ namespace ccm::ext
2727
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
2828
constexpr T ping_pong(T a, T b) noexcept
2929
{
30-
if (b == 0)
31-
{
32-
return T(0);
33-
}
30+
if (b == 0) { return T(0); }
3431

3532
return ccm::abs((ccm::ext::fract((a - b) / (b * 2.0)) * b * 2.0) - b);
36-
3733
}
3834
} // namespace ccm::ext

include/ccmath/ext/smoothstep.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616

1717
namespace ccm::ext
1818
{
19-
/**
20-
* @brief Smooth hermite interpolation.
21-
* @tparam T Type of the input and output.
22-
* @param edge0 Lower edge.
23-
* @param edge1 Upper edge.
24-
* @param x Value to interpolate.
25-
* @return The interpolated value.
26-
*/
27-
template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
28-
constexpr T smoothstep(T edge0, T edge1, T x)
29-
{
19+
/**
20+
* @brief Smooth hermite interpolation.
21+
* @tparam T Type of the input and output.
22+
* @param edge0 Lower edge.
23+
* @param edge1 Upper edge.
24+
* @param x Value to interpolate.
25+
* @return The interpolated value.
26+
*/
27+
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
28+
constexpr T smoothstep(T edge0, T edge1, T x)
29+
{
3030
// Scale, bias and saturate x to 0..1 range
31-
x = ccm::ext::clamp((x - edge0) / (edge1 - edge0));
32-
// Evaluate polynomial
33-
return x * x * (static_cast<T>(3) - static_cast<T>(2) * x);
34-
}
31+
x = ccm::ext::clamp((x - edge0) / (edge1 - edge0));
32+
// Evaluate polynomial
33+
return x * x * (static_cast<T>(3) - static_cast<T>(2) * x);
34+
}
3535
} // namespace ccm::ext

include/ccmath/internal/config/arch/check_simd_support.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@
117117
#define CCMATH_HAS_SIMD_NEON 1
118118
#endif
119119

120-
121-
122120
// ARM Scalable Vector Extension (SVE)
123121
/* TODO: At some point add proper SVE support.
124122
#if defined(__ARM_FEATURE_SVE)

include/ccmath/internal/config/arch/targets/aarch64.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
// VS defines: _M_ARM
1717
// GCC defines: __arm__
1818
#if defined(_M_ARM) || defined(__arm__)
19-
#define CCM_TARGET_ARCH_AARCH32 3
19+
#define CCM_TARGET_ARCH_AARCH32 3
2020
#define CCM_TARGET_ARCH_IS_ARM_BASED 1
2121
#endif
2222

2323
/// ARM64 Architecture
2424
// VS defines: _M_ARM64
2525
// GCC defines: __aarch64__
2626
#if defined(_M_ARM64) || defined(__aarch64__)
27-
#define CCM_TARGET_ARCH_AARCH64 4
27+
#define CCM_TARGET_ARCH_AARCH64 4
2828
#define CCM_TARGET_ARCH_IS_ARM_BASED 1
2929
#endif
30-
31-

include/ccmath/internal/config/arch/targets/x86_64.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
// VS defines: _M_IX86
1717
// GCC defines: i386, __i386, __i386__
1818
#if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(i386)
19-
#define CCMATH_TARGET_ARCH_X86 1
19+
#define CCMATH_TARGET_ARCH_X86 1
2020
#define CCMATH_TARGET_ARCH_IS_X86_BASED 1
2121
#endif
2222

2323
/// x86_64 Architecture
2424
// VS defines: _M_X64 and _M_AMD64
2525
// GCC defines: __amd64__, __amd64, __x86_64__, and __x86_64
2626
#if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
27-
#define CCMATH_TARGET_ARCH_X64 1
27+
#define CCMATH_TARGET_ARCH_X64 1
2828
#define CCMATH_TARGET_ARCH_IS_X86_BASED 1
2929
#endif

include/ccmath/internal/config/builtin/bit_cast_support.hpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@
2323
/// - MSVC 19.27+
2424

2525
// GCC 11.1+ has __builtin_bit_cast
26-
#if defined(__GNUC__) && (__GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1)) && !defined(__clang__) && !defined(__NVCOMPILER) && !defined(__NVCOMPILER_LLVM__) && !defined(__CUDACC__)
27-
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
28-
#define CCMATH_HAS_BUILTIN_BIT_CAST
29-
#endif
26+
#if defined(__GNUC__) && (__GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1)) && !defined(__clang__) && !defined(__NVCOMPILER) && \
27+
!defined(__NVCOMPILER_LLVM__) && !defined(__CUDACC__)
28+
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
29+
#define CCMATH_HAS_BUILTIN_BIT_CAST
30+
#endif
3031
#endif
3132

3233
// Clang 9.0.0+ has __builtin_bit_cast
33-
#if defined(__clang__) && !defined(__apple_build_version__) && __clang_major__ >= 9
34-
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
35-
#define CCMATH_HAS_BUILTIN_BIT_CAST
36-
#endif
34+
#if defined(__clang__) && !defined(__apple_build_version__) && __clang_major__ >= 9
35+
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
36+
#define CCMATH_HAS_BUILTIN_BIT_CAST
37+
#endif
3738
#endif
3839

3940
// Apple Clang 9.0.0+ has __builtin_bit_cast
@@ -53,10 +54,10 @@
5354
#endif
5455

5556
// DPC++ 2021.1.2+ has __builtin_bit_cast
56-
#if (defined(SYCL_LANGUAGE_VERSION) || defined(__INTEL_LLVM_COMPILER)) && (__INTEL_LLVM_COMPILER >= 20210102)
57-
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
58-
#define CCMATH_HAS_BUILTIN_BIT_CAST
59-
#endif
57+
#if (defined(SYCL_LANGUAGE_VERSION) || defined(__INTEL_LLVM_COMPILER)) && (__INTEL_LLVM_COMPILER >= 20210102)
58+
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
59+
#define CCMATH_HAS_BUILTIN_BIT_CAST
60+
#endif
6061
#endif
6162

6263
// NVIDIA HPC 22.7+ has __builtin_bit_cast (Maybe lower? This is as low as I can test currently)
@@ -68,7 +69,7 @@
6869

6970
// MSVC 19.27+ has __builtin_bit_cast
7071
#if defined(_MSC_VER) && !defined(__clang__) && (_MSC_VER >= 1927)
71-
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
72-
#define CCMATH_HAS_BUILTIN_BIT_CAST
73-
#endif
72+
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
73+
#define CCMATH_HAS_BUILTIN_BIT_CAST
74+
#endif
7475
#endif

include/ccmath/internal/config/builtin/copysign_support.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
// Clang 5.0.0+ has constexpr __builtin_copysign that DOES allow static_assert.
3434
#if defined(CCMATH_COMPILER_CLANG) && CCMATH_COMPILER_CLANG_VER_MAJOR >= 5
35-
#ifndef CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
36-
#define CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
37-
#endif
35+
#ifndef CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
36+
#define CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
37+
#endif
3838
#endif
3939

4040
// Clang-CL 5.0.0+ has constexpr __builtin_copysign that DOES allow static_assert.
@@ -55,14 +55,14 @@
5555

5656
// DPC++ 2021.1.2+ has constexpr __builtin_copysign that DOES allow static_assert.
5757
#if defined(CCMATH_COMPILER_INTEL) && CCMATH_COMPILER_INTEL_VER >= 20210102
58-
#ifndef CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
59-
#define CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
60-
#endif
58+
#ifndef CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
59+
#define CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
60+
#endif
6161
#endif
6262

6363
// NVIDIA HPC 24.1+ has constexpr __builtin_copysign that DOES allow static_assert.
6464
#if defined(CCMATH_COMPILER_NVIDIA) && CCMATH_COMPILER_NVIDIA_VER_MAJOR >= 24 && CCMATH_COMPILER_NVIDIA_VER_MINOR >= 1
65-
#ifndef CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
66-
#define CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
67-
#endif
65+
#ifndef CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
66+
#define CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN
67+
#endif
6868
#endif

include/ccmath/internal/config/platform/android.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#endif
2828

2929
#define CCM_TARGET_PLATFORM_ANDROID 1
30-
#define CCM_TARGET_PLATFORM_LINUX 1
31-
#define CCM_TARGET_PLATFORM_UNIX 1
32-
#define CCM_TARGET_PLATFORM_POSIX 1
30+
#define CCM_TARGET_PLATFORM_LINUX 1
31+
#define CCM_TARGET_PLATFORM_UNIX 1
32+
#define CCM_TARGET_PLATFORM_POSIX 1
3333

3434
#ifdef CCM_TARGET_PLATFORM_MOBILE
3535
#undef CCM_TARGET_PLATFORM_MOBILE

include/ccmath/internal/config/platform/darwin.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#pragma once
1212

13-
1413
#if defined(__APPLE__) || defined(__MACH__)
1514
#include <TargetConditionals.h>
1615

@@ -35,7 +34,7 @@
3534
#ifdef CCM_TARGET_PLATFORM_IPHONE
3635
#undef CCM_TARGET_PLATFORM_IPHONE
3736
#endif
38-
#define CCM_TARGET_PLATFORM_IPHONE 1
37+
#define CCM_TARGET_PLATFORM_IPHONE 1
3938
#define CCM_TARGET_POSIX_THREADS_AVAILABLE 1
4039

4140
#ifdef CCM_TARGET_PLATFORM_MOBILE
@@ -58,8 +57,8 @@
5857
#undef CCM_TARGET_PLATFORM_POSIX
5958
#endif
6059

61-
#define CCM_TARGET_PLATFORM_OSX 1
62-
#define CCM_TARGET_PLATFORM_UNIX 1
60+
#define CCM_TARGET_PLATFORM_OSX 1
61+
#define CCM_TARGET_PLATFORM_UNIX 1
6362
#define CCM_TARGET_PLATFORM_POSIX 1
6463

6564
#ifdef CCM_TARGET_PLATFORM_DESKTOP

include/ccmath/internal/config/platform/linux.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#endif
2525

2626
#define CCM_TARGET_PLATFORM_LINUX 1
27-
#define CCM_TARGET_PLATFORM_UNIX 1
27+
#define CCM_TARGET_PLATFORM_UNIX 1
2828
#define CCM_TARGET_PLATFORM_POSIX 1
2929

3030
#ifdef CCM_TARGET_PLATFORM_DESKTOP

0 commit comments

Comments
 (0)