1#ifndef BITSIM_UTILS_STD_MAP_UTILS_H
2#define BITSIM_UTILS_STD_MAP_UTILS_H
12#include <unordered_map>
23template <
typename OutT>
24OutT
resolve(
const std::string &name,
const std::map<std::string, std::any> &input)
27 auto itr = input.find(name);
29 if (itr == input.end())
31 throw std::logic_error(
"Property: " + name +
" not in input");
34 return std::any_cast<OutT>(itr->second);
41template <
typename OutT>
42OutT
resolve(
const std::string &name,
const std::unordered_map<std::string, std::any> &input)
44 auto itr = input.find(name);
46 if (itr == input.end())
48 throw std::logic_error(
"Property: " + name +
" not in input");
53 return std::any_cast<OutT>(itr->second);
55 catch (
const std::bad_any_cast &)
57 throw std::logic_error(
"Property: " + name +
" has unexpected type");
Definition bitsim_utils.h:11
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:24
Definition dc_motor_backend_base.h:9