Skip to content

Commit 6b58ee8

Browse files
committed
ENH: use std::enable_if instead of itk::mpl::EnableIf
1 parent 2f732c0 commit 6b58ee8

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

Modules/Core/Common/include/itkVariableLengthVector.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
#include <cassert>
2222
#include <algorithm>
23+
#include <type_traits>
2324
#include "itkNumericTraits.h"
2425
#include "itkMetaProgrammingLibrary.h"
25-
#include "itkEnableIf.h"
2626
#include "itkIsBaseOf.h"
2727
#include "itkIsNumber.h"
2828
#include "itkPromoteType.h"
@@ -1052,7 +1052,7 @@ struct GetType
10521052
* \sa \c VariableLengthVectorExpression
10531053
*/
10541054
template <typename TExpr1, typename TExpr2>
1055-
inline typename mpl::EnableIf<mpl::And<mpl::IsArray<TExpr1>, mpl::IsArray<TExpr2>>, unsigned int>::Type
1055+
inline std::enable_if_t<mpl::And<mpl::IsArray<TExpr1>, mpl::IsArray<TExpr2>>::Value, unsigned int>
10561056
GetSize(TExpr1 const & lhs, TExpr2 const & rhs)
10571057
{
10581058
(void)rhs;
@@ -1071,7 +1071,7 @@ GetSize(TExpr1 const & lhs, TExpr2 const & rhs)
10711071
* \sa \c VariableLengthVectorExpression
10721072
*/
10731073
template <typename TExpr1, typename TExpr2>
1074-
inline typename mpl::EnableIf<mpl::And<mpl::IsArray<TExpr1>, mpl::Not<mpl::IsArray<TExpr2>>>, unsigned int>::Type
1074+
inline std::enable_if_t<mpl::And<mpl::IsArray<TExpr1>, mpl::Not<mpl::IsArray<TExpr2>>>::Value, unsigned int>
10751075
GetSize(TExpr1 const & lhs, TExpr2 const & itkNotUsed(rhs))
10761076
{
10771077
return lhs.Size();
@@ -1087,7 +1087,7 @@ GetSize(TExpr1 const & lhs, TExpr2 const & itkNotUsed(rhs))
10871087
* \sa \c VariableLengthVectorExpression
10881088
*/
10891089
template <typename TExpr1, typename TExpr2>
1090-
inline typename mpl::EnableIf<mpl::And<mpl::IsArray<TExpr2>, mpl::Not<mpl::IsArray<TExpr1>>>, unsigned int>::Type
1090+
inline std::enable_if_t<mpl::And<mpl::IsArray<TExpr2>, mpl::Not<mpl::IsArray<TExpr1>>>::Value, unsigned int>
10911091
GetSize(TExpr1 const & itkNotUsed(lhs), TExpr2 const & rhs)
10921092
{
10931093
return rhs.Size();
@@ -1261,8 +1261,8 @@ struct VariableLengthVectorExpression
12611261
* \sa \c mpl::IsArray<> to know the exact array types recognized as \em array by this traits
12621262
*/
12631263
template <typename TExpr1, typename TExpr2>
1264-
inline typename mpl::EnableIf<Details::op::CanBeAddedOrSubtracted<TExpr1, TExpr2>,
1265-
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Plus>>::Type
1264+
inline std::enable_if_t<Details::op::CanBeAddedOrSubtracted<TExpr1, TExpr2>::Value,
1265+
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Plus>>
12661266
operator+(TExpr1 const & lhs, TExpr2 const & rhs)
12671267
{
12681268
return VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Plus>(lhs, rhs);
@@ -1278,8 +1278,8 @@ operator+(TExpr1 const & lhs, TExpr2 const & rhs)
12781278
* \sa \c mpl::IsArray<> to know the exact array types recognized as \em array by this traits
12791279
*/
12801280
template <typename TExpr1, typename TExpr2>
1281-
inline typename mpl::EnableIf<Details::op::CanBeAddedOrSubtracted<TExpr1, TExpr2>,
1282-
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Sub>>::Type
1281+
inline std::enable_if_t<Details::op::CanBeAddedOrSubtracted<TExpr1, TExpr2>::Value,
1282+
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Sub>>
12831283
operator-(TExpr1 const & lhs, TExpr2 const & rhs)
12841284
{
12851285
return VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Sub>(lhs, rhs);
@@ -1294,8 +1294,8 @@ operator-(TExpr1 const & lhs, TExpr2 const & rhs)
12941294
* \sa \c mpl::IsArray<> to know the exact array types recognized as \em array by this traits
12951295
*/
12961296
template <typename TExpr1, typename TExpr2>
1297-
inline typename mpl::EnableIf<Details::op::CanBeMultiplied<TExpr1, TExpr2>,
1298-
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Mult>>::Type
1297+
inline std::enable_if_t<Details::op::CanBeMultiplied<TExpr1, TExpr2>::Value,
1298+
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Mult>>
12991299
operator*(TExpr1 const & lhs, TExpr2 const & rhs)
13001300
{
13011301
return VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Mult>(lhs, rhs);
@@ -1309,8 +1309,8 @@ operator*(TExpr1 const & lhs, TExpr2 const & rhs)
13091309
* \sa \c mpl::IsArray<> to know the exact array types recognized as \em array by this traits
13101310
*/
13111311
template <typename TExpr1, typename TExpr2>
1312-
inline typename mpl::EnableIf<Details::op::CanBeDivided<TExpr1, TExpr2>,
1313-
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Div>>::Type
1312+
inline std::enable_if_t<Details::op::CanBeDivided<TExpr1, TExpr2>::Value,
1313+
VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Div>>
13141314
operator/(TExpr1 const & lhs, TExpr2 const & rhs)
13151315
{
13161316
return VariableLengthVectorExpression<TExpr1, TExpr2, Details::op::Div>(lhs, rhs);
@@ -1341,7 +1341,7 @@ operator<<(std::ostream & os, VariableLengthVectorExpression<TExpr1, TExpr2, TBi
13411341
* \relates itk::VariableLengthVectorExpression
13421342
*/
13431343
template <typename TExpr>
1344-
inline typename mpl::EnableIf<mpl::IsArray<TExpr>, typename TExpr::RealValueType>::Type
1344+
inline std::enable_if_t<mpl::IsArray<TExpr>::Value, typename TExpr::RealValueType>
13451345
GetNorm(TExpr const & v)
13461346
{
13471347
return static_cast<typename TExpr::RealValueType>(std::sqrt(static_cast<double>(GetSquaredNorm(v))));
@@ -1353,7 +1353,7 @@ GetNorm(TExpr const & v)
13531353
* \relates itk::VariableLengthVectorExpression
13541354
*/
13551355
template <typename TExpr>
1356-
inline typename mpl::EnableIf<mpl::IsArray<TExpr>, typename TExpr::RealValueType>::Type
1356+
inline std::enable_if_t<mpl::IsArray<TExpr>::Value, typename TExpr::RealValueType>
13571357
GetSquaredNorm(TExpr const & v)
13581358
{
13591359
using RealValueType = typename TExpr::RealValueType;

Modules/IO/ImageBase/include/itkConvertPixelBuffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "itkObject.h"
2323
#include "itkNumericTraits.h"
24-
#include "itkEnableIf.h"
24+
#include <type_traits> // for enable_if
2525

2626
namespace itk
2727
{
@@ -167,11 +167,11 @@ class ITK_TEMPLATE_EXPORT ConvertPixelBuffer
167167
* world of rgb<float> or rgb<double> alpha would have to be 1.0
168168
*/
169169
template <typename UComponentType>
170-
static typename DisableIfC<NumericTraits<UComponentType>::IsInteger, UComponentType>::Type
170+
static std::enable_if_t<!NumericTraits<UComponentType>::IsInteger, UComponentType>
171171
DefaultAlphaValue();
172172

173173
template <typename UComponentType>
174-
static typename EnableIfC<NumericTraits<UComponentType>::IsInteger, UComponentType>::Type
174+
static std::enable_if_t<NumericTraits<UComponentType>::IsInteger, UComponentType>
175175
DefaultAlphaValue();
176176
};
177177
} // namespace itk

Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ namespace itk
2929

3030
template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits>
3131
template <typename UComponentType>
32-
typename DisableIfC<NumericTraits<UComponentType>::IsInteger, UComponentType>::Type
32+
std::enable_if_t<!NumericTraits<UComponentType>::IsInteger, UComponentType>
3333
ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::DefaultAlphaValue()
3434
{
3535
return NumericTraits<UComponentType>::One;
3636
}
3737

3838
template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits>
3939
template <typename UComponentType>
40-
typename EnableIfC<NumericTraits<UComponentType>::IsInteger, UComponentType>::Type
40+
std::enable_if_t<NumericTraits<UComponentType>::IsInteger, UComponentType>
4141
ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::DefaultAlphaValue()
4242
{
4343
return NumericTraits<UComponentType>::max();

Modules/IO/NIFTI/test/itkNiftiImageIOTest3.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
*=========================================================================*/
1818

1919
#include "itkNiftiImageIOTest.h"
20-
#include "itkEnableIf.h"
20+
#include <type_traits> // for enable_if
2121
#include <limits>
2222

2323
template <typename ScalarType>
2424
void
25-
Decrement(ScalarType & value,
26-
typename itk::DisableIfC<std::numeric_limits<ScalarType>::is_signed, ScalarType>::Type * = nullptr)
25+
Decrement(ScalarType & value, std::enable_if_t<!std::numeric_limits<ScalarType>::is_signed, ScalarType> * = nullptr)
2726
{
2827
if (value > 1)
2928
{
@@ -33,8 +32,7 @@ Decrement(ScalarType & value,
3332

3433
template <typename ScalarType>
3534
void
36-
Decrement(ScalarType & value,
37-
typename itk::EnableIfC<std::numeric_limits<ScalarType>::is_signed, ScalarType>::Type * = nullptr)
35+
Decrement(ScalarType & value, std::enable_if_t<std::numeric_limits<ScalarType>::is_signed, ScalarType> * = nullptr)
3836
{
3937
if (value > -std::numeric_limits<ScalarType>::max() + 1)
4038
{

0 commit comments

Comments
 (0)