Skip to content

Commit

Permalink
STYLE: Remove std:: prefix from types that work without it
Browse files Browse the repository at this point in the history
This is accomplished with
cd git/ITK
find * -type f |
  egrep '\.(c|cc|cxx|cpp|h|hh|hxx|hpp)$' |
  fgrep -v ThirdParty |
  fgrep -v itkIntTypes.h |
  xargs sed -i -r -e \
    's/std::((size|ptrdiff|max_align|u?int(_fast|_least|max|ptr)?[0-9]*)_t)/\1/g'
  • Loading branch information
Leengit authored and hjmjohnson committed Mar 6, 2022
1 parent cef0b65 commit c173dfd
Show file tree
Hide file tree
Showing 44 changed files with 149 additions and 150 deletions.
2 changes: 1 addition & 1 deletion Examples/IO/DicomSeriesReadSeriesWrite.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ main(int argc, char * argv[])
namesGenerator->GetInputFileNames();
// Software Guide : EndCodeSnippet

std::size_t numberOfFileNames = filenames.size();
size_t numberOfFileNames = filenames.size();
std::cout << numberOfFileNames << std::endl;
for (unsigned int fni = 0; fni < numberOfFileNames; ++fni)
{
Expand Down
2 changes: 1 addition & 1 deletion Examples/IO/IOFactoryRegistration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ main()
{
const std::list<itk::ObjectFactoryBase *> & factories =
itk::ObjectFactoryBase::GetRegisteredFactories();
const std::size_t numFactories = factories.size();
const size_t numFactories = factories.size();

std::cout << numFactories << " Image IO factories registered:" << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion Examples/IO/IOPlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ main(int argc, char * argv[])
// List all registered factories
std::list<itk::ObjectFactoryBase *> factories =
itk::ObjectFactoryBase::GetRegisteredFactories();
const std::size_t numFactories = factories.size();
const size_t numFactories = factories.size();

std::cout << "----- Registered factories -----" << std::endl;
std::cout << "Count: " << numFactories << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions Modules/Compatibility/Deprecated/include/itkAtomicInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ class AtomicInt<T *>
}

T *
operator+=(std::ptrdiff_t val)
operator+=(ptrdiff_t val)
{
return reinterpret_cast<T *>(m_Object += val * sizeof(T));
}

T *
operator-=(std::ptrdiff_t val)
operator-=(ptrdiff_t val)
{
return reinterpret_cast<T *>(m_Object -= val * sizeof(T));
}
Expand Down
52 changes: 26 additions & 26 deletions Modules/Core/Common/include/itkConnectedImageNeighborhoodShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace itk
* neighborhood shape, including the center pixel, and asserts that the result
* is as expected:
\code
std::size_t maximumCityblockDistance = 2;
size_t maximumCityblockDistance = 2;
bool includeCenterPixel = true;
ConnectedImageNeighborhoodShape<3> shape{ maximumCityblockDistance, includeCenterPixel };
std::vector<Offset<3>> offsets = GenerateImageNeighborhoodOffsets(shape);
Expand Down Expand Up @@ -110,16 +110,16 @@ class ConnectedImageNeighborhoodShape
* The parameter 'includeCenterPixel' specifies whether or not the center
* pixel (offset zero) should be included with the offsets for this shape.
*/
constexpr explicit ConnectedImageNeighborhoodShape(const std::size_t maximumCityblockDistance,
const bool includeCenterPixel) noexcept
constexpr explicit ConnectedImageNeighborhoodShape(const size_t maximumCityblockDistance,
const bool includeCenterPixel) noexcept
: m_MaximumCityblockDistance{ maximumCityblockDistance }
, m_IncludeCenterPixel{ includeCenterPixel }
, m_NumberOfOffsets{ CalculateNumberOfOffsets(maximumCityblockDistance, includeCenterPixel) }
{}


/** Returns the number of offsets needed for this shape. */
constexpr std::size_t
constexpr size_t
GetNumberOfOffsets() const noexcept
{
return m_NumberOfOffsets;
Expand All @@ -136,12 +136,12 @@ class ConnectedImageNeighborhoodShape
Offset<ImageDimension> offset;
std::fill_n(offset.begin(), ImageDimension, -1);

std::size_t i = 0;
size_t i = 0;

while (i < m_NumberOfOffsets)
{
const std::size_t numberOfNonZeroOffsetValues =
ImageDimension - static_cast<std::size_t>(std::count(offset.begin(), offset.end(), 0));
const size_t numberOfNonZeroOffsetValues =
ImageDimension - static_cast<size_t>(std::count(offset.begin(), offset.end(), 0));

if ((m_IncludeCenterPixel || (numberOfNonZeroOffsetValues > 0)) &&
(numberOfNonZeroOffsetValues <= m_MaximumCityblockDistance))
Expand Down Expand Up @@ -170,41 +170,41 @@ class ConnectedImageNeighborhoodShape
private:
// The maximum city-block distance (Manhattan distance) between the center
// pixel and each connected neighbor pixel.
std::size_t m_MaximumCityblockDistance;
size_t m_MaximumCityblockDistance;

// Specifies whether or not the center pixel (offset zero) should be included
// with the offsets for this shape.
bool m_IncludeCenterPixel;

// The number of offsets needed to represent this shape.
std::size_t m_NumberOfOffsets;
size_t m_NumberOfOffsets;


// Calculates a + b. Numeric overflow triggers a compilation error in
// "constexpr context" and a debug assert failure at run-time.
static constexpr std::uintmax_t
CalculateSum(const std::uintmax_t a, const std::uintmax_t b) noexcept
static constexpr uintmax_t
CalculateSum(const uintmax_t a, const uintmax_t b) noexcept
{
return ((a + b) >= a) && ((a + b) >= b) ? (a + b) : (ITK_X_ASSERT(!"CalculateSum overflow!"), 0);
}


// Calculates 2 ^ n. Numeric overflow triggers a compilation error in
// "constexpr context" and a debug assert failure at run-time.
static constexpr std::uintmax_t
CalculatePowerOfTwo(const std::size_t n) noexcept
static constexpr uintmax_t
CalculatePowerOfTwo(const size_t n) noexcept
{
return (n < std::numeric_limits<std::uintmax_t>::digits) ? (std::uintmax_t{ 1 } << n)
: (ITK_X_ASSERT(!"CalculatePowerOfTwo overflow!"), 0);
return (n < std::numeric_limits<uintmax_t>::digits) ? (uintmax_t{ 1 } << n)
: (ITK_X_ASSERT(!"CalculatePowerOfTwo overflow!"), 0);
}


// Calculates the binomial coefficient, 'n' over 'k'.
// Inspired by the 'binom' function from Walter, June 23, 2017:
// https://stackoverflow.com/questions/44718971/calculate-binomial-coffeficient-very-reliable/44719165#44719165
// Optimized for small values of 'k' (k <= n/2).
static constexpr std::uintmax_t
CalculateBinomialCoefficient(const std::uintmax_t n, const std::uintmax_t k) noexcept
static constexpr uintmax_t
CalculateBinomialCoefficient(const uintmax_t n, const uintmax_t k) noexcept
{
return (k > n) ? (ITK_X_ASSERT(!"Out of range!"), 0)
: (k == 0) ? 1 : Math::UnsignedProduct(n, CalculateBinomialCoefficient(n - 1, k - 1)) / k;
Expand All @@ -214,8 +214,8 @@ class ConnectedImageNeighborhoodShape
// Calculates the number of m-dimensional hypercubes on the boundary of an
// n-cube, as described at https://en.wikipedia.org/wiki/Hypercube#Elements
// (Which refers to H.S.M. Coxeter, Regular polytopes, 3rd ed., 1973, p.120.)
static constexpr std::size_t
CalculateNumberOfHypercubesOnBoundaryOfCube(const std::size_t m, const std::size_t n) noexcept
static constexpr size_t
CalculateNumberOfHypercubesOnBoundaryOfCube(const size_t m, const size_t n) noexcept
{
// Calculate 2^(n-m) * BinomialCoefficient(n, m)
return Math::UnsignedProduct(CalculatePowerOfTwo(n - m),
Expand All @@ -229,8 +229,8 @@ class ConnectedImageNeighborhoodShape


// Iterates recursively from i = ImageDimension-1 down to m (inclusive).
static constexpr std::size_t
CalculateSumOfNumberOfHypercubesOnBoundaryOfCube(const std::size_t i, const std::size_t m) noexcept
static constexpr size_t
CalculateSumOfNumberOfHypercubesOnBoundaryOfCube(const size_t i, const size_t m) noexcept
{
return ITK_X_ASSERT(i >= m),
CalculateSum(CalculateNumberOfHypercubesOnBoundaryOfCube(i, ImageDimension),
Expand All @@ -239,8 +239,8 @@ class ConnectedImageNeighborhoodShape


/** Calculates the number of neighbors connected to the center pixel. */
static constexpr std::size_t
CalculateNumberOfConnectedNeighbors(const std::size_t maximumCityblockDistance) noexcept
static constexpr size_t
CalculateNumberOfConnectedNeighbors(const size_t maximumCityblockDistance) noexcept
{
return (((maximumCityblockDistance == 0) || (ImageDimension == 0))
? 0
Expand All @@ -252,16 +252,16 @@ class ConnectedImageNeighborhoodShape


/** Calculates the number of offsets needed for this shape. */
static constexpr std::size_t
CalculateNumberOfOffsets(const std::size_t maximumCityblockDistance, const bool includeCenterPixel) noexcept
static constexpr size_t
CalculateNumberOfOffsets(const size_t maximumCityblockDistance, const bool includeCenterPixel) noexcept
{
return (includeCenterPixel ? 1 : 0) + CalculateNumberOfConnectedNeighbors(maximumCityblockDistance);
}
};


/** Generates the offsets for a connected image neighborhood shape. */
template <unsigned int VImageDimension, std::size_t VMaximumCityblockDistance, bool VIncludeCenterPixel>
template <unsigned int VImageDimension, size_t VMaximumCityblockDistance, bool VIncludeCenterPixel>
auto
GenerateConnectedImageNeighborhoodShapeOffsets() noexcept
{
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/Common/include/itkImageBufferRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class ImageBufferRange final

public:
// Types conforming the iterator requirements of the C++ standard library:
using difference_type = std::ptrdiff_t;
using difference_type = ptrdiff_t;
using value_type = PixelType;
using reference = std::conditional_t<SupportsDirectPixelAccess, QualifiedPixelType &, PixelProxy<IsImageTypeConst>>;
using pointer = QualifiedPixelType *;
Expand Down Expand Up @@ -635,7 +635,7 @@ class ImageBufferRange final


/** Returns the size of the range, that is the number of pixels. */
std::size_t
size_t
size() const noexcept
{
return m_NumberOfPixels;
Expand All @@ -654,12 +654,12 @@ class ImageBufferRange final
* \note The return type QualifiedIterator<false>::reference is equivalent to
* iterator::reference.
*/
typename QualifiedIterator<false>::reference operator[](const std::size_t n) const noexcept
typename QualifiedIterator<false>::reference operator[](const size_t n) const noexcept
{
assert(n < this->size());
assert(n <= static_cast<std::size_t>(std::numeric_limits<std::ptrdiff_t>::max()));
assert(n <= static_cast<size_t>(std::numeric_limits<ptrdiff_t>::max()));

return this->begin()[static_cast<std::ptrdiff_t>(n)];
return this->begin()[static_cast<ptrdiff_t>(n)];
}
};

Expand Down
14 changes: 7 additions & 7 deletions Modules/Core/Common/include/itkImageRegionRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ImageRegionRange final
, m_IterationRegionSize(regionSize)
{}

template <std::size_t VIndex>
template <size_t VIndex>
void Increment(std::true_type) noexcept
{
static_assert(VIndex < (ImageDimension - 1), "For a larger index value, the other overload should be picked");
Expand All @@ -160,7 +160,7 @@ class ImageRegionRange final
}
}

template <std::size_t VIndex>
template <size_t VIndex>
void Increment(std::false_type) noexcept
{
static_assert(VIndex == (ImageDimension - 1), "For a smaller index value, the other overload should be picked");
Expand All @@ -170,7 +170,7 @@ class ImageRegionRange final
}


template <std::size_t VIndex>
template <size_t VIndex>
void Decrement(std::true_type) noexcept
{
static_assert(VIndex < (ImageDimension - 1), "For a larger index value, the other overload should be picked");
Expand All @@ -185,7 +185,7 @@ class ImageRegionRange final
}
}

template <std::size_t VIndex>
template <size_t VIndex>
void Decrement(std::false_type) noexcept
{
static_assert(VIndex == (ImageDimension - 1), "For a smaller index value, the other overload should be picked");
Expand All @@ -197,7 +197,7 @@ class ImageRegionRange final

public:
// Types conforming the iterator requirements of the C++ standard library:
using difference_type = std::ptrdiff_t;
using difference_type = ptrdiff_t;
using value_type = typename std::iterator_traits<QualifiedBufferIteratorType>::value_type;
using reference = typename std::iterator_traits<QualifiedBufferIteratorType>::reference;
using pointer = typename std::iterator_traits<QualifiedBufferIteratorType>::pointer;
Expand Down Expand Up @@ -439,11 +439,11 @@ class ImageRegionRange final


/** Returns the size of the range, that is the number of pixels in the region. */
std::size_t
size_t
size() const noexcept
{
return std::accumulate(
m_IterationRegionSize.begin(), m_IterationRegionSize.end(), std::size_t{ 1 }, std::multiplies<std::size_t>{});
m_IterationRegionSize.begin(), m_IterationRegionSize.end(), size_t{ 1 }, std::multiplies<size_t>{});
}


Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ struct ITK_TEMPLATE_EXPORT Index final
using iterator = value_type *;
using const_iterator = const value_type *;
using size_type = unsigned int;
using difference_type = std::ptrdiff_t;
using difference_type = ptrdiff_t;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkIndexRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class IndexRange final
{
public:
// Types conforming the iterator requirements of the C++ standard library:
using difference_type = std::ptrdiff_t;
using difference_type = ptrdiff_t;
using value_type = IndexType;
using reference = const IndexType &;
using pointer = const IndexType *;
Expand Down Expand Up @@ -386,10 +386,10 @@ class IndexRange final


/** Returns the size of the range, that is the number of indices. */
std::size_t
size_t
size() const noexcept
{
std::size_t result = 1;
size_t result = 1;

for (unsigned int i = 0; i < VDimension; ++i)
{
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/Common/include/itkMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ GreatestPrimeFactor(unsigned long long n);
/** Returns `a * b`. Numeric overflow triggers a compilation error in
* "constexpr context" and a debug assert failure at run-time.
*/
template <typename TReturnType = std::uintmax_t>
template <typename TReturnType = uintmax_t>
constexpr TReturnType
UnsignedProduct(const std::uintmax_t a, const std::uintmax_t b) noexcept
UnsignedProduct(const uintmax_t a, const uintmax_t b) noexcept
{
static_assert(std::is_unsigned<TReturnType>::value, "UnsignedProduct only supports unsigned return types");

Expand All @@ -789,14 +789,14 @@ UnsignedProduct(const std::uintmax_t a, const std::uintmax_t b) noexcept

/** Calculates base ^ exponent. Numeric overflow triggers a compilation error in
* "constexpr context" and a debug assert failure at run-time. Otherwise equivalent to
* C++11 `static_cast<std::uintmax_t>(std::pow(base, exponent))`
* C++11 `static_cast<uintmax_t>(std::pow(base, exponent))`
*
* \note `UnsignedPower(0, 0)` is not supported, as zero to the power of zero has
* no agreed-upon value: https://en.wikipedia.org/wiki/Zero_to_the_power_of_zero
*/
template <typename TReturnType = std::uintmax_t>
template <typename TReturnType = uintmax_t>
constexpr TReturnType
UnsignedPower(const std::uintmax_t base, const std::uintmax_t exponent) noexcept
UnsignedPower(const uintmax_t base, const uintmax_t exponent) noexcept
{
static_assert(std::is_unsigned<TReturnType>::value, "UnsignedPower only supports unsigned return types");

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkNumericTraitsArrayPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class NumericTraits<Array<T>>
}

/** Get the length of the input array. */
static std::size_t
static size_t
GetLength(const Array<T> & m)
{
return m.GetSize();
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkOffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ struct ITK_TEMPLATE_EXPORT Offset final
using iterator = value_type *;
using const_iterator = const value_type *;
using size_type = unsigned int;
using difference_type = std::ptrdiff_t;
using difference_type = ptrdiff_t;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class RectangularImageNeighborhoodShape


/** Returns the number of offsets needed to represent this shape. */
constexpr std::size_t
constexpr size_t
GetNumberOfOffsets() const noexcept
{
return m_NumberOfOffsets;
Expand All @@ -83,7 +83,7 @@ class RectangularImageNeighborhoodShape
return -static_cast<OffsetValueType>(radiusValue);
});

for (std::size_t i = 0; i < m_NumberOfOffsets; ++i)
for (size_t i = 0; i < m_NumberOfOffsets; ++i)
{
offsets[i] = offset;

Expand All @@ -108,12 +108,12 @@ class RectangularImageNeighborhoodShape
Size<ImageDimension> m_Radius;

// The number of offsets needed to represent this shape.
std::size_t m_NumberOfOffsets;
size_t m_NumberOfOffsets;


// Private helper function to calculate the number of Offsets by a recursive
// function call. Recursion is necessary for C++11 constexpr.
constexpr std::size_t
constexpr size_t
CalculateNumberOfOffsets(const unsigned int dimension) const noexcept
{
return (dimension == 0)
Expand Down
Loading

0 comments on commit c173dfd

Please sign in to comment.