OpenUSD icon indicating copy to clipboard operation
OpenUSD copied to clipboard

[Plug] Update TF_FOR_ALL to C++11 iterator

Open Cewein opened this issue 1 year ago • 4 comments

Description of Change(s)

Update files under pxr/base/plug by replacing TF_FOR_ALL with C++11-style range-based for each loop. Additionally, updated pointer usage to align with the new iterator approach, since we now handle references directly rather than raw pointers.

There is C++17 possibility to be used in some cases but this is left for another discussion.

Obgoing Issue(s)

This PR addresses issue https://github.com/PixarAnimationStudios/OpenUSD/issues/80, though many more instances still need to be resolved. Given the age of this issue (approximately 6–7 years), I wanted to reopen the discussion to evaluate its relevance. Specifically, is the header iterator.h still necessary?

Previous attempts to address this issue (e.g., https://github.com/PixarAnimationStudios/OpenUSD/pull/396) have been closed without further updates to the thread. I look forward to hearing thoughts on whether we should proceed with this.

Checklist

Cewein avatar Jan 31 '25 10:01 Cewein

Specifically, is the header iterator.h still necessary?

The Tf_ProxyReferenceReverseIterator is required until OpenUSD migrates to C++20. I also think there's also not a great drop in replacement for TF_REVERSE_FOR_ALL without std::ranges::views::reverse.

Ranged for otherwise sounds great to me. I would recommend using const TYPE& (or const auto&) whenever possible.

nvmkuruc avatar Jan 31 '25 13:01 nvmkuruc

Filed as internal issue #USD-10625

:heavy_exclamation_mark: Please make sure that a signed CLA has been submitted!

(This is an automated message. See here for more information.)

jesschimein avatar Jan 31 '25 18:01 jesschimein

/AzurePipelines run

jesschimein avatar Jan 31 '25 18:01 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jan 31 '25 18:01 azure-pipelines[bot]