105 using key_type =
typename owner_type::info_type::key_type;
107 static std::mutex mutex_;
108 static std::unordered_map<key_type, std::unique_ptr<owner_type>> instances;
110 using info_type =
typename owner_type::info_type;
112 static void init(
const info_type&
info){
113 std::lock_guard<std::mutex>
lock{mutex_};
115 auto instance = std::make_unique<owner_type>(
info);
116 owner_type&
ret = *instance;
117 instances.emplace(
info.key(), std::move(instance));
121 static bool contains(
const key_type& key){
122 return instances.contains(key);
126 static auto get(
const key_type& key) -> owner_type& {
127 std::lock_guard<std::mutex>
lock { mutex_ };
128 auto it = instances.find(key);
129 if (
it != instances.end()) {
133 throw std::runtime_error(std::format(
"uninitialized multiton {}",key));