From 61d5e64d87b8d1e0f1b21c6843cdbe404e8c5dec Mon Sep 17 00:00:00 2001 From: cursey Date: Wed, 5 Jan 2022 12:48:43 -0800 Subject: [PATCH] Fix parser expecting to always find templates --- src/project_parser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 9cef19d..abe8ae5 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -428,9 +428,14 @@ Project::Project(const Project *parent, const std::string &path, bool build) { } if (toml.contains("target") || toml.contains("template")) { + const toml::basic_value empty_templates_table = toml::table(); + auto tables = { + toml.contains("template") ? &toml::find(toml, "template") : &empty_templates_table, + &toml::find(toml, "target") + }; auto is_template = true; - for (const auto &ts : {&toml::find(toml, "template"), &toml::find(toml, "target")}) { + for (const auto &ts : tables) { for (const auto &itr : ts->as_table()) { const auto &value = itr.second; auto &t = checker.create(value);