diff --git a/include/behaviortree_cpp/utils/safe_any.hpp b/include/behaviortree_cpp/utils/safe_any.hpp index 710a0e530..7a585ba45 100644 --- a/include/behaviortree_cpp/utils/safe_any.hpp +++ b/include/behaviortree_cpp/utils/safe_any.hpp @@ -347,9 +347,9 @@ nonstd::expected Any::stringToNumber() const { static_assert(std::is_arithmetic_v && !std::is_same_v, "Expecting a numeric type"); - auto str = linb::any_cast(_any); - T out; + const auto str = linb::any_cast(_any); #if __has_include() + T out; auto [ptr, err] = std::from_chars(str.data(), str.data() + str.size(), out); if(err == std::errc()) {