Skip to content

Commit 2c2efef

Browse files
committed
4.5.1
1 parent 19a5b50 commit 2c2efef

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

CHANGELOG.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Changelog for package behaviortree_cpp
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5-
Forthcoming
6-
-----------
5+
4.5.1 (2024-01-23)
6+
------------------
77
* Support enums and real numbers in Node Switch
88
* improve Any::castPtr and add example
99
* fix issue `#748 <https://github.com/BehaviorTree/BehaviorTree.CPP/issues/748>`_ : static error messages

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
![License MIT](https://img.shields.io/github/license/BehaviorTree/BehaviorTree.CPP?color=blue)
2-
![Version](https://img.shields.io/badge/version-4.4-blue.svg)
2+
![Version](https://img.shields.io/badge/version-4.5-blue.svg)
33
[![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)
44
[![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)
55
[![ros1](https://github.com/BehaviorTree/BehaviorTree.CPP/workflows/ros1/badge.svg?branch=master)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions?query=workflow%3Aros1)
66
[![ros2](https://github.com/BehaviorTree/BehaviorTree.CPP/workflows/ros2/badge.svg?branch=master)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions?query=workflow%3Aros2)
77

8-
# BehaviorTree.CPP 4.4
8+
# BehaviorTree.CPP 4.5
99

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

package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>behaviortree_cpp</name>
4-
<version>4.5.0</version>
4+
<version>4.5.1</version>
55
<description>
66
This package provides the Behavior Trees core library.
77
</description>

src/controls/switch_node.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
#include "behaviortree_cpp/controls/switch_node.h"
1414

15+
#if __has_include(<charconv>)
16+
#include <charconv>
17+
#endif
18+
1519
namespace BT::details
1620
{
1721

@@ -35,8 +39,18 @@ bool CheckStringEquality(const std::string &v1, const std::string &v2,
3539
return true;
3640
}
3741
}
42+
#if __cpp_lib_to_chars >= 201611L
3843
auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), result);
3944
return (ec == std::errc());
45+
#else
46+
try {
47+
result = std::stoi(str);
48+
return true;
49+
}
50+
catch(...) {
51+
return false;
52+
}
53+
#endif
4054
};
4155
int v1_int = 0;
4256
int v2_int = 0;
@@ -47,8 +61,18 @@ bool CheckStringEquality(const std::string &v1, const std::string &v2,
4761
// compare as real numbers next
4862
auto ToReal = [](const std::string& str, auto& result) -> bool
4963
{
64+
#if __cpp_lib_to_chars >= 201611L
5065
auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), result);
5166
return (ec == std::errc());
67+
#else
68+
try {
69+
result = std::stod(str);
70+
return true;
71+
}
72+
catch(...) {
73+
return false;
74+
}
75+
#endif
5276
};
5377
double v1_real = 0;
5478
double v2_real = 0;

0 commit comments

Comments
 (0)