Skip to content

Commit

Permalink
4.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Jan 23, 2024
1 parent 19a5b50 commit 2c2efef
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/BehaviorTree/BehaviorTree.CPP/issues/748>`_ : static error messages
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

<p align="center"><img width=350 src="animated.svg"></p>

Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="3">
<name>behaviortree_cpp</name>
<version>4.5.0</version>
<version>4.5.1</version>
<description>
This package provides the Behavior Trees core library.
</description>
Expand Down
24 changes: 24 additions & 0 deletions src/controls/switch_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#include "behaviortree_cpp/controls/switch_node.h"

#if __has_include(<charconv>)
#include <charconv>
#endif

namespace BT::details
{

Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 2c2efef

Please sign in to comment.