Template, typename, others to make GCC happy

This commit is contained in:
Thomas Krijnen
2025-08-26 15:59:05 +02:00
parent 9109fcec12
commit e5fe2df552
5 changed files with 19 additions and 11 deletions
+15 -8
View File
@@ -374,7 +374,7 @@ private:
if constexpr (std::is_same_v<std::decay_t<decltype(m)>, impl::in_memory_file_storage> || if constexpr (std::is_same_v<std::decay_t<decltype(m)>, impl::in_memory_file_storage> ||
std::is_same_v<std::decay_t<decltype(m)>, impl::rocks_db_file_storage>) std::is_same_v<std::decay_t<decltype(m)>, impl::rocks_db_file_storage>)
{ {
return m.create<T>(); return m.template create<T>();
} else { } else {
return nullptr; return nullptr;
} }
@@ -398,17 +398,24 @@ private:
IFC_PARSE_API IfcFile* parse_ifcxml(const std::string& filename); IFC_PARSE_API IfcFile* parse_ifcxml(const std::string& filename);
#endif #endif
namespace impl {
// Trick to have a dependent static assertion
template <class> inline constexpr bool dependent_false_v = false;
}
} // namespace IfcParse } // namespace IfcParse
template <typename T> template <typename T>
T* IfcParse::impl::in_memory_file_storage::create() { T* IfcParse::impl::in_memory_file_storage::create() {
IfcUtil::IfcBaseClass* inst = nullptr; IfcUtil::IfcBaseClass* inst = nullptr;
if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<T::Class>>, IfcParse::entity>) { if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<typename T::Class>>, IfcParse::entity>) {
inst = new T(in_memory_attribute_storage(T::Class().attribute_count())); inst = new T(in_memory_attribute_storage(T::Class().attribute_count()));
} else if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<T::Class>>, IfcParse::type_declaration>) { } else if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<typename T::Class>>, IfcParse::type_declaration>) {
inst = new T(in_memory_attribute_storage(1)); inst = new T(in_memory_attribute_storage(1));
} else { } else {
static_assert(false, "Requires and entity or type declaration"); static_assert(dependent_false_v<T>, "Requires and entity or type declaration");
} }
inst->file_ = file; inst->file_ = file;
return file->addEntity(inst)->as<T>(); return file->addEntity(inst)->as<T>();
@@ -418,7 +425,7 @@ IfcUtil::IfcBaseClass* IfcParse::impl::in_memory_file_storage::create(const IfcP
IfcUtil::IfcBaseClass* inst = nullptr; IfcUtil::IfcBaseClass* inst = nullptr;
if (auto* ent = decl->as_entity()) { if (auto* ent = decl->as_entity()) {
inst = file->schema()->instantiate(decl, in_memory_attribute_storage(ent->attribute_count())); 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)); inst = file->schema()->instantiate(decl, in_memory_attribute_storage(1));
} else { } else {
throw std::runtime_error("Requires and entity or type declaration"); 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 <typename T> template <typename T>
T* IfcParse::impl::rocks_db_file_storage::create() { T* IfcParse::impl::rocks_db_file_storage::create() {
if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<T::Class>>, IfcParse::entity> || std::is_same_v<std::decay_t<std::invoke_result_t<T::Class>>, IfcParse::type_declaration>) { if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<typename T::Class>>, IfcParse::entity> || std::is_same_v<std::decay_t<std::invoke_result_t<typename T::Class>>, IfcParse::type_declaration>) {
auto* inst = new T(rocks_db_attribute_storage{}); auto* inst = new T(rocks_db_attribute_storage{});
inst->file_ = file; inst->file_ = file;
return file->addEntity(inst)->as<T>(); return file->addEntity(inst)->template as<T>();
} else { } else {
static_assert(false, "Requires and entity or type declaration"); static_assert(dependent_false_v<T>, "Requires and entity or type declaration");
} }
} }
+1 -1
View File
@@ -470,7 +470,7 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
aggregate_of_instance::ptr related_objects(new aggregate_of_instance); aggregate_of_instance::ptr related_objects(new aggregate_of_instance);
related_objects->push(related_object); related_objects->push(related_object);
T* t = create(&T::Class())->as<T>(); T* t = create(&T::Class())->template as<T>();
t->set_attribute_value(0, (std::string)IfcParse::IfcGlobalId()); t->set_attribute_value(0, (std::string)IfcParse::IfcGlobalId());
t->set_attribute_value(1, owner_hist); t->set_attribute_value(1, owner_hist);
int relating_index = 4; int relating_index = 4;
+1 -1
View File
@@ -120,7 +120,7 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) {
if (component->declaration().is(Schema::IfcSIUnit::Class())) { if (component->declaration().is(Schema::IfcSIUnit::Class())) {
si_unit = component->template as<typename Schema::IfcSIUnit>(); si_unit = component->template as<typename Schema::IfcSIUnit>();
typename Schema::IfcValue* value = factor->ValueComponent(); typename Schema::IfcValue* value = factor->ValueComponent();
scale = value->as<IfcUtil::IfcBaseClass>()->get_attribute_value(0); scale = value->template as<IfcUtil::IfcBaseClass>()->get_attribute_value(0);
} }
} else if (named_unit->declaration().is(Schema::IfcSIUnit::Class())) { } else if (named_unit->declaration().is(Schema::IfcSIUnit::Class())) {
si_unit = named_unit->template as<typename Schema::IfcSIUnit>(); si_unit = named_unit->template as<typename Schema::IfcSIUnit>();
+1
View File
@@ -215,6 +215,7 @@ public:
size_t erase(const key_type& key) { size_t erase(const key_type& key) {
// @todo // @todo
return 0;
} }
}; };
+1 -1
View File
@@ -507,8 +507,8 @@ namespace IfcParse {
break; break;
} }
} }
return *this;
#endif #endif
return *this;
} }
rocksdb_types_iterator operator++(int) { rocksdb_types_iterator operator++(int) {