| 184 | */ |
| 185 | template <template <typename> class C, typename T, typename... A> |
| 186 | void insert(const std::string &label, A &&...args) |
| 187 | { |
| 188 | static_assert(std::is_base_of<field::Base, C<T>>::value, "C is not a type of field::Base."); |
| 189 | |
| 190 | for (auto &field : fields) |
| 191 | { |
| 192 | if (field->label == label) |
| 193 | { |
| 194 | if (dynamic_cast<typename field::template Static<T> *>(field.get())) |
| 195 | { |
| 196 | field = std::make_unique<C<T>>(label, args...); |
| 197 | } |
| 198 | return; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | auto field = std::make_unique<C<T>>(label, std::forward<A>(args)...); |
| 203 | fields.push_back(std::move(field)); |
| 204 | } |
| 205 | |
| 206 | private: |
| 207 | std::vector<std::unique_ptr<field::Base>> fields; |
no test coverage detected