From 626c55f8e58a798c51f4bc2ed48090e1000079d2 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Tue, 28 Sep 2021 22:07:30 +0200
Subject: [PATCH] Template value type for get_with_prefix
---
include/components/config.hpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/components/config.hpp b/include/components/config.hpp
index 1b0a5b98..f00af679 100644
--- a/include/components/config.hpp
+++ b/include/components/config.hpp
@@ -117,18 +117,19 @@ class config {
* Eg: if you have in config `env-FOO = bar`,
* get_with_prefix(section, "env-") will return [{"FOO", "bar"}]
*/
- vector> get_with_prefix(const string& section, const string& key_prefix) const {
+ template
+ vector> get_with_prefix(const string& section, const string& key_prefix) const {
auto it = m_sections.find(section);
if (it == m_sections.end()) {
throw key_error("Missing section \"" + section + "\"");
}
- vector> list;
+ vector> list;
for (const auto& kv_pair : it->second) {
const auto& key = kv_pair.first;
if (key.substr(0, key_prefix.size()) == key_prefix) {
- const auto& val = kv_pair.second;
+ const T& val = get(section, key);
list.emplace_back(key.substr(key_prefix.size()), val);
}
}