1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Get rid of declarations inside constexpr functions. if constexpr warning remains

This commit is contained in:
Michael Marshall 2019-02-15 10:06:15 +00:00
parent 8cb96cb693
commit e8bd8767c0

View File

@ -120,16 +120,7 @@ namespace Grid {
static constexpr std::size_t Dimension(unsigned int dim) { static constexpr std::size_t Dimension(unsigned int dim) {
return ( dim == 0 ) ? N : Traits<T>::Dimension(dim - 1); } return ( dim == 0 ) ? N : Traits<T>::Dimension(dim - 1); }
static constexpr std::size_t DimensionNT(unsigned int dim) { static constexpr std::size_t DimensionNT(unsigned int dim) {
std::size_t DimSize = N; return ( N == 1 ) ? Traits<T>::DimensionNT(dim) : ( dim == 0 ) ? N : Traits<T>::DimensionNT(dim - 1);
bool bGotDimSize = false;
if( N != 1 ) {
if( dim == 0 )
bGotDimSize = true;
dim--;
}
if( !bGotDimSize )
DimSize = Traits<T>::DimensionNT(dim);
return DimSize;
} }
}; };
template <typename T, int N> struct Traits<iMatrix<T, N>> { template <typename T, int N> struct Traits<iMatrix<T, N>> {
@ -143,16 +134,7 @@ namespace Grid {
static constexpr std::size_t Dimension(unsigned int dim) { static constexpr std::size_t Dimension(unsigned int dim) {
return ( dim == 0 || dim == 1 ) ? N : Traits<T>::Dimension(dim - 2); } return ( dim == 0 || dim == 1 ) ? N : Traits<T>::Dimension(dim - 2); }
static constexpr std::size_t DimensionNT(unsigned int dim) { static constexpr std::size_t DimensionNT(unsigned int dim) {
std::size_t DimSize = N; return ( N == 1 ) ? Traits<T>::DimensionNT(dim) : ( dim == 0 || dim == 1 ) ? N : Traits<T>::DimensionNT(dim - 2);
bool bGotDimSize = false;
if( N != 1 ) {
if( dim == 0 || dim == 1 )
bGotDimSize = true;
dim -= 2;
}
if( !bGotDimSize )
DimSize = Traits<T>::DimensionNT(dim);
return DimSize;
} }
}; };
template <typename T, int N> struct Traits<std::array<T, N>> : Traits<iVector<T, N>> {}; template <typename T, int N> struct Traits<std::array<T, N>> : Traits<iVector<T, N>> {};