Skip to content

Commit 5b3c141

Browse files
committed
Fix bug related to std::get<std::string>(pubKey) and std::bad_variant_access
1 parent ac576ef commit 5b3c141

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Examples/Detectors/MuonSpectrometerMockupDetector/src/GeoMuonMockupExperiment.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <format>
1616
#include <iostream>
17-
#include <variant>
17+
#include <any>
1818

1919
#include <GeoModelWrite/WriteGeoModel.h>
2020

@@ -169,14 +169,14 @@ ActsPlugins::GeoModelTree GeoMuonMockupExperiment::constructMS() {
169169
VolumeMap_t publishedVol{};
170170
for (const auto& [fpV, pubKey] : m_publisher->getPublishedFPV()) {
171171
try {
172-
const auto key = std::get<std::string>(pubKey);
172+
const auto key = std::any_cast<std::string>(pubKey);
173173
if (!publishedVol
174174
.insert(std::make_pair(key, static_cast<GeoFullPhysVol*>(fpV)))
175175
.second) {
176176
throw std::invalid_argument("GeoMuonMockupExperiment() - Key " + key +
177177
" is no longer unique");
178178
}
179-
} catch (const std::bad_variant_access& e) {
179+
} catch (const std::bad_any_cast& e) {
180180
throw std::domain_error(
181181
"GeoMuonMockupExperiment() - Failed to cast the key to string " +
182182
std::string{e.what()});

0 commit comments

Comments
 (0)