Don't use std::forward on a variable multiple times

The previous usage was just wrong,
it may have been subtly broken.
This commit is contained in:
Silent 2024-10-14 21:35:03 +02:00
parent 3d205cdf95
commit 2ce34524c4
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
3 changed files with 15 additions and 15 deletions

View File

@ -26,46 +26,46 @@ private:
}; };
template <typename Pred> template <typename Pred>
Pred RwFrameForAllChildren(RwFrame* frame, Pred&& callback) Pred RwFrameForAllChildren(RwFrame* frame, Pred callback)
{ {
for ( RwFrame* curFrame = frame->child; curFrame != nullptr; curFrame = curFrame->next ) for ( RwFrame* curFrame = frame->child; curFrame != nullptr; curFrame = curFrame->next )
{ {
if ( std::forward<Pred>(callback)(curFrame) == nullptr ) if ( callback(curFrame) == nullptr )
break; break;
} }
return std::forward<Pred>(callback); return callback;
} }
template <typename Pred> template <typename Pred>
Pred RwFrameForAllObjects(RwFrame* frame, Pred&& callback) Pred RwFrameForAllObjects(RwFrame* frame, Pred callback)
{ {
for ( RwLLLink* link = rwLinkListGetFirstLLLink(&frame->objectList); link != rwLinkListGetTerminator(&frame->objectList); link = rwLLLinkGetNext(link) ) for ( RwLLLink* link = rwLinkListGetFirstLLLink(&frame->objectList); link != rwLinkListGetTerminator(&frame->objectList); link = rwLLLinkGetNext(link) )
{ {
if ( std::forward<Pred>(callback)(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr ) if ( callback(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr )
break; break;
} }
return std::forward<Pred>(callback); return callback;
} }
template <typename Pred> template <typename Pred>
Pred RpClumpForAllAtomics(RpClump* clump, Pred&& callback) Pred RpClumpForAllAtomics(RpClump* clump, Pred callback)
{ {
for ( RwLLLink* link = rwLinkListGetFirstLLLink(&clump->atomicList); link != rwLinkListGetTerminator(&clump->atomicList); link = rwLLLinkGetNext(link) ) for ( RwLLLink* link = rwLinkListGetFirstLLLink(&clump->atomicList); link != rwLinkListGetTerminator(&clump->atomicList); link = rwLLLinkGetNext(link) )
{ {
if ( std::forward<Pred>(callback)(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr ) if ( callback(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr )
break; break;
} }
return std::forward<Pred>(callback); return callback;
} }
template <typename Pred> template <typename Pred>
Pred RpGeometryForAllMaterials(RpGeometry* geometry, Pred&& callback) Pred RpGeometryForAllMaterials(RpGeometry* geometry, Pred callback)
{ {
for ( RwInt32 i = 0, j = geometry->matList.numMaterials; i < j; i++ ) for ( RwInt32 i = 0, j = geometry->matList.numMaterials; i < j; i++ )
{ {
if ( std::forward<Pred>(callback)(geometry->matList.materials[i]) == nullptr ) if ( callback(geometry->matList.materials[i]) == nullptr )
break; break;
} }
return std::forward<Pred>(callback); return callback;
} }

@ -1 +1 @@
Subproject commit cc5c9df5895e7c0ca0dc087a716f4782635ddcfe Subproject commit d70ae68a8e20c4cbd43f60e45586ce65304c1741

View File

@ -159,7 +159,7 @@ RwFrame* GetFrameFromName( RwFrame* topFrame, const char* name )
foundFrame = frame; foundFrame = frame;
return nullptr; return nullptr;
} }
RwFrameForAllChildren( frame, std::forward<GetFramePredicate>(*this) ); RwFrameForAllChildren(frame, std::ref(*this));
return foundFrame != nullptr ? nullptr : frame; return foundFrame != nullptr ? nullptr : frame;
} }
@ -189,7 +189,7 @@ RwFrame* GetFrameFromID( RwFrame* topFrame, int32_t ID )
foundFrame = frame; foundFrame = frame;
return nullptr; return nullptr;
} }
RwFrameForAllChildren( frame, std::forward<GetFramePredicate>(*this) ); RwFrameForAllChildren(frame, std::ref(*this));
return foundFrame != nullptr ? nullptr : frame; return foundFrame != nullptr ? nullptr : frame;
} }