Simplify verify_args function to fix error C3249

This commit is contained in:
mutouyun 2025-01-11 18:45:25 +08:00
parent 86d9d868c8
commit 99272a452a

View File

@ -9,13 +9,7 @@ namespace mem {
* \brief Check that bytes is not 0 and that the alignment is a power of two. * \brief Check that bytes is not 0 and that the alignment is a power of two.
*/ */
inline constexpr bool verify_args(std::size_t bytes, std::size_t alignment) noexcept { inline constexpr bool verify_args(std::size_t bytes, std::size_t alignment) noexcept {
if (bytes == 0) { return (bytes > 0) && (alignment > 0) && ((alignment & (alignment - 1)) == 0);
return false;
}
if ((alignment == 0) || (alignment & (alignment - 1)) != 0) {
return false;
}
return true;
} }
} // namespace mem } // namespace mem