Panagiotis Christopoulos Charitos 6 年之前
父節點
當前提交
b8c90297ab
共有 3 個文件被更改,包括 14 次插入8 次删除
  1. 7 3
      src/anki/math/Functions.h
  2. 6 4
      src/anki/util/StdTypes.h
  3. 1 1
      tests/util/SparseArray.cpp

+ 7 - 3
src/anki/math/Functions.h

@@ -107,9 +107,7 @@ inline T modf(T x, T& intPart)
 
 /// The same as abs/fabs. For ints and floats.
 template<typename T,
-	typename std::enable_if<std::is_floating_point<T>::value
-								|| (std::is_integral<T>::value && std::is_signed<T>::value),
-		int>::type = 0>
+	ANKI_ENABLE(std::is_floating_point<T>::value || (std::is_integral<T>::value && std::is_signed<T>::value))>
 inline T absolute(const T f)
 {
 	return (f < T(0)) ? -f : f;
@@ -121,6 +119,12 @@ inline T pow(const T x, const T power)
 	return T(std::pow(x, power));
 }
 
+template<typename T>
+inline T log2(const T x)
+{
+	return T(std::log2(x));
+}
+
 template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
 inline Bool isZero(const T f, const T e = EPSILON)
 {

+ 6 - 4
src/anki/util/StdTypes.h

@@ -260,14 +260,16 @@ static constexpr long double operator""_ns(long double x)
 	using _SelfRef = decltype(((_selfFn*)0)()); \
 	using Self = std::remove_reference<_SelfRef>::type;
 
+#if ANKI_COMPILER_GCC_COMPATIBLE
 /// Redefine the sizeof because the default returns size_t and that will require casting when used with U32 for example.
-#define _ANKI_SIZEOF(type) ((anki::U32)(sizeof(type)))
-#define sizeof(type) _ANKI_SIZEOF(type)
+#	define _ANKI_SIZEOF(type) ((anki::U32)(sizeof(type)))
+#	define sizeof(type) _ANKI_SIZEOF(type)
 
 /// Redefine the alignof because the default returns size_t and that will require casting when used with U32 for
 /// example.
-#define _ANKI_ALIGNOF(type) ((anki::U32)(alignof(type)))
-#define alignof(type) _ANKI_ALIGNOF(type)
+#	define _ANKI_ALIGNOF(type) ((anki::U32)(alignof(type)))
+#	define alignof(type) _ANKI_ALIGNOF(type)
+#endif
 /// @}
 
 } // end namespace anki

+ 1 - 1
tests/util/SparseArray.cpp

@@ -324,7 +324,7 @@ ANKI_TEST(Util, SparseArrayBench)
 	StlMap stdMap(10, std::hash<int>(), std::equal_to<int>(), allocStl);
 
 	using AkMap = SparseArray<int, U32>;
-	AkMap akMap(256, log2(256), 0.90f);
+	AkMap akMap(256, log2(256.0f), 0.90f);
 
 	HighRezTimer timer;