diff --git a/Juliet/include/Core/Common/CRC32.h b/Juliet/include/Core/Common/CRC32.h index d6be052..b462130 100644 --- a/Juliet/include/Core/Common/CRC32.h +++ b/Juliet/include/Core/Common/CRC32.h @@ -1,4 +1,6 @@ #pragma once +#include +#include // From https://web.mit.edu/freebsd/head/sys/libkern/crc32.c @@ -37,8 +39,9 @@ namespace details }; } -consteval uint32 crc32(const char* str, size_t length) +constexpr uint32 crc32(const char* str, size_t length) { + Assert(str && length > 0); const char* p = str; uint32_t crc = ~0U; while (length--) @@ -48,8 +51,12 @@ consteval uint32 crc32(const char* str, size_t length) return crc ^ ~0U; } +constexpr uint32 crc32(String str) +{ + return crc32(str.Str, str.Size); +} + consteval uint32 operator""_crc32(const char* str, size_t length) { return crc32(str, length); } -