From 3f72edd06511ccb9ae70942c08ae7e43c1c05d18 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Wed, 19 Mar 2025 10:22:58 +0300 Subject: [PATCH] Fix compile time string search in CTTI (#42) Fixes https://github.com/boostorg/type_index/issues/41 --- include/boost/type_index/detail/compile_time_type_info.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/type_index/detail/compile_time_type_info.hpp b/include/boost/type_index/detail/compile_time_type_info.hpp index 2c1ae38..95469bd 100644 --- a/include/boost/type_index/detail/compile_time_type_info.hpp +++ b/include/boost/type_index/detail/compile_time_type_info.hpp @@ -196,11 +196,12 @@ constexpr ctti_skip skip() noexcept { return detail::make_ctti_skip(0, 0, ""); } template BOOST_CXX14_CONSTEXPR inline const char* skip_begining_runtime(const char* begin) noexcept { + constexpr auto skip_value = detail::skip(); // to have the same `.until_runtime` value in code below const char* const it = detail::constexpr_search( begin, begin + ArrayLength, - skip().until_runtime, skip().until_runtime + skip().until_runtime_length + skip_value.until_runtime, skip_value.until_runtime + skip_value.until_runtime_length ); - return (it == begin + ArrayLength ? begin : it + skip().until_runtime_length); + return (it == begin + ArrayLength ? begin : it + skip_value.until_runtime_length); } template