Skip to content

Commit bde7fc5

Browse files
committed
fix issue BehaviorTree#256
1 parent 3f751c7 commit bde7fc5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/behaviortree_cpp_v3/basic_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ unsigned convertFromString<unsigned>(StringView str);
8484
template <>
8585
long convertFromString<long>(StringView str);
8686

87+
template <>
88+
unsigned long convertFromString<unsigned long>(StringView str);
89+
90+
template <>
91+
float convertFromString<float>(StringView str);
92+
8793
template <>
8894
double convertFromString<double>(StringView str);
8995

src/basic_types.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ unsigned convertFromString<unsigned>(StringView str)
119119
return unsigned(std::stoul(str.data()));
120120
}
121121

122+
template <>
123+
unsigned long convertFromString<unsigned long>(StringView str)
124+
{
125+
return std::stoul(str.data());
126+
}
127+
122128
template <>
123129
double convertFromString<double>(StringView str)
124130
{
@@ -132,6 +138,16 @@ double convertFromString<double>(StringView str)
132138
return val;
133139
}
134140

141+
template <>
142+
float convertFromString<float>(StringView str)
143+
{
144+
std::string old_locale = setlocale(LC_NUMERIC,nullptr);
145+
setlocale(LC_NUMERIC,"C");
146+
float val = std::stof(str.data());
147+
setlocale(LC_NUMERIC, old_locale.c_str());
148+
return val;
149+
}
150+
135151
template <>
136152
std::vector<int> convertFromString<std::vector<int>>(StringView str)
137153
{

0 commit comments

Comments
 (0)