Skip to content

Commit

Permalink
Move constructor for SharedAsset.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Oct 4, 2024
1 parent 275bac0 commit a88d83f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CesiumGltf/include/CesiumGltf/SharedAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ template <typename T>
class CESIUMGLTF_API SharedAsset : public CesiumUtility::ExtensibleObject {
public:
SharedAsset() = default;
~SharedAsset() { CESIUM_ASSERT(this->_referenceCount == 0); }

// Assets can be copied, but the fresh instance has no references and is not
// in the asset depot.
Expand All @@ -33,9 +34,13 @@ class CESIUMGLTF_API SharedAsset : public CesiumUtility::ExtensibleObject {
_pDepot(nullptr),
_uniqueAssetId() {}

// Move construction is not allowed, because existing references to this
// shared asset would be affected as well.
SharedAsset(SharedAsset&& rhs) = delete;
// After a move construction, the content of the asset is moved to the new
// instance, but the asset depot still references the old instance.
SharedAsset(SharedAsset&& rhs)
: ExtensibleObject(std::move(rhs)),
_referenceCount(0),
_pDepot(nullptr),
_uniqueAssetId() {}

// Assignment does not affect the asset's relationship with the depot, but is
// useful to assign the data in derived classes.
Expand Down

0 comments on commit a88d83f

Please sign in to comment.