summaryrefslogtreecommitdiff
path: root/lib/persistence.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-05-01 18:39:05 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-07 16:41:37 +0000
commit3ab8959669be3bd7232a8aa1859eb651fcdf05b3 (patch)
treea304c5c514914c99bc86ac167cb72a3ff15bed98 /lib/persistence.h
parentCommon implementation for shared and unique pointers (diff)
downloadilt-3ab8959669be3bd7232a8aa1859eb651fcdf05b3.tar.bz2
ilt-3ab8959669be3bd7232a8aa1859eb651fcdf05b3.tar.xz
ilt-3ab8959669be3bd7232a8aa1859eb651fcdf05b3.zip
Error on bad cast of named type
Diffstat (limited to 'lib/persistence.h')
-rw-r--r--lib/persistence.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/persistence.h b/lib/persistence.h
index 5ef1400..86b0dce 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -196,14 +196,17 @@ namespace Persistence {
auto no = Persistable::callSharedFactory(type);
if (auto tno = std::dynamic_pointer_cast<T>(no)) {
this->v = std::move(tno);
+ return;
}
}
else {
auto no = Persistable::callFactory(type);
if (dynamic_cast<T *>(no.get())) {
this->v.reset(static_cast<T *>(no.release()));
+ return;
}
}
+ throw std::runtime_error("Named type doesn't cast to target type");
}
};