From f359c31af44489729f60852162ecdb0939a633f7 Mon Sep 17 00:00:00 2001 From: Khalil Estell Date: Sat, 12 Oct 2024 07:48:14 -0700 Subject: [PATCH] :bug: Set correct constexpr/consteval for bit_mask (#29) --- include/libhal-util/bit.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/libhal-util/bit.hpp b/include/libhal-util/bit.hpp index 6b53c8c..0c7c96f 100644 --- a/include/libhal-util/bit.hpp +++ b/include/libhal-util/bit.hpp @@ -48,6 +48,9 @@ struct bit_mask * position1 and position2 can be in any order so long as they span the * distance from the start and end of the bit_mask range. * + * Use this when you REQUIRE the bit mask to be generated at compile time, + * because template arguments are required to be known at compile time. + * * @tparam position1 - bit position 1 * @tparam position2 - bit position 2 * @return consteval bit_mask - bit bit_mask represented by the two bit @@ -70,12 +73,15 @@ struct bit_mask * @ingroup Bit * @brief Generate, at compile time, a single bit width bit_mask at position * + * Use this when you REQUIRE the bit mask to be generated at compile time, + * because template arguments are required to be known at compile time. + * * @tparam position - the bit to make the bit_mask for * @return constexpr bit_mask - bit bit_mask with the position bit set to * position */ template - static constexpr bit_mask from() + static consteval bit_mask from() { return bit_mask{ .position = position, .width = 1U }; } @@ -96,7 +102,7 @@ struct bit_mask * @return consteval bit_mask - bit bit_mask represented by the two bit * positions */ - static consteval bit_mask from(std::uint32_t position1, + static constexpr bit_mask from(std::uint32_t position1, std::uint32_t position2) { constexpr std::uint32_t plus_one = 1;