Skip to content

Commit

Permalink
move constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxxen committed Mar 26, 2024
1 parent 7fa72ba commit 6b4b29c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions spatial/include/spatial/core/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,7 @@ class TypedCollectionGeometry : public CollectionGeometry {
protected:
TypedCollectionGeometry(GeometryType type, bool has_z, bool has_m)
: CollectionGeometry(type, has_z, has_m) {}
TypedCollectionGeometry(GeometryType type, ArenaAllocator &alloc, uint32_t count, bool has_z, bool has_m)
: CollectionGeometry(type, alloc, count, has_z, has_m) {
auto ptr = data.part_data;
for (uint32_t i = 0; i < count; i++) {
new(ptr++) T(has_z, has_m);
}
}
TypedCollectionGeometry(GeometryType type, ArenaAllocator &alloc, uint32_t count, bool has_z, bool has_m);

public:
T &operator[](uint32_t index);
Expand Down Expand Up @@ -489,7 +483,9 @@ class Geometry {
new(&collection) GeometryCollection(std::move(other.collection));
break;
default:
throw NotImplementedException("Geometry::Geometry(Geometry&&)");
D_ASSERT(false);
new(&point) Point(std::move(other.point));
break;
}
}

Expand Down Expand Up @@ -522,7 +518,9 @@ class Geometry {
new(&collection) GeometryCollection(std::move(other.collection));
break;
default:
throw NotImplementedException("Geometry::operator=(Geometry&&)");
D_ASSERT(false);
new(&point) Point(std::move(other.point));
break;
}
return *this;
}
Expand Down Expand Up @@ -659,6 +657,15 @@ inline GeometryCollection::GeometryCollection(ArenaAllocator &alloc, uint32_t co
}
}

template<class T>
inline TypedCollectionGeometry<T>::TypedCollectionGeometry(GeometryType type, ArenaAllocator &alloc, uint32_t count, bool has_z, bool has_m)
: CollectionGeometry(type, alloc, count, has_z, has_m) {
auto ptr = data.part_data;
for (uint32_t i = 0; i < count; i++) {
new(ptr++) T(has_z, has_m);
}
}

//-------------------
// MultiPartGeometry
//-------------------
Expand Down

0 comments on commit 6b4b29c

Please sign in to comment.