Skip to content

Add constexpr begin(), end(), cbegin(), cend() to FixedArray, Index, Offset, and Size#3236

Merged
hjmjohnson merged 4 commits intoInsightSoftwareConsortium:masterfrom
N-Dekker:FixedArray-Index-Offset-Size-begin-end-constexpr
Mar 1, 2022
Merged

Add constexpr begin(), end(), cbegin(), cend() to FixedArray, Index, Offset, and Size#3236
hjmjohnson merged 4 commits intoInsightSoftwareConsortium:masterfrom
N-Dekker:FixedArray-Index-Offset-Size-begin-end-constexpr

Conversation

@N-Dekker
Copy link
Contributor

No description provided.

The iterator types of `Index`, `Offset`, and `Size` are just raw pointer
types, and for those types, a function-style cast `T(expression)` is
generally discouraged in C++. Moreover, specifically in the
implementation of the `begin()` and `end()` member functions of `Index`,
`Offset`, and `Size`, casting appeared unnecessary anyway.
Mirrored the corresponding member functions of `std::array`.

Following commit 549a19c "STYLE: Change aggregate classes to mirror std::array", Hans Johnson, 2018-02-12
Added `constexpr` keywords to the `cbegin()`, `begin()`, `cend()`, and
`end()` member functions of `FixedArray`, `Index`, `Offset`, and `Size`.
Allows iterating over their elements at compile-time.
@github-actions github-actions bot added the area:Core Issues affecting the Core module label Feb 27, 2022
@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Feb 28, 2022
@N-Dekker N-Dekker force-pushed the FixedArray-Index-Offset-Size-begin-end-constexpr branch from b3ac69d to 665536e Compare February 28, 2022 17:20
@N-Dekker N-Dekker force-pushed the FixedArray-Index-Offset-Size-begin-end-constexpr branch from 665536e to b7eb203 Compare February 28, 2022 17:43
Added compile-time checks for the `cbegin()`, `begin()`, `cend()`, and
`end()` member functions of `FixedArray`, `Index`, `Offset`, and `Size`.
@N-Dekker N-Dekker force-pushed the FixedArray-Index-Offset-Size-begin-end-constexpr branch from b7eb203 to 9f1c34e Compare February 28, 2022 19:28
@N-Dekker N-Dekker marked this pull request as ready for review March 1, 2022 10:20
@N-Dekker
Copy link
Contributor Author

N-Dekker commented Mar 1, 2022

/azp run ITK.Linux

@hjmjohnson hjmjohnson merged commit 35648fa into InsightSoftwareConsortium:master Mar 1, 2022
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 22, 2024
Follow-up to pull request InsightSoftwareConsortium#3236
commit 47bce26
"ENH: Declare begin(), end() of FixedArray, Index, Offset, Size constexpr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants