mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 23:50:59 +00:00
fix(#6032): guard express::base::as<T>() on null instance
This commit is contained in:
committed by
Thomas Krijnen
parent
c80569ecc7
commit
6f2e1aa993
@@ -132,6 +132,11 @@ class IFC_PARSE_API base {
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T as() const {
|
T as() const {
|
||||||
|
if (!*this) {
|
||||||
|
// Unresolved or malformed attribute reference (e.g. a step-id
|
||||||
|
// that never resolved to an instance). Never dereference it.
|
||||||
|
return T{};
|
||||||
|
}
|
||||||
if constexpr (std::is_same_v<entity, T>) {
|
if constexpr (std::is_same_v<entity, T>) {
|
||||||
if (declaration().as_entity() != nullptr) {
|
if (declaration().as_entity() != nullptr) {
|
||||||
return T(data_weak());
|
return T(data_weak());
|
||||||
|
|||||||
Reference in New Issue
Block a user