fix: gcc 9 more pedantic in this case: int vs uint template arg

This commit is contained in:
Christian Zimmermann 2019-07-05 17:40:26 +02:00
parent 472abec3fd
commit a2d67ef78c
9 changed files with 83 additions and 82 deletions

View file

@ -22,13 +22,13 @@ namespace MultiArrayTools
};
template <>
struct OrigSize<-1>
struct OrigSize<MUI>
{
template <typename C, typename T>
struct FromTo
{
static void check() {}
static constexpr size_t SIZE = -1;
static constexpr size_t SIZE = MUI;
};
};
}

View file

@ -14,12 +14,12 @@
namespace MultiArrayTools
{
typedef GenSingleIndex<size_t,SpaceType::ANON,-1> AnonymousIndex;
typedef GenSingleIndex<size_t,SpaceType::ANON,MUI> AnonymousIndex;
//template <class R>
//using SIZET = size_t;
typedef GenSingleRange<size_t,SpaceType::ANON,-1> AnonymousRange;
typedef GenSingleRange<size_t,SpaceType::ANON,MUI> AnonymousRange;
// NOT THREAD SAVE!!
class AnonymousRangeFactory : public RangeFactoryBase
@ -53,18 +53,18 @@ namespace MultiArrayTools
};
template <>
class GenSingleRange<size_t,SpaceType::ANON,-1> : public RangeInterface<AnonymousIndex>
class GenSingleRange<size_t,SpaceType::ANON,MUI> : public RangeInterface<AnonymousIndex>
{
public:
static constexpr bool defaultable = true;
static constexpr size_t ISSTATIC = 0;
static constexpr size_t SIZE = -1;
static constexpr size_t SIZE = MUI;
static constexpr bool HASMETACONT = false;
typedef RangeBase RB;
typedef typename RangeInterface<AnonymousIndex>::IndexType IndexType;
typedef GenSingleRange<size_t,SpaceType::ANON,-1> RangeType;
typedef GenSingleRange<size_t,SpaceType::ANON,MUI> RangeType;
typedef size_t MetaType;
typedef AnonymousRangeFactory FType;
@ -209,7 +209,7 @@ namespace MultiArrayTools
***********************/
template <class... RangeTypes>
GenSingleRange<size_t,SpaceType::ANON,-1>::GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
RangeInterface<AnonymousIndex>()
{
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
@ -220,7 +220,7 @@ namespace MultiArrayTools
}
template <class... RangeTypes>
GenSingleRange<size_t,SpaceType::ANON,-1>::GenSingleRange(std::shared_ptr<RangeTypes>... origs) :
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(std::shared_ptr<RangeTypes>... origs) :
RangeInterface<AnonymousIndex>()
{
auto rst = std::make_tuple(origs...);
@ -232,13 +232,13 @@ namespace MultiArrayTools
}
template <class Range>
std::shared_ptr<Range> GenSingleRange<size_t,SpaceType::ANON,-1>::fullsub(size_t num) const
std::shared_ptr<Range> GenSingleRange<size_t,SpaceType::ANON,MUI>::fullsub(size_t num) const
{
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
}
template <class... Ranges>
std::shared_ptr<MultiRange<Ranges...> > GenSingleRange<size_t,SpaceType::ANON,-1>::scast(SIZET<Ranges>... sizes) const
std::shared_ptr<MultiRange<Ranges...> > GenSingleRange<size_t,SpaceType::ANON,MUI>::scast(SIZET<Ranges>... sizes) const
{
std::tuple<std::shared_ptr<Ranges>...> rtp;
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);

View file

@ -12,14 +12,14 @@
namespace MultiArrayTools
{
typedef GenSingleIndex<size_t,SpaceType::NONE,-1> ClassicIndex;
typedef GenSingleIndex<size_t,SpaceType::NONE,MUI> ClassicIndex;
template <>
class GenSingleRangeFactory<size_t,SpaceType::NONE,-1> : public RangeFactoryBase
class GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> : public RangeFactoryBase
{
public:
typedef GenSingleRange<size_t,SpaceType::NONE,-1> oType;
typedef GenSingleRange<size_t,SpaceType::NONE,MUI> oType;
GenSingleRangeFactory(size_t size = 0);
std::shared_ptr<RangeBase> create();
@ -27,14 +27,14 @@ namespace MultiArrayTools
};
template <>
class GenSingleRange<size_t,SpaceType::NONE,-1> : public RangeInterface<ClassicIndex>
class GenSingleRange<size_t,SpaceType::NONE,MUI> : public RangeInterface<ClassicIndex>
{
public:
typedef RangeBase RB;
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::NONE,-1> >::IndexType IndexType;
typedef GenSingleRange<size_t,SpaceType::NONE,-1> RangeType;
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::NONE,MUI> >::IndexType IndexType;
typedef GenSingleRange<size_t,SpaceType::NONE,MUI> RangeType;
typedef size_t MetaType;
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,-1> FType;
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> FType;
virtual size_t size() const final;
virtual size_t dim() const final;
@ -55,15 +55,15 @@ namespace MultiArrayTools
virtual IndexType end() const final;
//virtual std::shared_ptr<VIWB> index() const final;
friend GenSingleRangeFactory<size_t,SpaceType::NONE,-1>;
friend GenSingleRangeFactory<size_t,SpaceType::NONE,MUI>;
static constexpr bool defaultable = true;
static constexpr size_t ISSTATIC = 0;
static constexpr size_t SIZE = -1;
static constexpr size_t SIZE = MUI;
static constexpr bool HASMETACONT = false;
static GenSingleRangeFactory<size_t,SpaceType::NONE,-1> factory(size_t size = 0)
{ return GenSingleRangeFactory<size_t,SpaceType::NONE,-1>(size); }
static GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> factory(size_t size = 0)
{ return GenSingleRangeFactory<size_t,SpaceType::NONE,MUI>(size); }
protected:
@ -75,8 +75,8 @@ namespace MultiArrayTools
GenSingleRange(size_t size);
};
typedef GenSingleRange<size_t,SpaceType::NONE,-1> ClassicRange;
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,-1> ClassicRF;
typedef GenSingleRange<size_t,SpaceType::NONE,MUI> ClassicRange;
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> ClassicRF;
}

View file

@ -11,14 +11,14 @@ include_range_type(PSPACE,3) // Periodic 1dim space
namespace MultiArrayTools
{
// Periodic 1dim space
typedef GenSingleIndex<int,SpaceType::PSPACE,-1> XSpaceIndex;
typedef GenSingleIndex<int,SpaceType::PSPACE,MUI> XSpaceIndex;
template <>
class GenSingleRangeFactory<int,SpaceType::PSPACE,-1> : public RangeFactoryBase
class GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> : public RangeFactoryBase
{
public:
typedef GenSingleRange<int,SpaceType::PSPACE,-1> oType;
typedef GenSingleRange<int,SpaceType::PSPACE,MUI> oType;
GenSingleRangeFactory(size_t size = 0);
std::shared_ptr<RangeBase> create();
@ -26,14 +26,14 @@ namespace MultiArrayTools
};
template <>
class GenSingleRange<int,SpaceType::PSPACE,-1> : public RangeInterface<XSpaceIndex>
class GenSingleRange<int,SpaceType::PSPACE,MUI> : public RangeInterface<XSpaceIndex>
{
public:
typedef RangeBase RB;
typedef typename RangeInterface<GenSingleIndex<int,SpaceType::PSPACE,-1> >::IndexType IndexType;
typedef GenSingleRange<int,SpaceType::PSPACE,-1> RangeType;
typedef typename RangeInterface<GenSingleIndex<int,SpaceType::PSPACE,MUI> >::IndexType IndexType;
typedef GenSingleRange<int,SpaceType::PSPACE,MUI> RangeType;
typedef int MetaType;
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,-1> FType;
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> FType;
virtual size_t size() const final;
virtual size_t dim() const final;
@ -53,15 +53,15 @@ namespace MultiArrayTools
virtual IndexType begin() const final;
virtual IndexType end() const final;
friend GenSingleRangeFactory<int,SpaceType::PSPACE,-1>;
friend GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>;
static constexpr bool defaultable = true;
static constexpr size_t ISSTATIC = 0;
static constexpr size_t SIZE = -1;
static constexpr size_t SIZE = MUI;
static constexpr bool HASMETACONT = false;
static GenSingleRangeFactory<int,SpaceType::PSPACE,-1> factory(size_t size = 0)
{ return GenSingleRangeFactory<int,SpaceType::PSPACE,-1>(size); }
static GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> factory(size_t size = 0)
{ return GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>(size); }
protected:
@ -73,8 +73,8 @@ namespace MultiArrayTools
GenSingleRange(size_t size);
};
typedef GenSingleRange<int,SpaceType::PSPACE,-1> PSpaceRange;
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,-1> PSpaceRF;
typedef GenSingleRange<int,SpaceType::PSPACE,MUI> PSpaceRange;
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> PSpaceRF;
std::shared_ptr<PSpaceRF> mkPSPACE(const char* dp, size_t size);

View file

@ -15,6 +15,7 @@
#endif
#include "allocator.h"
#define MUI static_cast<size_t>(-1)
namespace MultiArrayTools
{

View file

@ -204,10 +204,10 @@ namespace MultiArrayTools
};
template <>
struct CheckStatic<-1>
struct CheckStatic<MUI>
{
static constexpr size_t ISSTATIC = false;
static constexpr size_t SIZE = -1;
static constexpr size_t SIZE = MUI;
};
template <SpaceType TYPE>
@ -283,13 +283,13 @@ namespace MultiArrayTools
};
template <typename U, SpaceType TYPE>
using SingleRange = GenSingleRange<U,TYPE,-1>;
using SingleRange = GenSingleRange<U,TYPE,MUI>;
template <typename U, SpaceType TYPE>
using SingleIndex = GenSingleIndex<U,TYPE,-1>;
using SingleIndex = GenSingleIndex<U,TYPE,MUI>;
template <typename U, SpaceType TYPE>
using SingleRangeFactory = GenSingleRangeFactory<U,TYPE,-1>;
using SingleRangeFactory = GenSingleRangeFactory<U,TYPE,MUI>;
}
@ -556,7 +556,7 @@ namespace MultiArrayTools
}
template <>
inline size_t getStatSizeOrDyn<-1>(size_t size)
inline size_t getStatSizeOrDyn<MUI>(size_t size)
{
return size;
}

