diff --git a/include/behaviortree_cpp/blackboard.h b/include/behaviortree_cpp/blackboard.h index 87ed4c8da..3b7f24a9f 100644 --- a/include/behaviortree_cpp/blackboard.h +++ b/include/behaviortree_cpp/blackboard.h @@ -25,6 +25,14 @@ struct StampedValue Timestamp stamp; }; +// Helper trait to check if a type is a std::vector +template +struct is_vector : std::false_type {}; + +template +struct is_vector> : std::true_type {}; + + /** * @brief The Blackboard is the mechanism used by BehaviorTrees to exchange * typed data. @@ -258,7 +266,8 @@ inline void Blackboard::set(const std::string& key, const T& value) std::type_index previous_type = entry.info.type(); // Allow mismatch if going from vector -> vector. - bool previous_is_vector = std::string(previous_type.name()).find("vector") != std::string::npos; + auto prev_type_demangled = demangle(entry.value.type()); + bool previous_is_vector = prev_type_demangled.substr(0, 11) == "std::vector"; bool new_is_vector_any = new_value.type() == typeid(std::vector); // check type mismatch diff --git a/include/behaviortree_cpp/tree_node.h b/include/behaviortree_cpp/tree_node.h index 2535125ca..1b4dc0fdc 100644 --- a/include/behaviortree_cpp/tree_node.h +++ b/include/behaviortree_cpp/tree_node.h @@ -30,13 +30,6 @@ namespace BT { -// Helper trait to check if a type is a std::vector -template -struct is_vector : std::false_type {}; - -template -struct is_vector> : std::true_type {}; - /// This information is used mostly by the XMLParser. struct TreeNodeManifest { diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index 053a1f0fc..039b3bc2b 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -789,7 +789,8 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element, // special case related to unwrapping vector -> vector objects. bool const vec_any_input = (prev_info->type() == typeid(std::vector)); // special case related to wrapping vector -> vector objects. - bool previous_is_vector = std::string(prev_info->type().name()).find("vector") != std::string::npos; + auto prev_type_demangled = demangle(entry.value.type()); + bool previous_is_vector = prev_type_demangled.substr(0, 11) == "std::vector"; bool new_is_vector_any = port_info.type() == typeid(std::vector); if(port_type_mismatch && !string_input &&