2121
2222#include < chrono>
2323#include < memory>
24+ #include < variant>
25+ #include < type_traits>
2426
2527
2628void run_subcommand::setup_options (
@@ -72,6 +74,12 @@ void run_subcommand::setup_options(
7274namespace
7375{
7476
77+ template <class ... Ts>
78+ struct overloaded : Ts... { using Ts::operator ()...; };
79+
80+ template <class ... Ts>
81+ overloaded (Ts...) -> overloaded<Ts...>;
82+
7583cosim::execution load_system_structure (
7684 const cosim::filesystem::path& path,
7785 cosim::model_uri_resolver& uriResolver,
@@ -84,14 +92,15 @@ cosim::execution load_system_structure(
8492 const auto config = cosim::load_osp_config (path, uriResolver);
8593 std::shared_ptr<cosim::algorithm> algorithm;
8694
87- std::visit ([&algorithm, &config, &workerThreadCount](auto && value) {
88- using T = std::decay_t <decltype (value)>;
89- if constexpr (std::is_same_v<T, cosim::fixed_step_algorithm_params>) {
90- algorithm = std::make_shared<cosim::fixed_step_algorithm>(std::get<cosim::fixed_step_algorithm_params>(config.algorithm_configuration ), workerThreadCount);
91- } else if constexpr (std::is_same_v<T, cosim::ecco_algorithm_params>) {
92- algorithm = std::make_shared<cosim::ecco_algorithm>(std::get<cosim::ecco_algorithm_params>(config.algorithm_configuration ), workerThreadCount);
93- }
94- }, config.algorithm_configuration );
95+ std::visit (
96+ overloaded{
97+ [&algorithm, &workerThreadCount](const cosim::fixed_step_algorithm_params& params) {
98+ algorithm = std::make_shared<cosim::fixed_step_algorithm>(params, workerThreadCount);
99+ },
100+ [&algorithm, &workerThreadCount](const cosim::ecco_algorithm_params& params) {
101+ algorithm = std::make_shared<cosim::ecco_algorithm>(params, workerThreadCount);
102+ }},
103+ config.algorithm_configuration );
95104
96105 auto execution = cosim::execution (startTime, algorithm);
97106 cosim::inject_system_structure (
0 commit comments