diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ccd1f97e6..a9cb4cb0d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package behaviortree_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.5.1 (2024-01-23) +------------------ * Support enums and real numbers in Node Switch * improve Any::castPtr and add example * fix issue `#748 `_ : static error messages diff --git a/README.md b/README.md index add4b0f60..48ad13537 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ![License MIT](https://img.shields.io/github/license/BehaviorTree/BehaviorTree.CPP?color=blue) -![Version](https://img.shields.io/badge/version-4.4-blue.svg) +![Version](https://img.shields.io/badge/version-4.5-blue.svg) [![conan Ubuntu](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_ubuntu.yml/badge.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_ubuntu.yml) [![conan Windows](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_windows.yml/badge.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_windows.yml) [![ros1](https://github.com/BehaviorTree/BehaviorTree.CPP/workflows/ros1/badge.svg?branch=master)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions?query=workflow%3Aros1) [![ros2](https://github.com/BehaviorTree/BehaviorTree.CPP/workflows/ros2/badge.svg?branch=master)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions?query=workflow%3Aros2) -# BehaviorTree.CPP 4.4 +# BehaviorTree.CPP 4.5

diff --git a/package.xml b/package.xml index 4ac69a49e..956e5427f 100644 --- a/package.xml +++ b/package.xml @@ -1,7 +1,7 @@ behaviortree_cpp - 4.5.0 + 4.5.1 This package provides the Behavior Trees core library. diff --git a/src/controls/switch_node.cpp b/src/controls/switch_node.cpp index 242d8aa96..02ad6095a 100644 --- a/src/controls/switch_node.cpp +++ b/src/controls/switch_node.cpp @@ -12,6 +12,10 @@ #include "behaviortree_cpp/controls/switch_node.h" +#if __has_include() +#include +#endif + namespace BT::details { @@ -35,8 +39,18 @@ bool CheckStringEquality(const std::string &v1, const std::string &v2, return true; } } +#if __cpp_lib_to_chars >= 201611L auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), result); return (ec == std::errc()); +#else + try { + result = std::stoi(str); + return true; + } + catch(...) { + return false; + } +#endif }; int v1_int = 0; int v2_int = 0; @@ -47,8 +61,18 @@ bool CheckStringEquality(const std::string &v1, const std::string &v2, // compare as real numbers next auto ToReal = [](const std::string& str, auto& result) -> bool { +#if __cpp_lib_to_chars >= 201611L auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), result); return (ec == std::errc()); +#else + try { + result = std::stod(str); + return true; + } + catch(...) { + return false; + } +#endif }; double v1_real = 0; double v2_real = 0;