Skip to content

Commit 8b8cf83

Browse files
Update yaml serialization of std::unordered_map to be generic
1 parent cd2a05a commit 8b8cf83

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tesseract_common/include/tesseract_common/yaml_extenstions.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,11 @@ struct convert<tesseract_common::AllowedCollisionMatrix>
833833
}
834834
};
835835

836-
//============================== std::unordered_map<std::string, bool> =============================
837-
template <>
838-
struct convert<std::unordered_map<std::string, bool>>
836+
//============================== std::unordered_map =============================
837+
template <typename T, typename A>
838+
struct convert<std::unordered_map<T, A>>
839839
{
840-
static Node encode(const std::unordered_map<std::string, bool>& rhs)
840+
static Node encode(const std::unordered_map<T, A>& rhs)
841841
{
842842
Node node(NodeType::Map);
843843
for (const auto& pair : rhs)
@@ -846,13 +846,13 @@ struct convert<std::unordered_map<std::string, bool>>
846846
return node;
847847
}
848848

849-
static bool decode(const Node& node, std::unordered_map<std::string, bool>& rhs)
849+
static bool decode(const Node& node, std::unordered_map<T, A>& rhs)
850850
{
851851
if (!node.IsMap())
852852
return false;
853853

854854
for (auto it = node.begin(); it != node.end(); ++it)
855-
rhs[it->first.as<std::string>()] = it->second.as<bool>();
855+
rhs[it->first.as<T>()] = it->second.as<A>();
856856

857857
return true;
858858
}

0 commit comments

Comments
 (0)