From 70bb337498be186572f0e42e91f54faa5d2d2bfb Mon Sep 17 00:00:00 2001 From: Bart Janssens Date: Fri, 4 Aug 2023 23:21:28 +0200 Subject: [PATCH] Switch to type_index for type map --- include/jlcxx/type_conversion.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/jlcxx/type_conversion.hpp b/include/jlcxx/type_conversion.hpp index ddc9f82..1dab240 100644 --- a/include/jlcxx/type_conversion.hpp +++ b/include/jlcxx/type_conversion.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -332,7 +333,7 @@ struct CachedDatatype }; // Work around the fact that references aren't part of the typeid result -using type_hash_t = std::pair; +using type_hash_t = std::pair; namespace detail { @@ -342,7 +343,7 @@ struct TypeHash { static inline type_hash_t value() { - return std::make_pair(typeid(T).hash_code(), std::size_t(0)); + return std::make_pair(std::type_index(typeid(T)), std::size_t(0)); } }; @@ -351,7 +352,7 @@ struct TypeHash { static inline type_hash_t value() { - return std::make_pair(typeid(T).hash_code(), std::size_t(1)); + return std::make_pair(std::type_index(typeid(T)), std::size_t(1)); } }; @@ -360,7 +361,7 @@ struct TypeHash { static inline type_hash_t value() { - return std::make_pair(typeid(T).hash_code(), std::size_t(2)); + return std::make_pair(std::type_index(typeid(T)), std::size_t(2)); } }; @@ -395,7 +396,7 @@ class JuliaTypeCache const auto insresult = jlcxx_type_map().insert(std::make_pair(type_hash(), CachedDatatype(dt, protect))); if(!insresult.second) { - std::cout << "Warning: Type " << typeid(SourceT).name() << " already had a mapped type set as " << julia_type_name(insresult.first->second.get_dt()) << " using hash " << insresult.first->first.first << " and const-ref indicator " << insresult.first->first.second << std::endl; + std::cout << "Warning: Type " << typeid(SourceT).name() << " already had a mapped type set as " << julia_type_name(insresult.first->second.get_dt()) << " using hash " << insresult.first->first.first.hash_code() << " and const-ref indicator " << insresult.first->first.second << std::endl; return; } }