Skip to content

Commit

Permalink
cppcoreguidelines-missing-std-forward
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 13, 2024
1 parent f021c49 commit f5e80dd
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 191 deletions.
2 changes: 1 addition & 1 deletion Cesium3DTilesSelection/src/RasterOverlayCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Function>(callback)(*pCurrent);
pCurrent = pNext;
}
}
Expand Down
2 changes: 1 addition & 1 deletion CesiumAsync/include/CesiumAsync/AsyncSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CESIUMASYNC_API AsyncSystem final {
Promise<T> promise(this->_pSchedulers, pEvent);

try {
f(promise);
std::forward<Func>(f)(promise);
} catch (...) {
promise.reject(std::current_exception());
}
Expand Down
1 change: 1 addition & 0 deletions CesiumAsync/include/CesiumAsync/Future.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ template <typename T> class Future final {
*/
template <typename... TPassThrough>
Future<std::tuple<TPassThrough..., T>>
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
thenPassThrough(TPassThrough&&... values) && {
return std::move(*this).thenImmediately(
[values = std::tuple(std::forward<TPassThrough>(values)...)](
Expand Down
1 change: 1 addition & 0 deletions CesiumAsync/include/CesiumAsync/SharedFuture.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ template <typename T> class SharedFuture final {
*/
template <typename... TPassThrough>
Future<std::tuple<TPassThrough..., T>>
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
thenPassThrough(TPassThrough&&... values) {
return this->thenImmediately(
[values = std::tuple(std::forward<TPassThrough>(values)...)](
Expand Down
34 changes: 20 additions & 14 deletions CesiumGltf/include/CesiumGltf/AccessorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,36 +374,37 @@ createAccessorView(
const Accessor& accessor,
TCallback&& callback) {
if (accessor.type == Accessor::Type::SCALAR) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::SCALAR<TElement>>(model, accessor));
}
if (accessor.type == Accessor::Type::VEC2) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::VEC2<TElement>>(model, accessor));
}
if (accessor.type == Accessor::Type::VEC3) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::VEC3<TElement>>(model, accessor));
}
if (accessor.type == Accessor::Type::VEC4) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::VEC4<TElement>>(model, accessor));
}
if (accessor.type == Accessor::Type::MAT2) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::MAT2<TElement>>(model, accessor));
}
if (accessor.type == Accessor::Type::MAT3) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::MAT3<TElement>>(model, accessor));
}
if (accessor.type == Accessor::Type::MAT4) {
return callback(
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::MAT4<TElement>>(model, accessor));
}
// TODO Print a warning here???
return callback(AccessorView<AccessorTypes::SCALAR<TElement>>(
AccessorViewStatus::InvalidType));
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::SCALAR<TElement>>(
AccessorViewStatus::InvalidType));
}
} // namespace CesiumImpl

Expand Down Expand Up @@ -460,8 +461,9 @@ createAccessorView(
accessor,
std::forward<TCallback>(callback));
default:
return callback(AccessorView<AccessorTypes::SCALAR<float>>(
AccessorViewStatus::InvalidComponentType));
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::SCALAR<float>>(
AccessorViewStatus::InvalidComponentType));
}
}

Expand Down Expand Up @@ -489,10 +491,14 @@ createAccessorView(
TCallback&& callback) {
const Accessor* pAccessor = Model::getSafe(&model.accessors, accessorIndex);
if (!pAccessor) {
return callback(AccessorView<AccessorTypes::SCALAR<float>>(
AccessorViewStatus::InvalidComponentType));
return std::forward<TCallback>(callback)(
AccessorView<AccessorTypes::SCALAR<float>>(
AccessorViewStatus::InvalidComponentType));
}

return createAccessorView(model, *pAccessor, callback);
return createAccessorView(
model,
*pAccessor,
std::forward<TCallback>(callback));
}
} // namespace CesiumGltf
50 changes: 25 additions & 25 deletions CesiumGltf/include/CesiumGltf/PropertyAttributeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class PropertyAttributeView {
const std::string& propertyId,
Callback&& callback) const {
if (this->_status != PropertyAttributeViewStatus::Valid) {
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::
Expand All @@ -185,15 +185,15 @@ class PropertyAttributeView {

const ClassProperty* pClassProperty = getClassProperty(propertyId);
if (!pClassProperty) {
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorNonexistentProperty));
return;
}

if (pClassProperty->array) {
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty));
Expand All @@ -209,7 +209,7 @@ class PropertyAttributeView {

bool normalized = pClassProperty->normalized;
if (normalized && !isPropertyComponentTypeInteger(componentType)) {
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorInvalidNormalization));
Expand Down Expand Up @@ -277,7 +277,7 @@ class PropertyAttributeView {
return;
}

callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty));
Expand Down Expand Up @@ -381,47 +381,47 @@ class PropertyAttributeView {
Callback&& callback) const {
switch (componentType) {
case PropertyComponentType::Int8:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<int8_t, Normalized>(
primitive,
propertyId,
classProperty));
return;
case PropertyComponentType::Uint8:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<uint8_t, Normalized>(
primitive,
propertyId,
classProperty));
return;
case PropertyComponentType::Int16:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<int16_t, Normalized>(
primitive,
propertyId,
classProperty));
return;
case PropertyComponentType::Uint16:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<uint16_t, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Float32:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<float, false>(
primitive,
propertyId,
classProperty));
break;
default:
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty));
Expand All @@ -438,47 +438,47 @@ class PropertyAttributeView {
Callback&& callback) const {
switch (componentType) {
case PropertyComponentType::Int8:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Uint8:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Int16:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Uint16:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Float32:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::vec<N, float>, false>(
primitive,
propertyId,
classProperty));
break;
default:
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty));
Expand Down Expand Up @@ -521,7 +521,7 @@ class PropertyAttributeView {
std::forward<Callback>(callback));
break;
default:
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorTypeMismatch));
Expand All @@ -538,47 +538,47 @@ class PropertyAttributeView {
Callback&& callback) const {
switch (componentType) {
case PropertyComponentType::Int8:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::mat<N, N, int8_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Uint8:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::mat<N, N, uint8_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Int16:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::mat<N, N, int16_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Uint16:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::mat<N, N, uint16_t>, Normalized>(
primitive,
propertyId,
classProperty));
break;
case PropertyComponentType::Float32:
callback(
std::forward<Callback>(callback)(
propertyId,
getPropertyViewImpl<glm::mat<N, N, float>, false>(
primitive,
propertyId,
classProperty));
break;
default:
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorUnsupportedProperty));
Expand Down Expand Up @@ -621,7 +621,7 @@ class PropertyAttributeView {
std::forward<Callback>(callback));
break;
default:
callback(
std::forward<Callback>(callback)(
propertyId,
PropertyAttributePropertyView<uint8_t>(
PropertyAttributePropertyViewStatus::ErrorTypeMismatch));
Expand Down
Loading

0 comments on commit f5e80dd

Please sign in to comment.