From 0d5c6844672227a4b1b3eaa3161493d46eb06a96 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 28 Dec 2022 13:43:23 +0200 Subject: [PATCH] Disallow two components with the same name --- source/lib/sourcepackage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/lib/sourcepackage.cpp b/source/lib/sourcepackage.cpp index 0913592..34e8a1b 100644 --- a/source/lib/sourcepackage.cpp +++ b/source/lib/sourcepackage.cpp @@ -219,6 +219,8 @@ void SourcePackage::Loader::feature(const string &n, const string &d) template void SourcePackage::Loader::component(Args... args, const string &n) { + if(any_of(obj.components.begin(), obj.components.end(), [&n](const Component *c){ return c->get_name()==n; })) + throw key_error(n); C *comp = new C(obj, n, args...); load_sub(*comp); obj.components.push_back(comp); -- 2.43.0