Removed BX_STATIC_ASSERT. Not needed in C++17.

This commit is contained in:
Бранимир Караџић
2024-12-07 22:51:31 -08:00
parent 57a4fb1246
commit 3e9604c743
16 changed files with 48 additions and 51 deletions

View File

@@ -21,8 +21,8 @@
BX_ERROR_USE_TEMP_WHEN_NULL(_ptr); \
bx::ErrorScope bxErrorScope(const_cast<bx::Error*>(&tmpError), "" __VA_ARGS__)
#define BX_ERROR_RESULT(_err, _code) \
BX_STATIC_ASSERT(_code != 0, "ErrorCode 0 is reserved!"); \
#define BX_ERROR_RESULT(_err, _code) \
static_assert(_code != 0, "ErrorCode 0 is reserved!"); \
static constexpr bx::ErrorResult _err = { _code }
namespace bx

View File

@@ -142,7 +142,7 @@ namespace bx
template<typename HashT, typename Ty>
inline uint32_t hash(const Ty& _data)
{
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
return hash<HashT>(&_data, sizeof(Ty) );
}

View File

@@ -668,28 +668,28 @@ namespace bx
template<typename Ty>
inline BX_CONSTEXPR_FUNC uint8_t findFirstSet(Ty _val)
{
BX_STATIC_ASSERT(isInteger<Ty>(), "Type Ty must be of integer type!");
static_assert(isInteger<Ty>(), "Type Ty must be of integer type!");
return Ty(0) == _val ? uint8_t(0) : countTrailingZeros<Ty>(_val) + 1;
}
template<typename Ty>
inline BX_CONSTEXPR_FUNC uint8_t findLastSet(Ty _val)
{
BX_STATIC_ASSERT(isInteger<Ty>(), "Type Ty must be of integer type!");
static_assert(isInteger<Ty>(), "Type Ty must be of integer type!");
return Ty(0) == _val ? uint8_t(0) : sizeof(Ty)*8 - countLeadingZeros<Ty>(_val);
}
template<typename Ty>
inline BX_CONSTEXPR_FUNC uint8_t ceilLog2(Ty _a)
{
BX_STATIC_ASSERT(isInteger<Ty>(), "Type Ty must be of integer type!");
static_assert(isInteger<Ty>(), "Type Ty must be of integer type!");
return Ty(_a) < Ty(1) ? Ty(0) : sizeof(Ty)*8 - countLeadingZeros<Ty>(_a - 1);
}
template<typename Ty>
inline BX_CONSTEXPR_FUNC uint8_t floorLog2(Ty _a)
{
BX_STATIC_ASSERT(isInteger<Ty>(), "Type Ty must be of integer type!");
static_assert(isInteger<Ty>(), "Type Ty must be of integer type!");
return Ty(_a) < Ty(1) ? Ty(0) : sizeof(Ty)*8 - 1 - countLeadingZeros<Ty>(_a);
}

View File

@@ -276,7 +276,7 @@ namespace bx
inline int32_t read(ReaderI* _reader, Ty& _value, Error* _err)
{
BX_ERROR_SCOPE(_err);
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
return _reader->read(&_value, sizeof(Ty), _err);
}
@@ -284,7 +284,7 @@ namespace bx
inline int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err)
{
BX_ERROR_SCOPE(_err);
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
Ty value;
int32_t result = _reader->read(&value, sizeof(Ty), _err);
_value = toHostEndian(value, _fromLittleEndian);
@@ -322,7 +322,7 @@ namespace bx
inline int32_t write(WriterI* _writer, const Ty& _value, Error* _err)
{
BX_ERROR_SCOPE(_err);
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
return _writer->write(&_value, sizeof(Ty), _err);
}
@@ -347,7 +347,7 @@ namespace bx
inline int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err)
{
BX_ERROR_SCOPE(_err);
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
Ty value = toLittleEndian(_value);
int32_t result = _writer->write(&value, sizeof(Ty), _err);
return result;
@@ -363,7 +363,7 @@ namespace bx
inline int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err)
{
BX_ERROR_SCOPE(_err);
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
Ty value = toBigEndian(_value);
int32_t result = _writer->write(&value, sizeof(Ty), _err);
return result;
@@ -414,7 +414,7 @@ namespace bx
inline int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err)
{
BX_ERROR_SCOPE(_err);
BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
static_assert(isTriviallyCopyable<Ty>() );
return peek(_reader, &_value, sizeof(Ty), _err);
}

