From 722ac86e6ca513d30ae3e56f287f072302944d0d Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 26 Sep 2024 22:33:11 +0200 Subject: [PATCH] STYLE: Deprecate (`ITK_FUTURE_LEGACY_REMOVE`) `ByteSwapper::OStreamType` The type alias `OStreamType` just served as a workaround to an old MSVC bug. For the record, this old workaround was introduced by commit 3066546a8934c4470d47fe9ffeab8450704b7988 "ENH:Read at least one raw image :-)", Will Schroeder, 9 July 2001. --- Modules/Core/Common/include/itkByteSwapper.h | 18 +++++++++++------- Modules/Core/Common/include/itkByteSwapper.hxx | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Modules/Core/Common/include/itkByteSwapper.h b/Modules/Core/Common/include/itkByteSwapper.h index a60f3bef65c..eb0f0c6f650 100644 --- a/Modules/Core/Common/include/itkByteSwapper.h +++ b/Modules/Core/Common/include/itkByteSwapper.h @@ -58,8 +58,12 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object using Pointer = SmartPointer; using ConstPointer = SmartPointer; - /** Work around MSVC bug (including ByteSwapper.h in a templated class). */ - using OStreamType = std::ostream; +#ifndef ITK_FUTURE_LEGACY_REMOVE + /** Work around old MSVC bug (including ByteSwapper.h in a templated class). */ + using OStreamType + [[deprecated("ByteSwapper::OStreamType is deprecated from ITK 6. Just use `std::ostream` instead!")]] = + std::ostream; +#endif /** \see LightObject::GetNameOfClass() */ itkOverrideGetNameOfClassMacro(ByteSwapper); @@ -117,7 +121,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object * others raise an exception. The method is used to * swap to and from Big Endian. */ static void - SwapWriteRangeFromSystemToBigEndian(const T * p, int num, OStreamType * fp); + SwapWriteRangeFromSystemToBigEndian(const T * p, int num, std::ostream * fp); /** Generic swap method handles type T. The swapping is * done in-place. 2, 4 and 8 byte swapping @@ -143,7 +147,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object * others raise an exception. The method is used to * swap to and from Little Endian. */ static void - SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, OStreamType * fp); + SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, std::ostream * fp); protected: ByteSwapper() = default; @@ -161,7 +165,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object /** Swap and write a range of two-byte words. Num is the number of two-byte * words to swap and write. */ static void - SwapWrite2Range(const void * ptr, BufferSizeType num, OStreamType * fp); + SwapWrite2Range(const void * ptr, BufferSizeType num, std::ostream * fp); /** Swap four bytes. */ static void @@ -175,7 +179,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object /** Swap and write a range of four-byte words. Num is the number of four-byte * words to swap and write. */ static void - SwapWrite4Range(const void * ptr, BufferSizeType num, OStreamType * fp); + SwapWrite4Range(const void * ptr, BufferSizeType num, std::ostream * fp); /** Swap 8 bytes. */ static void @@ -189,7 +193,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object /** Swap and write a range of 8-byte words. Num is the number of four-byte * words to swap and write. */ static void - SwapWrite8Range(const void * ptr, BufferSizeType num, OStreamType * fp); + SwapWrite8Range(const void * ptr, BufferSizeType num, std::ostream * fp); private: /** Swaps the bytes of the specified argument in-place. Assumes that its number of bytes is either 2, 4, or 8. diff --git a/Modules/Core/Common/include/itkByteSwapper.hxx b/Modules/Core/Common/include/itkByteSwapper.hxx index ddc461f8d26..1b550403325 100644 --- a/Modules/Core/Common/include/itkByteSwapper.hxx +++ b/Modules/Core/Common/include/itkByteSwapper.hxx @@ -63,7 +63,7 @@ ByteSwapper::SwapRangeFromSystemToBigEndian([[maybe_unused]] T * p, [[maybe_u template void -ByteSwapper::SwapWriteRangeFromSystemToBigEndian(const T * p, int num, OStreamType * fp) +ByteSwapper::SwapWriteRangeFromSystemToBigEndian(const T * p, int num, std::ostream * fp) { if constexpr (m_SystemIsBigEndian) { @@ -116,7 +116,7 @@ ByteSwapper::SwapRangeFromSystemToLittleEndian([[maybe_unused]] T * p, [[mayb template void -ByteSwapper::SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, OStreamType * fp) +ByteSwapper::SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, std::ostream * fp) { if constexpr (m_SystemIsBigEndian) { @@ -175,7 +175,7 @@ ByteSwapper::Swap2Range(void * ptr, BufferSizeType num) // Swap bunch of bytes. Num is the number of four byte words to swap. template void -ByteSwapper::SwapWrite2Range(const void * ptr, BufferSizeType num, OStreamType * fp) +ByteSwapper::SwapWrite2Range(const void * ptr, BufferSizeType num, std::ostream * fp) { BufferSizeType chunkSize = 1000000; if (num < chunkSize) @@ -228,7 +228,7 @@ ByteSwapper::Swap4Range(void * ptr, BufferSizeType num) // Swap bunch of bytes. Num is the number of four byte words to swap. template void -ByteSwapper::SwapWrite4Range(const void * ptr, BufferSizeType num, OStreamType * fp) +ByteSwapper::SwapWrite4Range(const void * ptr, BufferSizeType num, std::ostream * fp) { BufferSizeType chunkSize = 1000000; @@ -286,7 +286,7 @@ ByteSwapper::Swap8Range(void * ptr, BufferSizeType num) // Swap bunch of bytes. Num is the number of four byte words to swap. template void -ByteSwapper::SwapWrite8Range(const void * ptr, BufferSizeType num, OStreamType * fp) +ByteSwapper::SwapWrite8Range(const void * ptr, BufferSizeType num, std::ostream * fp) { BufferSizeType chunkSize = 1000000; if (num < chunkSize)