Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29bac92

Browse files
committed
fix issue related to template specialization
1 parent d788989 commit 29bac92

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

include/behaviortree_cpp/blackboard/blackboard.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Blackboard
5656
/** Return true if the entry with the given key was found.
5757
* Note that this method may throw an exception if the cast to T failed.
5858
*
59-
* return true is succesful
59+
* return true if succesful
6060
*/
6161
template <typename T>
6262
bool get(const std::string& key, T& value) const
@@ -75,20 +75,13 @@ class Blackboard
7575
return true;
7676
}
7777

78-
template <typename T>
79-
bool get(const std::string& key, const SafeAny::Any* value) const
78+
const SafeAny::Any* getAny(const std::string& key) const
8079
{
8180
if (!impl_)
8281
{
83-
return false;
84-
}
85-
const SafeAny::Any* val = impl_->get(key);
86-
if (!val)
87-
{
88-
return false;
82+
return nullptr;
8983
}
90-
value = val;
91-
return true;
84+
return impl_->get(key);
9285
}
9386

9487

include/behaviortree_cpp/tree_node.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class TreeNode
138138
bool bb_pattern = isBlackboardPattern(str);
139139
if( bb_pattern && just_constructed_)
140140
{
141-
std::cerr << "you are calling getParam inside a constructor, but this is not allowed "
141+
std::cerr << "You are calling getParam inside a constructor, but this is not allowed "
142142
"when the parameter contains a blackboard.\n"
143143
"You should call getParam inside your tick() method"<< std::endl;
144144
std::logic_error("Calling getParam inside a constructor");
@@ -147,9 +147,9 @@ class TreeNode
147147
if ( bb_ && bb_pattern)
148148
{
149149
const std::string stripped_key(&str[2], str.size() - 3);
150-
const SafeAny::Any* val;
151-
bool found = bb_->get(stripped_key, val);
152-
if( found )
150+
const SafeAny::Any* val = bb_->getAny(stripped_key);
151+
152+
if( val )
153153
{
154154
if( std::is_same<T,std::string>::value == false &&
155155
(val->type() == typeid (std::string) ||
@@ -161,7 +161,7 @@ class TreeNode
161161
destination = val->cast<T>();
162162
}
163163
}
164-
return found;
164+
return val != nullptr;
165165
}
166166
else{
167167
destination = convertFromString<T>(str.c_str());

0 commit comments

Comments
 (0)