From e5fe2df552e31b3923c7cb8c7a3f75229e72ca17 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 26 Aug 2025 15:59:05 +0200 Subject: [PATCH] Template, typename, others to make GCC happy --- src/ifcparse/IfcFile.h | 23 +++++++++++++++-------- src/ifcparse/IfcHierarchyHelper.h | 2 +- src/ifcparse/IfcSIPrefix.cpp | 2 +- src/ifcparse/rocksdb_set_view.h | 1 + src/ifcparse/storage.h | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index 564ba4b2a7..e8f61826da 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -374,7 +374,7 @@ private: if constexpr (std::is_same_v, impl::in_memory_file_storage> || std::is_same_v, impl::rocks_db_file_storage>) { - return m.create(); + return m.template create(); } else { return nullptr; } @@ -398,17 +398,24 @@ private: IFC_PARSE_API IfcFile* parse_ifcxml(const std::string& filename); #endif +namespace impl { + // Trick to have a dependent static assertion + template inline constexpr bool dependent_false_v = false; +} + } // namespace IfcParse + + template T* IfcParse::impl::in_memory_file_storage::create() { IfcUtil::IfcBaseClass* inst = nullptr; - if constexpr (std::is_same_v>, IfcParse::entity>) { + if constexpr (std::is_same_v>, IfcParse::entity>) { inst = new T(in_memory_attribute_storage(T::Class().attribute_count())); - } else if constexpr (std::is_same_v>, IfcParse::type_declaration>) { + } else if constexpr (std::is_same_v>, IfcParse::type_declaration>) { inst = new T(in_memory_attribute_storage(1)); } else { - static_assert(false, "Requires and entity or type declaration"); + static_assert(dependent_false_v, "Requires and entity or type declaration"); } inst->file_ = file; return file->addEntity(inst)->as(); @@ -418,7 +425,7 @@ IfcUtil::IfcBaseClass* IfcParse::impl::in_memory_file_storage::create(const IfcP IfcUtil::IfcBaseClass* inst = nullptr; if (auto* ent = decl->as_entity()) { inst = file->schema()->instantiate(decl, in_memory_attribute_storage(ent->attribute_count())); - } else if (auto* typedecl = decl->as_type_declaration()) { + } else if (decl->as_type_declaration() != nullptr) { inst = file->schema()->instantiate(decl, in_memory_attribute_storage(1)); } else { throw std::runtime_error("Requires and entity or type declaration"); @@ -429,12 +436,12 @@ IfcUtil::IfcBaseClass* IfcParse::impl::in_memory_file_storage::create(const IfcP template T* IfcParse::impl::rocks_db_file_storage::create() { - if constexpr (std::is_same_v>, IfcParse::entity> || std::is_same_v>, IfcParse::type_declaration>) { + if constexpr (std::is_same_v>, IfcParse::entity> || std::is_same_v>, IfcParse::type_declaration>) { auto* inst = new T(rocks_db_attribute_storage{}); inst->file_ = file; - return file->addEntity(inst)->as(); + return file->addEntity(inst)->template as(); } else { - static_assert(false, "Requires and entity or type declaration"); + static_assert(dependent_false_v, "Requires and entity or type declaration"); } } diff --git a/src/ifcparse/IfcHierarchyHelper.h b/src/ifcparse/IfcHierarchyHelper.h index 1d79fc939c..65b35717d2 100644 --- a/src/ifcparse/IfcHierarchyHelper.h +++ b/src/ifcparse/IfcHierarchyHelper.h @@ -470,7 +470,7 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile { aggregate_of_instance::ptr related_objects(new aggregate_of_instance); related_objects->push(related_object); - T* t = create(&T::Class())->as(); + T* t = create(&T::Class())->template as(); t->set_attribute_value(0, (std::string)IfcParse::IfcGlobalId()); t->set_attribute_value(1, owner_hist); int relating_index = 4; diff --git a/src/ifcparse/IfcSIPrefix.cpp b/src/ifcparse/IfcSIPrefix.cpp index 22cf78d011..22be5e52d3 100644 --- a/src/ifcparse/IfcSIPrefix.cpp +++ b/src/ifcparse/IfcSIPrefix.cpp @@ -120,7 +120,7 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) { if (component->declaration().is(Schema::IfcSIUnit::Class())) { si_unit = component->template as(); typename Schema::IfcValue* value = factor->ValueComponent(); - scale = value->as()->get_attribute_value(0); + scale = value->template as()->get_attribute_value(0); } } else if (named_unit->declaration().is(Schema::IfcSIUnit::Class())) { si_unit = named_unit->template as(); diff --git a/src/ifcparse/rocksdb_set_view.h b/src/ifcparse/rocksdb_set_view.h index be2b26223a..ef22d694f4 100644 --- a/src/ifcparse/rocksdb_set_view.h +++ b/src/ifcparse/rocksdb_set_view.h @@ -215,6 +215,7 @@ public: size_t erase(const key_type& key) { // @todo + return 0; } }; diff --git a/src/ifcparse/storage.h b/src/ifcparse/storage.h index c3a5c4853a..9a26039e1f 100644 --- a/src/ifcparse/storage.h +++ b/src/ifcparse/storage.h @@ -507,8 +507,8 @@ namespace IfcParse { break; } } - return *this; #endif + return *this; } rocksdb_types_iterator operator++(int) {