View file

@ -253,7 +253,7 @@ namespace MultiArrayTools
return mOrig;
}
GenSingleRange<size_t,SpaceType::ANON,-1>::GenSingleRange(const vector<std::shared_ptr<RangeBase>>& origs) :
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(const vector<std::shared_ptr<RangeBase>>& origs) :
RangeInterface<AnonymousIndex>(),
mOrig(origs)
{

View file

@ -8,16 +8,16 @@ namespace MultiArrayTools
* GenSingleRange *
********************/
GenSingleRangeFactory<size_t,SpaceType::NONE,-1>::GenSingleRangeFactory(size_t size)
GenSingleRangeFactory<size_t,SpaceType::NONE,MUI>::GenSingleRangeFactory(size_t size)
{
// Quasi Singleton
if(not mProd){
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::NONE,-1>(size) );
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::NONE,MUI>(size) );
setSelf();
}
}
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::NONE,-1>::create()
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::NONE,MUI>::create()
{
return mProd;
}
@ -26,55 +26,55 @@ namespace MultiArrayTools
* GenSingleRange *
********************/
GenSingleRange<size_t,SpaceType::NONE,-1>::GenSingleRange(size_t size) : mSize(size) {}
GenSingleRange<size_t,SpaceType::NONE,MUI>::GenSingleRange(size_t size) : mSize(size) {}
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::get(size_t pos) const
size_t GenSingleRange<size_t,SpaceType::NONE,MUI>::get(size_t pos) const
{
return pos;
}
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::getMeta(size_t metaPos) const
size_t GenSingleRange<size_t,SpaceType::NONE,MUI>::getMeta(size_t metaPos) const
{
return metaPos;
}
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::size() const
size_t GenSingleRange<size_t,SpaceType::NONE,MUI>::size() const
{
return mSize;
}
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::dim() const
size_t GenSingleRange<size_t,SpaceType::NONE,MUI>::dim() const
{
return 1;
}
SpaceType GenSingleRange<size_t,SpaceType::NONE,-1>::spaceType() const
SpaceType GenSingleRange<size_t,SpaceType::NONE,MUI>::spaceType() const
{
return SpaceType::NONE;
}
vector<size_t> GenSingleRange<size_t,SpaceType::NONE,-1>::typeNum() const
vector<size_t> GenSingleRange<size_t,SpaceType::NONE,MUI>::typeNum() const
{
return {NumTypeMap<size_t>::num};
}
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::cmeta(char* target, size_t pos) const
size_t GenSingleRange<size_t,SpaceType::NONE,MUI>::cmeta(char* target, size_t pos) const
{
*reinterpret_cast<size_t*>(target) = pos;
return sizeof(size_t);
}
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::cmetaSize() const
size_t GenSingleRange<size_t,SpaceType::NONE,MUI>::cmetaSize() const
{
return sizeof(size_t);
}
std::string GenSingleRange<size_t,SpaceType::NONE,-1>::stringMeta(size_t pos) const
std::string GenSingleRange<size_t,SpaceType::NONE,MUI>::stringMeta(size_t pos) const
{
return std::to_string(get(pos));
}
vector<char> GenSingleRange<size_t,SpaceType::NONE,-1>::data() const
vector<char> GenSingleRange<size_t,SpaceType::NONE,MUI>::data() const
{
DataHeader h = dataHeader();
vector<char> out;
@ -86,7 +86,7 @@ namespace MultiArrayTools
return out;
}
DataHeader GenSingleRange<size_t,SpaceType::NONE,-1>::dataHeader() const
DataHeader GenSingleRange<size_t,SpaceType::NONE,MUI>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( SpaceType::NONE );
@ -96,17 +96,17 @@ namespace MultiArrayTools
}
typename GenSingleRange<size_t,SpaceType::NONE,-1>::IndexType GenSingleRange<size_t,SpaceType::NONE,-1>::begin() const
typename GenSingleRange<size_t,SpaceType::NONE,MUI>::IndexType GenSingleRange<size_t,SpaceType::NONE,MUI>::begin() const
{
GenSingleIndex<size_t,SpaceType::NONE,-1> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NONE,-1> >
GenSingleIndex<size_t,SpaceType::NONE,MUI> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NONE,MUI> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
typename GenSingleRange<size_t,SpaceType::NONE,-1>::IndexType GenSingleRange<size_t,SpaceType::NONE,-1>::end() const
typename GenSingleRange<size_t,SpaceType::NONE,MUI>::IndexType GenSingleRange<size_t,SpaceType::NONE,MUI>::end() const
{
GenSingleIndex<size_t,SpaceType::NONE,-1> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NONE,-1> >
GenSingleIndex<size_t,SpaceType::NONE,MUI> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NONE,MUI> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = size();
return i;

View file

@ -14,16 +14,16 @@ namespace MultiArrayTools
* GenSingleRange *
********************/
GenSingleRangeFactory<int,SpaceType::PSPACE,-1>::GenSingleRangeFactory(size_t size)
GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>::GenSingleRangeFactory(size_t size)
{
// Quasi Singleton
if(not mProd){
mProd = std::shared_ptr<oType>( new GenSingleRange<int,SpaceType::PSPACE,-1>(size) );
mProd = std::shared_ptr<oType>( new GenSingleRange<int,SpaceType::PSPACE,MUI>(size) );
setSelf();
}
}
std::shared_ptr<RangeBase> GenSingleRangeFactory<int,SpaceType::PSPACE,-1>::create()
std::shared_ptr<RangeBase> GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>::create()
{
return mProd;
}
@ -32,55 +32,55 @@ namespace MultiArrayTools
* GenSingleRange *
********************/
GenSingleRange<int,SpaceType::PSPACE,-1>::GenSingleRange(size_t size) : mSize(size) { }
GenSingleRange<int,SpaceType::PSPACE,MUI>::GenSingleRange(size_t size) : mSize(size) { }
int GenSingleRange<int,SpaceType::PSPACE,-1>::get(size_t pos) const
int GenSingleRange<int,SpaceType::PSPACE,MUI>::get(size_t pos) const
{
return pos > mSize / 2 ? pos - mSize : pos;
}
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::getMeta(int metaPos) const
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::getMeta(int metaPos) const
{
return metaPos < 0 ? metaPos + mSize : metaPos;
}
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::size() const
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::size() const
{
return mSize;
}
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::dim() const
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::dim() const
{
return 1;
}
SpaceType GenSingleRange<int,SpaceType::PSPACE,-1>::spaceType() const
SpaceType GenSingleRange<int,SpaceType::PSPACE,MUI>::spaceType() const
{
return SpaceType::PSPACE;
}
vector<size_t> GenSingleRange<int,SpaceType::PSPACE,-1>::typeNum() const
vector<size_t> GenSingleRange<int,SpaceType::PSPACE,MUI>::typeNum() const
{
return {NumTypeMap<int>::num};
}
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::cmeta(char* target, size_t pos) const
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::cmeta(char* target, size_t pos) const
{
*reinterpret_cast<int*>(target) = get(pos);
return sizeof(int);
}
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::cmetaSize() const
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::cmetaSize() const
{
return sizeof(int);
}
std::string GenSingleRange<int,SpaceType::PSPACE,-1>::stringMeta(size_t pos) const
std::string GenSingleRange<int,SpaceType::PSPACE,MUI>::stringMeta(size_t pos) const
{
return std::to_string(get(pos));
}
vector<char> GenSingleRange<int,SpaceType::PSPACE,-1>::data() const
vector<char> GenSingleRange<int,SpaceType::PSPACE,MUI>::data() const
{
DataHeader h = dataHeader();
vector<char> out;
@ -92,7 +92,7 @@ namespace MultiArrayTools
return out;
}
DataHeader GenSingleRange<int,SpaceType::PSPACE,-1>::dataHeader() const
DataHeader GenSingleRange<int,SpaceType::PSPACE,MUI>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( SpaceType::PSPACE );
@ -101,17 +101,17 @@ namespace MultiArrayTools
return h;
}
typename GenSingleRange<int,SpaceType::PSPACE,-1>::IndexType GenSingleRange<int,SpaceType::PSPACE,-1>::begin() const
typename GenSingleRange<int,SpaceType::PSPACE,MUI>::IndexType GenSingleRange<int,SpaceType::PSPACE,MUI>::begin() const
{
GenSingleIndex<int,SpaceType::PSPACE,-1> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,-1> >
GenSingleIndex<int,SpaceType::PSPACE,MUI> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,MUI> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
typename GenSingleRange<int,SpaceType::PSPACE,-1>::IndexType GenSingleRange<int,SpaceType::PSPACE,-1>::end() const
typename GenSingleRange<int,SpaceType::PSPACE,MUI>::IndexType GenSingleRange<int,SpaceType::PSPACE,MUI>::end() const
{
GenSingleIndex<int,SpaceType::PSPACE,-1> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,-1> >
GenSingleIndex<int,SpaceType::PSPACE,MUI> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,MUI> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = size();
return i;