diff --git a/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp b/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp index f13fcbb6d..3f748a6ce 100644 --- a/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp +++ b/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp @@ -35,7 +35,7 @@ void forEachTile(Tile::LoadedLinkedList& list, Function callback) { Tile* pCurrent = list.head(); while (pCurrent) { Tile* pNext = list.next(pCurrent); - callback(*pCurrent); + std::forward(callback)(*pCurrent); pCurrent = pNext; } } diff --git a/CesiumAsync/include/CesiumAsync/AsyncSystem.h b/CesiumAsync/include/CesiumAsync/AsyncSystem.h index 4ce4ac961..466b51fe5 100644 --- a/CesiumAsync/include/CesiumAsync/AsyncSystem.h +++ b/CesiumAsync/include/CesiumAsync/AsyncSystem.h @@ -69,7 +69,7 @@ class CESIUMASYNC_API AsyncSystem final { Promise promise(this->_pSchedulers, pEvent); try { - f(promise); + std::forward(f)(promise); } catch (...) { promise.reject(std::current_exception()); } diff --git a/CesiumAsync/include/CesiumAsync/Future.h b/CesiumAsync/include/CesiumAsync/Future.h index e6a4936e4..462f8c9ea 100644 --- a/CesiumAsync/include/CesiumAsync/Future.h +++ b/CesiumAsync/include/CesiumAsync/Future.h @@ -214,6 +214,7 @@ template class Future final { */ template Future> + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) thenPassThrough(TPassThrough&&... values) && { return std::move(*this).thenImmediately( [values = std::tuple(std::forward(values)...)]( diff --git a/CesiumAsync/include/CesiumAsync/SharedFuture.h b/CesiumAsync/include/CesiumAsync/SharedFuture.h index 54183239a..789f49a79 100644 --- a/CesiumAsync/include/CesiumAsync/SharedFuture.h +++ b/CesiumAsync/include/CesiumAsync/SharedFuture.h @@ -201,6 +201,7 @@ template class SharedFuture final { */ template Future> + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) thenPassThrough(TPassThrough&&... values) { return this->thenImmediately( [values = std::tuple(std::forward(values)...)]( diff --git a/CesiumGltf/include/CesiumGltf/AccessorView.h b/CesiumGltf/include/CesiumGltf/AccessorView.h index 71eafb043..011670b9f 100644 --- a/CesiumGltf/include/CesiumGltf/AccessorView.h +++ b/CesiumGltf/include/CesiumGltf/AccessorView.h @@ -374,36 +374,37 @@ createAccessorView( const Accessor& accessor, TCallback&& callback) { if (accessor.type == Accessor::Type::SCALAR) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } if (accessor.type == Accessor::Type::VEC2) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } if (accessor.type == Accessor::Type::VEC3) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } if (accessor.type == Accessor::Type::VEC4) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } if (accessor.type == Accessor::Type::MAT2) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } if (accessor.type == Accessor::Type::MAT3) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } if (accessor.type == Accessor::Type::MAT4) { - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); } // TODO Print a warning here??? - return callback(AccessorView>( - AccessorViewStatus::InvalidType)); + return std::forward(callback)( + AccessorView>( + AccessorViewStatus::InvalidType)); } } // namespace CesiumImpl @@ -460,8 +461,9 @@ createAccessorView( accessor, std::forward(callback)); default: - return callback(AccessorView>( - AccessorViewStatus::InvalidComponentType)); + return std::forward(callback)( + AccessorView>( + AccessorViewStatus::InvalidComponentType)); } } @@ -489,10 +491,14 @@ createAccessorView( TCallback&& callback) { const Accessor* pAccessor = Model::getSafe(&model.accessors, accessorIndex); if (!pAccessor) { - return callback(AccessorView>( - AccessorViewStatus::InvalidComponentType)); + return std::forward(callback)( + AccessorView>( + AccessorViewStatus::InvalidComponentType)); } - return createAccessorView(model, *pAccessor, callback); + return createAccessorView( + model, + *pAccessor, + std::forward(callback)); } } // namespace CesiumGltf diff --git a/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h b/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h index c6997488f..1e1573bbd 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h @@ -175,7 +175,7 @@ class PropertyAttributeView { const std::string& propertyId, Callback&& callback) const { if (this->_status != PropertyAttributeViewStatus::Valid) { - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus:: @@ -185,7 +185,7 @@ class PropertyAttributeView { const ClassProperty* pClassProperty = getClassProperty(propertyId); if (!pClassProperty) { - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorNonexistentProperty)); @@ -193,7 +193,7 @@ class PropertyAttributeView { } if (pClassProperty->array) { - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty)); @@ -209,7 +209,7 @@ class PropertyAttributeView { bool normalized = pClassProperty->normalized; if (normalized && !isPropertyComponentTypeInteger(componentType)) { - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorInvalidNormalization)); @@ -277,7 +277,7 @@ class PropertyAttributeView { return; } - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty)); @@ -381,7 +381,7 @@ class PropertyAttributeView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( primitive, @@ -389,7 +389,7 @@ class PropertyAttributeView { classProperty)); return; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( primitive, @@ -397,7 +397,7 @@ class PropertyAttributeView { classProperty)); return; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( primitive, @@ -405,7 +405,7 @@ class PropertyAttributeView { classProperty)); return; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( primitive, @@ -413,7 +413,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( primitive, @@ -421,7 +421,7 @@ class PropertyAttributeView { classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty)); @@ -438,7 +438,7 @@ class PropertyAttributeView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -446,7 +446,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -454,7 +454,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -462,7 +462,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -470,7 +470,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( primitive, @@ -478,7 +478,7 @@ class PropertyAttributeView { classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty)); @@ -521,7 +521,7 @@ class PropertyAttributeView { std::forward(callback)); break; default: - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorTypeMismatch)); @@ -538,7 +538,7 @@ class PropertyAttributeView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -546,7 +546,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -554,7 +554,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -562,7 +562,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( primitive, @@ -570,7 +570,7 @@ class PropertyAttributeView { classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( primitive, @@ -578,7 +578,7 @@ class PropertyAttributeView { classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty)); @@ -621,7 +621,7 @@ class PropertyAttributeView { std::forward(callback)); break; default: - callback( + std::forward(callback)( propertyId, PropertyAttributePropertyView( PropertyAttributePropertyViewStatus::ErrorTypeMismatch)); diff --git a/CesiumGltf/include/CesiumGltf/PropertyTableView.h b/CesiumGltf/include/CesiumGltf/PropertyTableView.h index 22504e133..05f75fde9 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTableView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTableView.h @@ -177,7 +177,7 @@ class PropertyTableView { void getPropertyView(const std::string& propertyId, Callback&& callback) const { if (this->size() <= 0) { - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorInvalidPropertyTable)); @@ -186,7 +186,7 @@ class PropertyTableView { const ClassProperty* pClassProperty = getClassProperty(propertyId); if (!pClassProperty) { - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorNonexistentProperty)); @@ -203,7 +203,7 @@ class PropertyTableView { bool normalized = pClassProperty->normalized; if (normalized && !isPropertyComponentTypeInteger(componentType)) { // Only integer components may be normalized. - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorInvalidNormalization)); @@ -285,7 +285,7 @@ class PropertyTableView { } if (type == PropertyType::String) { - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -294,13 +294,13 @@ class PropertyTableView { } if (type == PropertyType::Boolean) { - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, *pClassProperty)); return; } - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorTypeMismatch)); @@ -342,77 +342,77 @@ class PropertyTableView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); break; case PropertyComponentType::Float64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorComponentTypeMismatch)); @@ -428,77 +428,77 @@ class PropertyTableView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Int64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl>, false>( propertyId, classProperty)); break; case PropertyComponentType::Float64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl>, false>( propertyId, classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorComponentTypeMismatch)); @@ -537,7 +537,7 @@ class PropertyTableView { std::forward(callback)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorTypeMismatch)); @@ -553,77 +553,77 @@ class PropertyTableView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Int64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Uint64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl< PropertyArrayView>, Normalized>(propertyId, classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl>, false>( propertyId, classProperty)); break; case PropertyComponentType::Float64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl>, false>( propertyId, classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorComponentTypeMismatch)); @@ -662,7 +662,7 @@ class PropertyTableView { std::forward(callback)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorTypeMismatch)); @@ -698,20 +698,20 @@ class PropertyTableView { componentType, std::forward(callback)); } else if (type == PropertyType::Boolean) { - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); } else if (type == PropertyType::String) { - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); } else { - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorTypeMismatch)); @@ -727,77 +727,77 @@ class PropertyTableView { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); break; case PropertyComponentType::Float64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorComponentTypeMismatch)); @@ -836,7 +836,7 @@ class PropertyTableView { std::forward(callback)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorTypeMismatch)); @@ -852,77 +852,77 @@ class PropertyTableView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Int64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Uint64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); break; case PropertyComponentType::Float64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, false>( propertyId, classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorComponentTypeMismatch)); @@ -961,7 +961,7 @@ class PropertyTableView { std::forward(callback)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorTypeMismatch)); @@ -977,57 +977,57 @@ class PropertyTableView { Callback&& callback) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); return; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); return; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); return; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; case PropertyComponentType::Int64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; case PropertyComponentType::Uint64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; case PropertyComponentType::Float64: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl(propertyId, classProperty)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTablePropertyView( PropertyTablePropertyViewStatus::ErrorComponentTypeMismatch)); diff --git a/CesiumGltf/include/CesiumGltf/PropertyTextureView.h b/CesiumGltf/include/CesiumGltf/PropertyTextureView.h index 55c87ea8e..9f887962a 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTextureView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTextureView.h @@ -165,7 +165,7 @@ class PropertyTextureView { Callback&& callback, const TextureViewOptions& propertyOptions = TextureViewOptions()) const { if (this->_status != PropertyTextureViewStatus::Valid) { - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorInvalidPropertyTexture)); @@ -174,7 +174,7 @@ class PropertyTextureView { const ClassProperty* pClassProperty = getClassProperty(propertyId); if (!pClassProperty) { - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorNonexistentProperty)); @@ -191,7 +191,7 @@ class PropertyTextureView { bool normalized = pClassProperty->normalized; if (normalized && !isPropertyComponentTypeInteger(componentType)) { // Only integer components may be normalized. - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorInvalidNormalization)); @@ -259,7 +259,7 @@ class PropertyTextureView { return; } - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorUnsupportedProperty)); @@ -353,7 +353,7 @@ class PropertyTextureView { const TextureViewOptions& propertyOptions) const { // Only scalar arrays are supported. if (type != PropertyType::Scalar) { - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorUnsupportedProperty)); @@ -362,7 +362,7 @@ class PropertyTextureView { int64_t count = classProperty.count.value_or(0); if (count <= 0 || count > 4) { - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorUnsupportedProperty)); @@ -371,7 +371,7 @@ class PropertyTextureView { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -379,7 +379,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -387,7 +387,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -395,7 +395,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -403,7 +403,7 @@ class PropertyTextureView { propertyOptions)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorUnsupportedProperty)); @@ -420,7 +420,7 @@ class PropertyTextureView { const TextureViewOptions& propertyOptions) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -428,7 +428,7 @@ class PropertyTextureView { propertyOptions)); return; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -436,7 +436,7 @@ class PropertyTextureView { propertyOptions)); return; case PropertyComponentType::Int16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -444,7 +444,7 @@ class PropertyTextureView { propertyOptions)); return; case PropertyComponentType::Uint16: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -452,7 +452,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Int32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -460,7 +460,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Uint32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -468,7 +468,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Float32: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl( propertyId, @@ -476,7 +476,7 @@ class PropertyTextureView { propertyOptions)); break; default: - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorUnsupportedProperty)); @@ -493,7 +493,7 @@ class PropertyTextureView { const TextureViewOptions& propertyOptions) const { switch (componentType) { case PropertyComponentType::Int8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -501,7 +501,7 @@ class PropertyTextureView { propertyOptions)); break; case PropertyComponentType::Uint8: - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -510,7 +510,7 @@ class PropertyTextureView { break; case PropertyComponentType::Int16: if constexpr (N == 2) { - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -521,7 +521,7 @@ class PropertyTextureView { [[fallthrough]]; case PropertyComponentType::Uint16: if constexpr (N == 2) { - callback( + std::forward(callback)( propertyId, getPropertyViewImpl, Normalized>( propertyId, @@ -531,7 +531,7 @@ class PropertyTextureView { } [[fallthrough]]; default: - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorUnsupportedProperty)); @@ -574,7 +574,7 @@ class PropertyTextureView { propertyOptions); break; default: - callback( + std::forward(callback)( propertyId, PropertyTexturePropertyView( PropertyTexturePropertyViewStatus::ErrorTypeMismatch)); diff --git a/CesiumGltf/src/Model.cpp b/CesiumGltf/src/Model.cpp index 8896abf82..0db5f3816 100644 --- a/CesiumGltf/src/Model.cpp +++ b/CesiumGltf/src/Model.cpp @@ -440,7 +440,7 @@ void forEachPrimitiveInMeshObject( const Mesh& mesh, TCallback& callback) { for (const MeshPrimitive& primitive : mesh.primitives) { - callback(model, node, mesh, primitive, transform); + std::forward(callback)(model, node, mesh, primitive, transform); } } @@ -549,7 +549,7 @@ void forEachNode( glm::dmat4x4 nodeTransform = transform * getNodeTransform(node).value_or(glm::dmat4x4(1.0)); - callback(model, node, nodeTransform); + std::forward(callback)(model, node, nodeTransform); for (const int32_t childNodeId : node.children) { if (childNodeId >= 0 && size_t(childNodeId) < model.nodes.size()) { @@ -572,7 +572,7 @@ void forEachNodeInSceneObject( if (!pNode) continue; - callback(model, *pNode); + std::forward(callback)(model, *pNode); } } diff --git a/CesiumGltfContent/src/GltfUtilities.cpp b/CesiumGltfContent/src/GltfUtilities.cpp index 2cff6296c..4dd123fdb 100644 --- a/CesiumGltfContent/src/GltfUtilities.cpp +++ b/CesiumGltfContent/src/GltfUtilities.cpp @@ -766,14 +766,15 @@ struct VisitTextureIds { // Find textures in materials for (Material& material : gltf.materials) { if (material.emissiveTexture) - callback(material.emissiveTexture->index); + std::forward(callback)(material.emissiveTexture->index); if (material.normalTexture) - callback(material.normalTexture->index); + std::forward(callback)(material.normalTexture->index); if (material.pbrMetallicRoughness) { if (material.pbrMetallicRoughness->baseColorTexture) - callback(material.pbrMetallicRoughness->baseColorTexture->index); + std::forward(callback)( + material.pbrMetallicRoughness->baseColorTexture->index); if (material.pbrMetallicRoughness->metallicRoughnessTexture) - callback( + std::forward(callback)( material.pbrMetallicRoughness->metallicRoughnessTexture->index); } } @@ -786,7 +787,7 @@ struct VisitTextureIds { if (pMeshFeatures) { for (FeatureId& featureId : pMeshFeatures->featureIds) { if (featureId.texture) - callback(featureId.texture->index); + std::forward(callback)(featureId.texture->index); } } } @@ -797,7 +798,7 @@ struct VisitTextureIds { if (pMetadata) { for (PropertyTexture& propertyTexture : pMetadata->propertyTextures) { for (auto& pair : propertyTexture.properties) { - callback(pair.second.index); + std::forward(callback)(pair.second.index); } } } @@ -808,7 +809,7 @@ struct VisitSamplerIds { template void operator()(Model& gltf, Func&& callback) { // Find samplers in textures for (Texture& texture : gltf.textures) { - callback(texture.sampler); + std::forward(callback)(texture.sampler); } } }; @@ -836,17 +837,17 @@ struct VisitImageIds { template void operator()(Model& gltf, Func&& callback) { // Find images in textures for (Texture& texture : gltf.textures) { - callback(texture.source); + std::forward(callback)(texture.source); ExtensionKhrTextureBasisu* pBasis = texture.getExtension(); if (pBasis) - callback(pBasis->source); + std::forward(callback)(pBasis->source); ExtensionTextureWebp* pWebP = texture.getExtension(); if (pWebP) - callback(pWebP->source); + std::forward(callback)(pWebP->source); } } }; @@ -855,38 +856,38 @@ struct VisitAccessorIds { template void operator()(Model& gltf, Func&& callback) { for (Mesh& mesh : gltf.meshes) { for (MeshPrimitive& primitive : mesh.primitives) { - callback(primitive.indices); + std::forward(callback)(primitive.indices); for (auto& pair : primitive.attributes) { - callback(pair.second); + std::forward(callback)(pair.second); } ExtensionCesiumTileEdges* pTileEdges = primitive.getExtension(); if (pTileEdges) { - callback(pTileEdges->left); - callback(pTileEdges->bottom); - callback(pTileEdges->right); - callback(pTileEdges->top); + std::forward(callback)(pTileEdges->left); + std::forward(callback)(pTileEdges->bottom); + std::forward(callback)(pTileEdges->right); + std::forward(callback)(pTileEdges->top); } ExtensionCesiumPrimitiveOutline* pPrimitiveOutline = primitive.getExtension(); if (pPrimitiveOutline) { - callback(pPrimitiveOutline->indices); + std::forward(callback)(pPrimitiveOutline->indices); } } } for (Animation& animation : gltf.animations) { for (AnimationSampler& sampler : animation.samplers) { - callback(sampler.input); - callback(sampler.output); + std::forward(callback)(sampler.input); + std::forward(callback)(sampler.output); } } for (Skin& skin : gltf.skins) { - callback(skin.inverseBindMatrices); + std::forward(callback)(skin.inverseBindMatrices); } for (Node& node : gltf.nodes) { @@ -894,7 +895,7 @@ struct VisitAccessorIds { node.getExtension(); if (pInstancing) { for (auto& pair : pInstancing->attributes) { - callback(pair.second); + std::forward(callback)(pair.second); } } } @@ -904,16 +905,16 @@ struct VisitAccessorIds { struct VisitBufferViewIds { template void operator()(Model& gltf, Func&& callback) { for (Accessor& accessor : gltf.accessors) { - callback(accessor.bufferView); + std::forward(callback)(accessor.bufferView); if (accessor.sparse) { - callback(accessor.sparse->indices.bufferView); - callback(accessor.sparse->values.bufferView); + std::forward(callback)(accessor.sparse->indices.bufferView); + std::forward(callback)(accessor.sparse->values.bufferView); } } for (Image& image : gltf.images) { - callback(image.bufferView); + std::forward(callback)(image.bufferView); } for (Mesh& mesh : gltf.meshes) { @@ -921,7 +922,7 @@ struct VisitBufferViewIds { ExtensionKhrDracoMeshCompression* pDraco = primitive.getExtension(); if (pDraco) { - callback(pDraco->bufferView); + std::forward(callback)(pDraco->bufferView); } } } @@ -931,9 +932,9 @@ struct VisitBufferViewIds { if (pMetadata) { for (PropertyTable& propertyTable : pMetadata->propertyTables) { for (auto& pair : propertyTable.properties) { - callback(pair.second.values); - callback(pair.second.arrayOffsets); - callback(pair.second.stringOffsets); + std::forward(callback)(pair.second.values); + std::forward(callback)(pair.second.arrayOffsets); + std::forward(callback)(pair.second.stringOffsets); } } } @@ -943,12 +944,12 @@ struct VisitBufferViewIds { struct VisitBufferIds { template void operator()(Model& gltf, Func&& callback) { for (BufferView& bufferView : gltf.bufferViews) { - callback(bufferView.buffer); + std::forward(callback)(bufferView.buffer); ExtensionBufferViewExtMeshoptCompression* pMeshOpt = bufferView.getExtension(); if (pMeshOpt) { - callback(pMeshOpt->buffer); + std::forward(callback)(pMeshOpt->buffer); } } } @@ -957,7 +958,7 @@ struct VisitBufferIds { struct VisitMeshIds { template void operator()(Model& gltf, Func&& callback) { for (Node& node : gltf.nodes) { - callback(node.mesh); + std::forward(callback)(node.mesh); } } }; @@ -966,7 +967,7 @@ struct VisitMaterialIds { template void operator()(Model& gltf, Func&& callback) { for (Mesh& mesh : gltf.meshes) { for (MeshPrimitive& primitive : mesh.primitives) { - callback(primitive.material); + std::forward(callback)(primitive.material); } } } @@ -986,14 +987,16 @@ void removeUnusedElements( } // Determine which elements are used. - visitFunction(gltf, [&usedElements](int32_t elementIndex) { + std::forward( + visitFunction)(gltf, [&usedElements](int32_t elementIndex) { if (elementIndex >= 0 && size_t(elementIndex) < usedElements.size()) usedElements[size_t(elementIndex)] = true; }); // Update the element indices based on the unused indices being removed. std::vector indexMap = getIndexMap(usedElements); - visitFunction(gltf, [&indexMap](int32_t& elementIndex) { + std::forward( + visitFunction)(gltf, [&indexMap](int32_t& elementIndex) { if (elementIndex >= 0 && size_t(elementIndex) < indexMap.size()) { int32_t newIndex = indexMap[size_t(elementIndex)]; CESIUM_ASSERT(newIndex >= 0); @@ -1265,24 +1268,27 @@ createPositionView( switch (accessor.componentType) { case Accessor::ComponentType::BYTE: - return callback(AccessorView>(model, accessor)); + return std::forward(callback)( + AccessorView>(model, accessor)); case Accessor::ComponentType::UNSIGNED_BYTE: - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); case Accessor::ComponentType::SHORT: - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); case Accessor::ComponentType::UNSIGNED_SHORT: - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); case Accessor::ComponentType::UNSIGNED_INT: - return callback( + return std::forward(callback)( AccessorView>(model, accessor)); case Accessor::ComponentType::FLOAT: - return callback(AccessorView>(model, accessor)); + return std::forward(callback)( + AccessorView>(model, accessor)); default: - return callback(AccessorView>( - AccessorViewStatus::InvalidComponentType)); + return std::forward(callback)( + AccessorView>( + AccessorViewStatus::InvalidComponentType)); } }