Add const T& overload to WellContainer

This commit is contained in:
Joakim Hove 2021-05-07 09:05:21 +02:00
parent 42101774a0
commit 0083022742

View File

@ -56,6 +56,14 @@ public:
this->data.push_back(std::forward<T>(value));
}
void add(const std::string& name, const T& value) {
if (index_map.count(name) != 0)
throw std::logic_error("An object with name: " + name + " already exists in container");
this->index_map.emplace(name, this->data.size());
this->data.push_back(value);
}
bool has(const std::string& name) const {
return (index_map.count(name) != 0);
}
@ -66,10 +74,19 @@ public:
this->data[index] = std::forward<T>(value);
}
void update(const std::string& name, const T& value) {
auto index = this->index_map.at(name);
this->data[index] = value;
}
void update(std::size_t index, T&& value) {
this->data.at(index) = std::forward<T>(value);
}
void update(std::size_t index, const T& value) {
this->data.at(index) = value;
}
/*
Will copy the value from other to this - for all wells which are present
in both containers.