Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,25 +445,25 @@ struct ITK_TEMPLATE_EXPORT Index final
return m_InternalArray[pos];
}

reference
constexpr reference
front()
{
return *begin();
}

const_reference
constexpr const_reference
front() const
{
return *begin();
}

reference
constexpr reference
back()
{
return VDimension ? *(end() - 1) : *end();
}

const_reference
constexpr const_reference
back() const
{
return VDimension ? *(end() - 1) : *end();
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkOffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,25 +397,25 @@ struct ITK_TEMPLATE_EXPORT Offset final
return m_InternalArray[pos];
}

reference
constexpr reference
front()
{
return *begin();
}

const_reference
constexpr const_reference
front() const
{
return *begin();
}

reference
constexpr reference
back()
{
return VDimension ? *(end() - 1) : *end();
}

const_reference
constexpr const_reference
back() const
{
return VDimension ? *(end() - 1) : *end();
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,25 +369,25 @@ struct ITK_TEMPLATE_EXPORT Size final
return m_InternalArray[pos];
}

reference
constexpr reference
front()
{
return *begin();
}

const_reference
constexpr const_reference
front() const
{
return *begin();
}

reference
constexpr reference
back()
{
return VDimension ? *(end() - 1) : *end();
}

const_reference
constexpr const_reference
back() const
{
return VDimension ? *(end() - 1) : *end();
Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkIndexGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk
itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk::Index<1>>(),
"Check constexpr begin() and end() of Index.");

static_assert(itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Index<>()) &&
itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Index<1>()),
"Check that `distance(&front, &back) + 1` is equal to `size`");


// Tests that itk::Index::Filled(value) returns an itk::Index with the
// specified value for each element.
Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkOffsetGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk::Offset<>>() &&
itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk::Offset<1>>(),
"Check constexpr begin() and end() of Offset.");

static_assert(itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Offset<>()) &&
itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Offset<1>()),
"Check that `distance(&front, &back) + 1` is equal to `size`");
9 changes: 9 additions & 0 deletions Modules/Core/Common/test/itkRangeGTestUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ class RangeGTestUtilities
}


// Tells if `distance(&front, &back) + 1` is equal to `size`, for the specified container.
template <typename TContainer>
static constexpr bool
IsDistanceFromFrontToBackPlusOneEqualToSize(const TContainer & container)
{
return std::distance(&container.front(), &container.back()) + 1 == container.size();
}


// Checks that each element of the specified range is zero.
template <typename TRange>
static void
Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkSizeGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk
itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk::Size<1>>(),
"Check constexpr begin() and end() of Size.");

static_assert(itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Size<>()) &&
itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Size<1>()),
"Check that `distance(&front, &back) + 1` is equal to `size`");


// Tests that itk::Size::Filled(value) returns an itk::Size with the
// specified value for each element.
Expand Down