From: <sv...@op...> - 2024-08-16 13:09:19
|
Author: manx Date: Fri Aug 16 15:09:07 2024 New Revision: 21498 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21498 Log: [Ref] openmpt/fileformat_base/magic.hpp: Make all functions consteval. Modified: trunk/OpenMPT/src/openmpt/fileformat_base/magic.hpp Modified: trunk/OpenMPT/src/openmpt/fileformat_base/magic.hpp ============================================================================== --- trunk/OpenMPT/src/openmpt/fileformat_base/magic.hpp Fri Aug 16 15:08:46 2024 (r21497) +++ trunk/OpenMPT/src/openmpt/fileformat_base/magic.hpp Fri Aug 16 15:09:07 2024 (r21498) @@ -6,6 +6,7 @@ #include "openmpt/all/BuildSettings.hpp" +#include "mpt/base/macros.hpp" #include "openmpt/base/Types.hpp" @@ -16,11 +17,11 @@ // Functions to create 4-byte and 2-byte magic byte identifiers in little-endian format // Use this together with uint32le/uint16le file members. -constexpr uint32 MagicLE(const char (&id)[5]) +MPT_CONSTEVAL uint32 MagicLE(const char (&id)[5]) { return static_cast<uint32>((static_cast<uint8>(id[3]) << 24) | (static_cast<uint8>(id[2]) << 16) | (static_cast<uint8>(id[1]) << 8) | static_cast<uint8>(id[0])); } -constexpr uint16 MagicLE(const char (&id)[3]) +MPT_CONSTEVAL uint16 MagicLE(const char (&id)[3]) { return static_cast<uint16>((static_cast<uint8>(id[1]) << 8) | static_cast<uint8>(id[0])); } @@ -29,11 +30,11 @@ // Use this together with uint32be/uint16be file members. // Note: Historically, some magic bytes in MPT-specific fields are reversed (due to the use of multi-char literals). // Such fields turned up reversed in files, so MagicBE is used to keep them readable in the code. -constexpr uint32 MagicBE(const char (&id)[5]) +MPT_CONSTEVAL uint32 MagicBE(const char (&id)[5]) { return static_cast<uint32>((static_cast<uint8>(id[0]) << 24) | (static_cast<uint8>(id[1]) << 16) | (static_cast<uint8>(id[2]) << 8) | static_cast<uint8>(id[3])); } -constexpr uint16 MagicBE(const char (&id)[3]) +MPT_CONSTEVAL uint16 MagicBE(const char (&id)[3]) { return static_cast<uint16>((static_cast<uint8>(id[0]) << 8) | static_cast<uint8>(id[1])); } |