From b0d7141c0c1c9dd872051d7b34ab8a99215e659d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 12 Jan 2026 23:04:42 +0100 Subject: [PATCH] Add compile time log2_pow2 --- include/boost/container/detail/math_functions.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/container/detail/math_functions.hpp b/include/boost/container/detail/math_functions.hpp index e9a9165..af36896 100644 --- a/include/boost/container/detail/math_functions.hpp +++ b/include/boost/container/detail/math_functions.hpp @@ -167,6 +167,18 @@ struct lcm_ct BOOST_STATIC_CONSTEXPR std::size_t value = I1 * I2 / gcd_ct::value; }; +template +struct log2_pow2 +{ + BOOST_STATIC_CONSTEXPR std::size_t value = log2_pow2<(N >> 1), Count + 1>::value; +}; + +// Base case: we've reached 1 +template +struct log2_pow2<1, Count> { + BOOST_STATIC_CONSTEXPR std::size_t value = Count; +}; + } // namespace dtl } // namespace container } // namespace boost