diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/MappingUtils.h b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/MappingUtils.h index 7849b8c8..08b46570 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/MappingUtils.h +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/MappingUtils.h @@ -152,6 +152,11 @@ namespace k4EDM4hep2LcioConv { } } + /// Helper type alias that can be used to detect whether a T can be used + /// with std::get directly or whether it has to be dereferenced first + template + using std_get_usable = decltype(std::get<0>(std::declval())); + /** * Helper function to get the Key from an Iterator (e.g. returned by * mapInsert). This is necessary because map::emplace returns an iterator, @@ -161,13 +166,12 @@ namespace k4EDM4hep2LcioConv { template auto getKey(const It& it) { - return std::get<0>(it); - } - - template - auto getKey(const It* it) - { - return std::get<0>(*it); + if constexpr (det::is_detected_v) { + return std::get<0>(it); + } + else { + return std::get<0>(*it); + } } /** @@ -179,13 +183,12 @@ namespace k4EDM4hep2LcioConv { template auto getMapped(const It& it) { - return std::get<1>(it); - } - - template - auto getMapped(const It* it) - { - return std::get<1>(*it); + if constexpr (det::is_detected_v) { + return std::get<1>(it); + } + else { + return std::get<1>(*it); + } } } // namespace detail