View File

@@ -44,28 +44,28 @@ namespace bx
template<typename Ty>
inline void quickSort(void* _data, uint32_t _num, uint32_t _stride, const ComparisonFn _fn)
{
BX_STATIC_ASSERT(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
static_assert(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
quickSort(_data, _num, _stride, _fn);
}
template<typename Ty>
inline void quickSort(Ty* _data, uint32_t _num, const ComparisonFn _fn)
{
BX_STATIC_ASSERT(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
static_assert(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
quickSort( (void*)_data, _num, sizeof(Ty), _fn);
}
template<typename Ty>
inline uint32_t unique(void* _data, uint32_t _num, uint32_t _stride, const ComparisonFn _fn)
{
BX_STATIC_ASSERT(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
static_assert(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
return unique(_data, _num, _stride, _fn);
}
template<typename Ty>
inline uint32_t unique(Ty* _data, uint32_t _num, const ComparisonFn _fn)
{
BX_STATIC_ASSERT(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
static_assert(isTriviallyMoveAssignable<Ty>(), "Element type must be trivially move assignable");
return unique( (void*)_data, _num, sizeof(Ty), _fn);
}
@@ -189,7 +189,7 @@ done:
template <typename Ty>
inline void radixSort(uint32_t* _keys, uint32_t* _tempKeys, Ty* _values, Ty* _tempValues, uint32_t _size)
{
BX_STATIC_ASSERT(isTriviallyMoveAssignable<Ty>(), "Sort element type must be trivially move assignable");
static_assert(isTriviallyMoveAssignable<Ty>(), "Sort element type must be trivially move assignable");
uint32_t* keys = _keys;
uint32_t* tempKeys = _tempKeys;
@@ -325,7 +325,7 @@ done:
template <typename Ty>
inline void radixSort(uint64_t* _keys, uint64_t* _tempKeys, Ty* _values, Ty* _tempValues, uint32_t _size)
{
BX_STATIC_ASSERT(isTriviallyMoveAssignable<Ty>(), "Sort element type must be trivially move assignable");
static_assert(isTriviallyMoveAssignable<Ty>(), "Sort element type must be trivially move assignable");
uint64_t* keys = _keys;
uint64_t* tempKeys = _tempKeys;

View File

@@ -591,7 +591,7 @@ namespace bx
template<typename Ty>
inline constexpr Ty&& forward(RemoveReferenceType<Ty>&& _a)
{
BX_STATIC_ASSERT(!isLvalueReference<Ty>(), "Can not forward an Rvalue as an Lvalue.");
static_assert(!isLvalueReference<Ty>(), "Can not forward an Rvalue as an Lvalue.");
return static_cast<Ty&&>(_a);
}

View File

@@ -88,9 +88,6 @@
///
#define BX_CONSTEXPR_FUNC constexpr BX_CONST_FUNC
///
#define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, "" __VA_ARGS__)
///
#define BX_ALIGN_DECL_16(_decl) BX_ALIGN_DECL(16, _decl)
#define BX_ALIGN_DECL_256(_decl) BX_ALIGN_DECL(256, _decl)

View File

@@ -627,7 +627,7 @@ namespace bx
bool intersect(const Ray& _ray, const Capsule& _capsule, Hit* _hit)
{
BX_STATIC_ASSERT(sizeof(Capsule) == sizeof(Cylinder) );
static_assert(sizeof(Capsule) == sizeof(Cylinder) );
return intersect(_ray, *( (const Cylinder*)&_capsule), true, _hit);
}

View File

@@ -53,7 +53,7 @@ namespace bx
easeInOutBounce,
easeOutInBounce,
};
BX_STATIC_ASSERT(BX_COUNTOF(s_easeFunc) == Easing::Count);
static_assert(BX_COUNTOF(s_easeFunc) == Easing::Count);
EaseFn getEaseFunc(Easing::Enum _enum)
{

View File

@@ -494,7 +494,7 @@ namespace bx
FileReader::FileReader()
{
BX_STATIC_ASSERT(sizeof(FileReaderImpl) <= sizeof(m_internal) );
static_assert(sizeof(FileReaderImpl) <= sizeof(m_internal) );
BX_PLACEMENT_NEW(m_internal, FileReaderImpl)(NULL);
}
@@ -530,7 +530,7 @@ namespace bx
FileWriter::FileWriter()
{
BX_STATIC_ASSERT(sizeof(FileWriterImpl) <= sizeof(m_internal) );
static_assert(sizeof(FileWriterImpl) <= sizeof(m_internal) );
BX_PLACEMENT_NEW(m_internal, FileWriterImpl)(NULL);
}
@@ -711,7 +711,7 @@ namespace bx
DirectoryReader::DirectoryReader()
{
BX_STATIC_ASSERT(sizeof(DirectoryReaderImpl) <= sizeof(m_internal) );
static_assert(sizeof(DirectoryReaderImpl) <= sizeof(m_internal) );
BX_PLACEMENT_NEW(m_internal, DirectoryReaderImpl);
}

View File

@@ -43,7 +43,7 @@ static const uint32_t s_crcTableIeee[] =
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
};
BX_STATIC_ASSERT(BX_COUNTOF(s_crcTableIeee) == 256);
static_assert(BX_COUNTOF(s_crcTableIeee) == 256);
static const uint32_t s_crcTableCastagnoli[] =
{
@@ -80,7 +80,7 @@ static const uint32_t s_crcTableCastagnoli[] =
0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e,
0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351,
};
BX_STATIC_ASSERT(BX_COUNTOF(s_crcTableCastagnoli) == 256);
static_assert(BX_COUNTOF(s_crcTableCastagnoli) == 256);
static const uint32_t s_crcTableKoopman[] =
{
@@ -117,7 +117,7 @@ static const uint32_t s_crcTableKoopman[] =
0xcc9b9520, 0x5a0e51ea, 0x37d3ace9, 0xa1466823, 0xec6856ef, 0x7afd9225, 0x17206f26, 0x81b5abec,
0x8d7c12be, 0x1be9d674, 0x76342b77, 0xe0a1efbd, 0xad8fd171, 0x3b1a15bb, 0x56c7e8b8, 0xc0522c72,
};
BX_STATIC_ASSERT(BX_COUNTOF(s_crcTableKoopman) == 256);
static_assert(BX_COUNTOF(s_crcTableKoopman) == 256);
static const uint32_t* s_crcTable[] =
{
@@ -125,7 +125,7 @@ static const uint32_t* s_crcTable[] =
s_crcTableCastagnoli,
s_crcTableKoopman,
};
BX_STATIC_ASSERT(BX_COUNTOF(s_crcTable) == HashCrc32::Count);
static_assert(BX_COUNTOF(s_crcTable) == HashCrc32::Count);
void HashCrc32::begin(Enum _type)
{
@@ -270,7 +270,7 @@ struct HashMurmur2APod
m_hash ^= m_hash >> 15;
}
};
BX_STATIC_ASSERT(sizeof(HashMurmur2A) == sizeof(HashMurmur2APod) );
static_assert(sizeof(HashMurmur2A) == sizeof(HashMurmur2APod) );
void HashMurmur2A::add(const void* _data, int32_t _len)
{
@@ -334,7 +334,7 @@ struct HashMurmur3Pod
m_hash ^= m_hash >> 16;
}
};
BX_STATIC_ASSERT(sizeof(HashMurmur3) == sizeof(HashMurmur3Pod) );
static_assert(sizeof(HashMurmur3) == sizeof(HashMurmur3Pod) );
void HashMurmur3::add(const void* _data, int32_t _len)
{

View File

@@ -44,7 +44,7 @@ namespace bx
Mutex::Mutex()
{
BX_STATIC_ASSERT(sizeof(int32_t) <= sizeof(m_internal) );
static_assert(sizeof(int32_t) <= sizeof(m_internal) );
uint32_t* futex = (uint32_t*)m_internal;
*futex = State::Unlocked;
@@ -123,7 +123,7 @@ namespace bx
Mutex::Mutex()
{
BX_STATIC_ASSERT(sizeof(pthread_mutex_t) <= sizeof(m_internal) );
static_assert(sizeof(pthread_mutex_t) <= sizeof(m_internal) );
pthread_mutexattr_t attr;

View File

@@ -54,7 +54,7 @@ namespace bx
#if BX_CRT_NONE
Semaphore::Semaphore()
{
BX_STATIC_ASSERT(sizeof(SemaphoreInternal) <= sizeof(m_internal) );
static_assert(sizeof(SemaphoreInternal) <= sizeof(m_internal) );
}
Semaphore::~Semaphore()
@@ -77,7 +77,7 @@ namespace bx
Semaphore::Semaphore()
{
BX_STATIC_ASSERT(sizeof(SemaphoreInternal) <= sizeof(m_internal) );
static_assert(sizeof(SemaphoreInternal) <= sizeof(m_internal) );
SemaphoreInternal* si = (SemaphoreInternal*)m_internal;
si->m_handle = dispatch_semaphore_create(0);
@@ -137,7 +137,7 @@ namespace bx
Semaphore::Semaphore()
{
BX_STATIC_ASSERT(sizeof(SemaphoreInternal) <= sizeof(m_internal) );
static_assert(sizeof(SemaphoreInternal) <= sizeof(m_internal) );
SemaphoreInternal* si = (SemaphoreInternal*)m_internal;
si->m_count = 0;

View File

@@ -96,7 +96,7 @@ namespace bx
, m_exitCode(kExitSuccess)
, m_running(false)
{
BX_STATIC_ASSERT(sizeof(ThreadInternal) <= sizeof(m_internal) );
static_assert(sizeof(ThreadInternal) <= sizeof(m_internal) );
ThreadInternal* ti = (ThreadInternal*)m_internal;
#if BX_CRT_NONE
@@ -330,7 +330,7 @@ namespace bx
#if BX_CRT_NONE
TlsData::TlsData()
{
BX_STATIC_ASSERT(sizeof(TlsDataInternal) <= sizeof(m_internal) );
static_assert(sizeof(TlsDataInternal) <= sizeof(m_internal) );
TlsDataInternal* ti = (TlsDataInternal*)m_internal;
BX_UNUSED(ti);
@@ -357,7 +357,7 @@ namespace bx
#elif BX_PLATFORM_WINDOWS
TlsData::TlsData()
{
BX_STATIC_ASSERT(sizeof(TlsDataInternal) <= sizeof(m_internal) );
static_assert(sizeof(TlsDataInternal) <= sizeof(m_internal) );
TlsDataInternal* ti = (TlsDataInternal*)m_internal;
ti->m_id = TlsAlloc();
@@ -387,7 +387,7 @@ namespace bx
TlsData::TlsData()
{
BX_STATIC_ASSERT(sizeof(TlsDataInternal) <= sizeof(m_internal) );
static_assert(sizeof(TlsDataInternal) <= sizeof(m_internal) );
TlsDataInternal* ti = (TlsDataInternal*)m_internal;
int result = pthread_key_create(&ti->m_id, NULL);

View File

@@ -7,7 +7,7 @@
#include <bx/bx.h>
#include <bx/string.h>
BX_STATIC_ASSERT(false
static_assert(false
|| BX_CRT_BIONIC
|| BX_CRT_GLIBC
|| BX_CRT_LIBCXX
@@ -17,12 +17,12 @@ BX_STATIC_ASSERT(false
|| BX_CRT_NONE
);
BX_STATIC_ASSERT(1 == BX_VA_ARGS_COUNT(1) );
BX_STATIC_ASSERT(2 == BX_VA_ARGS_COUNT(1, 2) );
BX_STATIC_ASSERT(3 == BX_VA_ARGS_COUNT(1, 2, 3) );
BX_STATIC_ASSERT(4 == BX_VA_ARGS_COUNT(1, 2, 3, 4) );
BX_STATIC_ASSERT(5 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) );
BX_STATIC_ASSERT(6 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) );
static_assert(1 == BX_VA_ARGS_COUNT(1) );
static_assert(2 == BX_VA_ARGS_COUNT(1, 2) );
static_assert(3 == BX_VA_ARGS_COUNT(1, 2, 3) );
static_assert(4 == BX_VA_ARGS_COUNT(1, 2, 3, 4) );
static_assert(5 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) );
static_assert(6 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) );
BX_NO_INLINE void unusedFunction()
{

View File

@@ -207,7 +207,7 @@ TEST_CASE("strCmpV sort", "[string][sort]")
"test_100.txt",
};
BX_STATIC_ASSERT(BX_COUNTOF(test) == BX_COUNTOF(expected) );
static_assert(BX_COUNTOF(test) == BX_COUNTOF(expected) );
bx::quickSort(test, BX_COUNTOF(test), sizeof(const char*), strCmpV);