diff --git a/include/gz/physics/CompositeData.hh b/include/gz/physics/CompositeData.hh index 792a1b516..c561862ab 100644 --- a/include/gz/physics/CompositeData.hh +++ b/include/gz/physics/CompositeData.hh @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -963,7 +964,7 @@ namespace gz // We make this typedef public so that helper functions can use it without // being friends of the class. - public: using MapOfData = std::map; + public: using MapOfData = std::map; GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Map from the label of a data object type to its entry diff --git a/include/gz/physics/detail/CompositeData.hh b/include/gz/physics/detail/CompositeData.hh index 246ee529e..71f25e7d1 100644 --- a/include/gz/physics/detail/CompositeData.hh +++ b/include/gz/physics/detail/CompositeData.hh @@ -20,6 +20,7 @@ #include #include +#include #include @@ -92,7 +93,7 @@ namespace gz { bool inserted = false; const CompositeData::MapOfData::iterator it = _dataMap.insert( - std::make_pair(typeid(Data).name(), + std::make_pair(std::type_index(typeid(Data)), CompositeData::DataEntry())).first; if (!it->second.data) @@ -121,7 +122,7 @@ namespace gz Data &CompositeData::Get() { const MapOfData::iterator it = this->dataMap.insert( - std::make_pair(typeid(Data).name(), DataEntry())).first; + std::make_pair(std::type_index(typeid(Data)), DataEntry())).first; if (!it->second.data) { @@ -157,7 +158,7 @@ namespace gz bool CompositeData::Remove() { const MapOfData::iterator it = - this->dataMap.find(typeid(Data).name()); + this->dataMap.find(std::type_index(typeid(Data))); if (this->dataMap.end() == it || !it->second.data) return true; @@ -183,7 +184,7 @@ namespace gz Data *CompositeData::Query(const QueryMode _mode) { const MapOfData::const_iterator it = - this->dataMap.find(typeid(Data).name()); + this->dataMap.find(std::type_index(typeid(Data))); if (this->dataMap.end() == it) return nullptr; @@ -202,7 +203,7 @@ namespace gz const Data *CompositeData::Query(const QueryMode _mode) const { const MapOfData::const_iterator it = - this->dataMap.find(typeid(Data).name()); + this->dataMap.find(std::type_index(typeid(Data))); if (this->dataMap.end() == it) return nullptr; @@ -231,7 +232,7 @@ namespace gz DataStatus status; const MapOfData::const_iterator it = - this->dataMap.find(typeid(Data).name()); + this->dataMap.find(std::type_index(typeid(Data))); if (this->dataMap.end() == it) return status; @@ -251,7 +252,7 @@ namespace gz bool CompositeData::Unquery() const { const MapOfData::const_iterator it = - this->dataMap.find(typeid(Data).name()); + this->dataMap.find(std::type_index(typeid(Data))); if (this->dataMap.end() == it) return false; @@ -273,7 +274,7 @@ namespace gz Data &CompositeData::MakeRequired(Args &&..._args) { const MapOfData::iterator it = this->dataMap.insert( - std::make_pair(typeid(Data).name(), DataEntry())).first; + std::make_pair(std::type_index(typeid(Data)), DataEntry())).first; it->second.required = true; if (!it->second.data) @@ -293,7 +294,7 @@ namespace gz bool CompositeData::Requires() const { const MapOfData::const_iterator it = - this->dataMap.find(typeid(Data).name()); + this->dataMap.find(std::type_index(typeid(Data))); if (this->dataMap.end() == it) return false; diff --git a/include/gz/physics/detail/SpecifyData.hh b/include/gz/physics/detail/SpecifyData.hh index 13e694878..38535c3cd 100644 --- a/include/gz/physics/detail/SpecifyData.hh +++ b/include/gz/physics/detail/SpecifyData.hh @@ -21,6 +21,7 @@ #include #include #include +#include #include "gz/physics/SpecifyData.hh" @@ -34,7 +35,7 @@ namespace gz : CompositeData(), privateExpectData( this->dataMap.insert( - std::make_pair(typeid(Expected).name(), + std::make_pair(std::type_index(typeid(Expected)), CompositeData::DataEntry())).first) { // Do nothing diff --git a/src/CompositeData.cc b/src/CompositeData.cc index 876c05a69..197da4097 100644 --- a/src/CompositeData.cc +++ b/src/CompositeData.cc @@ -17,6 +17,7 @@ #include #include +#include #include "gz/physics/CompositeData.hh" @@ -336,7 +337,7 @@ namespace gz for (const auto &entry : dataMap) { if (entry.second.data) - entries.insert(entries.end(), entry.first); + entries.insert(entries.end(), entry.first.name()); } return entries; @@ -353,7 +354,7 @@ namespace gz for (const auto &entry : dataMap) { if (entry.second.data && !entry.second.queried) - unqueried.insert(unqueried.end(), entry.first); + unqueried.insert(unqueried.end(), entry.first.name()); } return unqueried;