Move template down to .cpp to prevent use of incomplete type

This commit is contained in:
Thomas Krijnen
2026-01-06 09:41:20 +01:00
parent 7098beb819
commit 2d7521ed88
2 changed files with 14 additions and 11 deletions
+13 -2
View File
@@ -529,8 +529,6 @@ template IFC_PARSE_API void rocks_db_attribute_storage::set<Derived>(void* stora
template IFC_PARSE_API void rocks_db_attribute_storage::set<empty_aggregate_t>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index, const empty_aggregate_t& value);
template IFC_PARSE_API void rocks_db_attribute_storage::set<empty_aggregate_of_aggregate_t>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index, const empty_aggregate_of_aggregate_t& value);
template IFC_PARSE_API bool rocks_db_attribute_storage::has<Blank>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index) const;
template IFC_PARSE_API bool rocks_db_attribute_storage::has<int>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index) const;
template IFC_PARSE_API bool rocks_db_attribute_storage::has<bool>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index) const;
@@ -554,4 +552,17 @@ template IFC_PARSE_API bool rocks_db_attribute_storage::has<Derived>(void* stora
template IFC_PARSE_API bool rocks_db_attribute_storage::has<empty_aggregate_t>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index) const;
template IFC_PARSE_API bool rocks_db_attribute_storage::has<empty_aggregate_of_aggregate_t>(void* storage, const IfcParse::declaration* decl, std::size_t identity, size_t index) const;
template <typename T>
T* InstanceData::get_storage_of_type() const {
return std::visit([this](auto& m) -> T* {
if constexpr (std::is_same_v<std::decay_t<decltype(m)>, T>) {
return &m;
}
return nullptr;
}, file()->storage_);
}
template IFC_PARSE_API IfcParse::impl::in_memory_file_storage* InstanceData::get_storage_of_type<IfcParse::impl::in_memory_file_storage>() const;
template IFC_PARSE_API IfcParse::impl::rocks_db_file_storage* InstanceData::get_storage_of_type<IfcParse::impl::rocks_db_file_storage>() const;
#endif
+1 -9
View File
@@ -424,15 +424,7 @@ class IFC_PARSE_API InstanceData {
uint32_t id_;
template <typename T>
T* get_storage_of_type() const {
return std::visit([this](auto& m) -> T* {
if constexpr (std::is_same_v<std::decay_t<decltype(m)>, T>) {
return &m;
}
return nullptr;
},
file()->storage_);
}
T* get_storage_of_type() const;
public:
// Since rocks_db_attribute_storage has no members this is not a variant<in_memory, rocks> but in_memory*, where nullptr means a rocks_db_attribute_storage is constructed on the fly given the context from instance data.