mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Template, typename, others to make GCC happy
This commit is contained in:
+15
-8
@@ -374,7 +374,7 @@ private:
|
||||
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>)
|
||||
{
|
||||
return m.create<T>();
|
||||
return m.template create<T>();
|
||||
} 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 <class> inline constexpr bool dependent_false_v = false;
|
||||
}
|
||||
|
||||
} // namespace IfcParse
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
T* IfcParse::impl::in_memory_file_storage::create() {
|
||||
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()));
|
||||
} 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));
|
||||
} 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;
|
||||
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;
|
||||
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 <typename T>
|
||||
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{});
|
||||
inst->file_ = file;
|
||||
return file->addEntity(inst)->as<T>();
|
||||
return file->addEntity(inst)->template as<T>();
|
||||
} else {
|
||||
static_assert(false, "Requires and entity or type declaration");
|
||||
static_assert(dependent_false_v<T>, "Requires and entity or type declaration");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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* t = create(&T::Class())->template as<T>();
|
||||
t->set_attribute_value(0, (std::string)IfcParse::IfcGlobalId());
|
||||
t->set_attribute_value(1, owner_hist);
|
||||
int relating_index = 4;
|
||||
|
||||
@@ -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::IfcSIUnit>();
|
||||
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())) {
|
||||
si_unit = named_unit->template as<typename Schema::IfcSIUnit>();
|
||||
|
||||
@@ -215,6 +215,7 @@ public:
|
||||
|
||||
size_t erase(const key_type& key) {
|
||||
// @todo
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -507,8 +507,8 @@ namespace IfcParse {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
rocksdb_types_iterator operator++(int) {
|
||||
|
||||
Reference in New Issue
Block a user