Skip to content

Commit b8e41d0

Browse files
committed
COMP: Use C++11 constexpr directly
git grep -l \"ITK_CONSTEXPR_VAR\" | fgrep -v itk_compiler_detection.h | fgrep -v itkMacro.h | fgrep -v CMakeLists.txt |fgrep -v .cmake | xargs sed -i '' -e \"s/ ITK_CONSTEXPR_VAR/ constexpr/g\" Change-Id: I618ad84d057dfaf4933f575e44ae60118997b2e5
1 parent 02128ab commit b8e41d0

44 files changed

Lines changed: 449 additions & 449 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Modules/Core/Common/include/itkHexahedronCell.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ HexahedronCell< TCellInterface >
338338
double *dist2,
339339
InterpolationWeightType *weight)
340340
{
341-
static ITK_CONSTEXPR_VAR int ITK_HEX_MAX_ITERATION = 10;
342-
static ITK_CONSTEXPR_VAR double ITK_HEX_CONVERGED = 1.e-03;
343-
static ITK_CONSTEXPR_VAR double ITK_DIVERGED = 1.e6;
341+
static constexpr int ITK_HEX_MAX_ITERATION = 10;
342+
static constexpr double ITK_HEX_CONVERGED = 1.e-03;
343+
static constexpr double ITK_DIVERGED = 1.e6;
344344

345345
int iteration, converged;
346346
double params[3];

Modules/Core/Common/include/itkIsBaseOf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace mpl {
3737
template <typename TBase, typename TDerived>
3838
struct IsBaseOf
3939
{
40-
static ITK_CONSTEXPR_VAR bool Value
40+
static constexpr bool Value
4141
= IsConvertible<const TDerived*, const TBase*>::Value
4242
&& ! IsSame<const TBase*, const void*>::Value;
4343
};

Modules/Core/Common/include/itkIsConvertible.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct IsConvertible
6262
static TTwo Test(...);
6363
static TFrom MakeT();
6464
public:
65-
static ITK_CONSTEXPR_VAR bool Value = sizeof(Test(MakeT())) == sizeof(TOne);
65+
static constexpr bool Value = sizeof(Test(MakeT())) == sizeof(TOne);
6666
};
6767

6868
} // end namespace mpl

Modules/Core/Common/include/itkMath.h

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,52 +53,52 @@ namespace Math
5353

5454

5555
/** \brief \f[e\f] The base of the natural logarithm or Euler's number */
56-
static ITK_CONSTEXPR_VAR double e = vnl_math::e;
56+
static constexpr double e = vnl_math::e;
5757
/** \brief \f[ \log_2 e \f] */
58-
static ITK_CONSTEXPR_VAR double log2e = vnl_math::log2e;
58+
static constexpr double log2e = vnl_math::log2e;
5959
/** \brief \f[ \log_{10} e \f] */
60-
static ITK_CONSTEXPR_VAR double log10e = vnl_math::log10e;
60+
static constexpr double log10e = vnl_math::log10e;
6161
/** \brief \f[ \log_e 2 \f] */
62-
static ITK_CONSTEXPR_VAR double ln2 = vnl_math::ln2;
62+
static constexpr double ln2 = vnl_math::ln2;
6363
/** \brief \f[ \log_e 10 \f] */
64-
static ITK_CONSTEXPR_VAR double ln10 = vnl_math::ln10;
64+
static constexpr double ln10 = vnl_math::ln10;
6565
/** \brief \f[ \pi \f] */
66-
static ITK_CONSTEXPR_VAR double pi = vnl_math::pi;
66+
static constexpr double pi = vnl_math::pi;
6767
/** \brief \f[ 2\pi \f] */
68-
static ITK_CONSTEXPR_VAR double twopi = vnl_math::twopi;
68+
static constexpr double twopi = vnl_math::twopi;
6969
/** \brief \f[ \frac{\pi}{2} \f] */
70-
static ITK_CONSTEXPR_VAR double pi_over_2 = vnl_math::pi_over_2;
70+
static constexpr double pi_over_2 = vnl_math::pi_over_2;
7171
/** \brief \f[ \frac{\pi}{4} \f] */
72-
static ITK_CONSTEXPR_VAR double pi_over_4 = vnl_math::pi_over_4;
72+
static constexpr double pi_over_4 = vnl_math::pi_over_4;
7373
/** \brief \f[ \frac{\pi}{180} \f] */
74-
static ITK_CONSTEXPR_VAR double pi_over_180 = vnl_math::pi_over_180;
74+
static constexpr double pi_over_180 = vnl_math::pi_over_180;
7575
/** \brief \f[ \frac{1}{\pi} \f] */
76-
static ITK_CONSTEXPR_VAR double one_over_pi = vnl_math::one_over_pi;
76+
static constexpr double one_over_pi = vnl_math::one_over_pi;
7777
/** \brief \f[ \frac{2}{\pi} \f] */
78-
static ITK_CONSTEXPR_VAR double two_over_pi = vnl_math::two_over_pi;
78+
static constexpr double two_over_pi = vnl_math::two_over_pi;
7979
/** \brief \f[ \frac{180}{\pi} \f] */
80-
static ITK_CONSTEXPR_VAR double deg_per_rad = vnl_math::deg_per_rad;
80+
static constexpr double deg_per_rad = vnl_math::deg_per_rad;
8181
/** \brief \f[ \sqrt{2\pi} \f] */
82-
static ITK_CONSTEXPR_VAR double sqrt2pi = vnl_math::sqrt2pi;
82+
static constexpr double sqrt2pi = vnl_math::sqrt2pi;
8383
/** \brief \f[ \frac{2}{\sqrt{\pi}} \f] */
84-
static ITK_CONSTEXPR_VAR double two_over_sqrtpi = vnl_math::two_over_sqrtpi;
84+
static constexpr double two_over_sqrtpi = vnl_math::two_over_sqrtpi;
8585
/** \brief \f[ \frac{2}{\sqrt{2\pi}} \f] */
86-
static ITK_CONSTEXPR_VAR double one_over_sqrt2pi = vnl_math::one_over_sqrt2pi;
86+
static constexpr double one_over_sqrt2pi = vnl_math::one_over_sqrt2pi;
8787
/** \brief \f[ \sqrt{2} \f] */
88-
static ITK_CONSTEXPR_VAR double sqrt2 = vnl_math::sqrt2;
88+
static constexpr double sqrt2 = vnl_math::sqrt2;
8989
/** \brief \f[ \sqrt{ \frac{1}{2}} \f] */
90-
static ITK_CONSTEXPR_VAR double sqrt1_2 = vnl_math::sqrt1_2;
90+
static constexpr double sqrt1_2 = vnl_math::sqrt1_2;
9191
/** \brief \f[ \sqrt{ \frac{1}{3}} \f] */
92-
static ITK_CONSTEXPR_VAR double sqrt1_3 = vnl_math::sqrt1_3;
92+
static constexpr double sqrt1_3 = vnl_math::sqrt1_3;
9393
/** \brief euler constant */
94-
static ITK_CONSTEXPR_VAR double euler = vnl_math::euler;
94+
static constexpr double euler = vnl_math::euler;
9595

