Function is_power_of_two

Synopsis

#include <src/entt/core/memory.hpp>

constexpr bool is_power_of_two(const std::size_t value)

Description

Checks whether a value is a power of two or not.

Parameters

value - A value that may or may not be a power of two.

Returns
True if the value is a power of two, false otherwise.

Source

Lines 75-77 in src/entt/core/memory.hpp.

[[nodiscard]] inline constexpr bool is_power_of_two(const std::size_t value) ENTT_NOEXCEPT {
    return value && ((value & (value - 1)) == 0);
}





Add Discussion

Log in to comment