9696
//: IEEE double machine precision
97-
static ITK_CONSTEXPR_VAR double eps = vnl_math::eps;
98-
static ITK_CONSTEXPR_VAR double sqrteps = vnl_math::sqrteps;
97+
static constexpr double eps = vnl_math::eps;
98+
static constexpr double sqrteps = vnl_math::sqrteps;
9999
//: IEEE single machine precision
100-
static ITK_CONSTEXPR_VAR float float_eps = vnl_math::float_eps;
101-
static ITK_CONSTEXPR_VAR float float_sqrteps = vnl_math::float_sqrteps;
100+
static constexpr float float_eps = vnl_math::float_eps;
101+
static constexpr float float_sqrteps = vnl_math::float_sqrteps;
102102

103103
/** A useful macro to generate a template floating point to integer
104104
* conversion templated on the return type and using either the 32
@@ -507,10 +507,10 @@ struct AlmostEqualsFunctionSelector<true, false, true, false>
507507
template<typename TInputType1, typename TInputType2>
508508
struct AlmostEqualsScalarImplementer
509509
{
510-
static ITK_CONSTEXPR_VAR bool TInputType1IsInteger = itk::NumericTraits<TInputType1>::IsInteger;
511-
static ITK_CONSTEXPR_VAR bool TInputType1IsSigned = itk::NumericTraits<TInputType1>::IsSigned;
512-
static ITK_CONSTEXPR_VAR bool TInputType2IsInteger = itk::NumericTraits<TInputType2>::IsInteger;
513-
static ITK_CONSTEXPR_VAR bool TInputType2IsSigned = itk::NumericTraits<TInputType2>::IsSigned;
510+
static constexpr bool TInputType1IsInteger = itk::NumericTraits<TInputType1>::IsInteger;
511+
static constexpr bool TInputType1IsSigned = itk::NumericTraits<TInputType1>::IsSigned;
512+
static constexpr bool TInputType2IsInteger = itk::NumericTraits<TInputType2>::IsInteger;
513+
static constexpr bool TInputType2IsSigned = itk::NumericTraits<TInputType2>::IsSigned;
514514

515515
typedef typename AlmostEqualsFunctionSelector< TInputType1IsInteger, TInputType1IsSigned,
516516
TInputType2IsInteger, TInputType2IsSigned >::SelectedVersion SelectedVersion;
@@ -614,8 +614,8 @@ struct AlmostEqualsComplexChooser< true, false>
614614
template <typename T1, typename T2>
615615
struct AlmostEqualsComplexImplementer
616616
{
617-
static ITK_CONSTEXPR_VAR bool T1IsComplex = NumericTraits< T1 >::IsComplex;
618-
static ITK_CONSTEXPR_VAR bool T2IsComplex = NumericTraits< T2 >::IsComplex;
617+
static constexpr bool T1IsComplex = NumericTraits< T1 >::IsComplex;
618+
static constexpr bool T2IsComplex = NumericTraits< T2 >::IsComplex;
619619

620620
typedef typename AlmostEqualsComplexChooser< T1IsComplex, T2IsComplex >::ChosenVersion ChosenVersion;
621621
};

0 commit comments

Comments
 (0)