From a2d67ef78cc3e9d39441dd6bc738132a0d403284 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Fri, 5 Jul 2019 17:40:26 +0200 Subject: [PATCH] fix: gcc 9 more pedantic in this case: int vs uint template arg --- src/include/conversions.h | 4 +- src/include/ranges/anonymous_range.h | 18 ++++----- .../ranges/range_types/classic_range.h | 26 ++++++------- src/include/ranges/range_types/space_range.h | 26 ++++++------- src/include/ranges/rbase_def.h | 1 + src/include/ranges/single_range.h | 12 +++--- src/lib/ranges/anonymous_range.cc | 2 +- src/lib/ranges/range_types/classic_range.cc | 38 +++++++++---------- src/lib/ranges/range_types/space_range.cc | 38 +++++++++---------- 9 files changed, 83 insertions(+), 82 deletions(-) diff --git a/src/include/conversions.h b/src/include/conversions.h index 60a3b53..5cb06c7 100644 --- a/src/include/conversions.h +++ b/src/include/conversions.h @@ -22,13 +22,13 @@ namespace MultiArrayTools }; template <> - struct OrigSize<-1> + struct OrigSize { template struct FromTo { static void check() {} - static constexpr size_t SIZE = -1; + static constexpr size_t SIZE = MUI; }; }; } diff --git a/src/include/ranges/anonymous_range.h b/src/include/ranges/anonymous_range.h index 78ac54f..f8ee5b9 100644 --- a/src/include/ranges/anonymous_range.h +++ b/src/include/ranges/anonymous_range.h @@ -14,12 +14,12 @@ namespace MultiArrayTools { - typedef GenSingleIndex AnonymousIndex; + typedef GenSingleIndex AnonymousIndex; //template //using SIZET = size_t; - typedef GenSingleRange AnonymousRange; + typedef GenSingleRange AnonymousRange; // NOT THREAD SAVE!! class AnonymousRangeFactory : public RangeFactoryBase @@ -53,18 +53,18 @@ namespace MultiArrayTools }; template <> - class GenSingleRange : public RangeInterface + class GenSingleRange : public RangeInterface { 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::IndexType IndexType; - typedef GenSingleRange RangeType; + typedef GenSingleRange RangeType; typedef size_t MetaType; typedef AnonymousRangeFactory FType; @@ -209,7 +209,7 @@ namespace MultiArrayTools ***********************/ template - GenSingleRange::GenSingleRange(const std::tuple...>& origs) : + GenSingleRange::GenSingleRange(const std::tuple...>& origs) : RangeInterface() { RPackNum::RangesToVec( origs, mOrig ); @@ -220,7 +220,7 @@ namespace MultiArrayTools } template - GenSingleRange::GenSingleRange(std::shared_ptr... origs) : + GenSingleRange::GenSingleRange(std::shared_ptr... origs) : RangeInterface() { auto rst = std::make_tuple(origs...); @@ -232,13 +232,13 @@ namespace MultiArrayTools } template - std::shared_ptr GenSingleRange::fullsub(size_t num) const + std::shared_ptr GenSingleRange::fullsub(size_t num) const { return std::dynamic_pointer_cast( mOrig.at(num) ); } template - std::shared_ptr > GenSingleRange::scast(SIZET... sizes) const + std::shared_ptr > GenSingleRange::scast(SIZET... sizes) const { std::tuple...> rtp; RPackNum::resolveRangeType(mOrig, rtp, 0, sizes...); diff --git a/src/include/ranges/range_types/classic_range.h b/src/include/ranges/range_types/classic_range.h index 0bc6edc..6de6587 100644 --- a/src/include/ranges/range_types/classic_range.h +++ b/src/include/ranges/range_types/classic_range.h @@ -12,14 +12,14 @@ namespace MultiArrayTools { - typedef GenSingleIndex ClassicIndex; + typedef GenSingleIndex ClassicIndex; template <> - class GenSingleRangeFactory : public RangeFactoryBase + class GenSingleRangeFactory : public RangeFactoryBase { public: - typedef GenSingleRange oType; + typedef GenSingleRange oType; GenSingleRangeFactory(size_t size = 0); std::shared_ptr create(); @@ -27,14 +27,14 @@ namespace MultiArrayTools }; template <> - class GenSingleRange : public RangeInterface + class GenSingleRange : public RangeInterface { public: typedef RangeBase RB; - typedef typename RangeInterface >::IndexType IndexType; - typedef GenSingleRange RangeType; + typedef typename RangeInterface >::IndexType IndexType; + typedef GenSingleRange RangeType; typedef size_t MetaType; - typedef GenSingleRangeFactory FType; + typedef GenSingleRangeFactory 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 index() const final; - friend GenSingleRangeFactory; + friend GenSingleRangeFactory; 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 factory(size_t size = 0) - { return GenSingleRangeFactory(size); } + static GenSingleRangeFactory factory(size_t size = 0) + { return GenSingleRangeFactory(size); } protected: @@ -75,8 +75,8 @@ namespace MultiArrayTools GenSingleRange(size_t size); }; - typedef GenSingleRange ClassicRange; - typedef GenSingleRangeFactory ClassicRF; + typedef GenSingleRange ClassicRange; + typedef GenSingleRangeFactory ClassicRF; } diff --git a/src/include/ranges/range_types/space_range.h b/src/include/ranges/range_types/space_range.h index d60c64e..20022d5 100644 --- a/src/include/ranges/range_types/space_range.h +++ b/src/include/ranges/range_types/space_range.h @@ -11,14 +11,14 @@ include_range_type(PSPACE,3) // Periodic 1dim space namespace MultiArrayTools { // Periodic 1dim space - typedef GenSingleIndex XSpaceIndex; + typedef GenSingleIndex XSpaceIndex; template <> - class GenSingleRangeFactory : public RangeFactoryBase + class GenSingleRangeFactory : public RangeFactoryBase { public: - typedef GenSingleRange oType; + typedef GenSingleRange oType; GenSingleRangeFactory(size_t size = 0); std::shared_ptr create(); @@ -26,14 +26,14 @@ namespace MultiArrayTools }; template <> - class GenSingleRange : public RangeInterface + class GenSingleRange : public RangeInterface { public: typedef RangeBase RB; - typedef typename RangeInterface >::IndexType IndexType; - typedef GenSingleRange RangeType; + typedef typename RangeInterface >::IndexType IndexType; + typedef GenSingleRange RangeType; typedef int MetaType; - typedef GenSingleRangeFactory FType; + typedef GenSingleRangeFactory 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; + friend GenSingleRangeFactory; 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 factory(size_t size = 0) - { return GenSingleRangeFactory(size); } + static GenSingleRangeFactory factory(size_t size = 0) + { return GenSingleRangeFactory(size); } protected: @@ -73,8 +73,8 @@ namespace MultiArrayTools GenSingleRange(size_t size); }; - typedef GenSingleRange PSpaceRange; - typedef GenSingleRangeFactory PSpaceRF; + typedef GenSingleRange PSpaceRange; + typedef GenSingleRangeFactory PSpaceRF; std::shared_ptr mkPSPACE(const char* dp, size_t size); diff --git a/src/include/ranges/rbase_def.h b/src/include/ranges/rbase_def.h index 41c0a28..5ed59c8 100644 --- a/src/include/ranges/rbase_def.h +++ b/src/include/ranges/rbase_def.h @@ -15,6 +15,7 @@ #endif #include "allocator.h" +#define MUI static_cast(-1) namespace MultiArrayTools { diff --git a/src/include/ranges/single_range.h b/src/include/ranges/single_range.h index 44ee5cb..7b1ef84 100644 --- a/src/include/ranges/single_range.h +++ b/src/include/ranges/single_range.h @@ -204,10 +204,10 @@ namespace MultiArrayTools }; template <> - struct CheckStatic<-1> + struct CheckStatic { static constexpr size_t ISSTATIC = false; - static constexpr size_t SIZE = -1; + static constexpr size_t SIZE = MUI; }; template @@ -283,13 +283,13 @@ namespace MultiArrayTools }; template - using SingleRange = GenSingleRange; + using SingleRange = GenSingleRange; template - using SingleIndex = GenSingleIndex; + using SingleIndex = GenSingleIndex; template - using SingleRangeFactory = GenSingleRangeFactory; + using SingleRangeFactory = GenSingleRangeFactory; } @@ -556,7 +556,7 @@ namespace MultiArrayTools } template <> - inline size_t getStatSizeOrDyn<-1>(size_t size) + inline size_t getStatSizeOrDyn(size_t size) { return size; } diff --git a/src/lib/ranges/anonymous_range.cc b/src/lib/ranges/anonymous_range.cc index 999b460..e7e4d25 100644 --- a/src/lib/ranges/anonymous_range.cc +++ b/src/lib/ranges/anonymous_range.cc @@ -253,7 +253,7 @@ namespace MultiArrayTools return mOrig; } - GenSingleRange::GenSingleRange(const vector>& origs) : + GenSingleRange::GenSingleRange(const vector>& origs) : RangeInterface(), mOrig(origs) { diff --git a/src/lib/ranges/range_types/classic_range.cc b/src/lib/ranges/range_types/classic_range.cc index 7630175..96508cf 100644 --- a/src/lib/ranges/range_types/classic_range.cc +++ b/src/lib/ranges/range_types/classic_range.cc @@ -8,16 +8,16 @@ namespace MultiArrayTools * GenSingleRange * ********************/ - GenSingleRangeFactory::GenSingleRangeFactory(size_t size) + GenSingleRangeFactory::GenSingleRangeFactory(size_t size) { // Quasi Singleton if(not mProd){ - mProd = std::shared_ptr( new GenSingleRange(size) ); + mProd = std::shared_ptr( new GenSingleRange(size) ); setSelf(); } } - std::shared_ptr GenSingleRangeFactory::create() + std::shared_ptr GenSingleRangeFactory::create() { return mProd; } @@ -26,55 +26,55 @@ namespace MultiArrayTools * GenSingleRange * ********************/ - GenSingleRange::GenSingleRange(size_t size) : mSize(size) {} + GenSingleRange::GenSingleRange(size_t size) : mSize(size) {} - size_t GenSingleRange::get(size_t pos) const + size_t GenSingleRange::get(size_t pos) const { return pos; } - size_t GenSingleRange::getMeta(size_t metaPos) const + size_t GenSingleRange::getMeta(size_t metaPos) const { return metaPos; } - size_t GenSingleRange::size() const + size_t GenSingleRange::size() const { return mSize; } - size_t GenSingleRange::dim() const + size_t GenSingleRange::dim() const { return 1; } - SpaceType GenSingleRange::spaceType() const + SpaceType GenSingleRange::spaceType() const { return SpaceType::NONE; } - vector GenSingleRange::typeNum() const + vector GenSingleRange::typeNum() const { return {NumTypeMap::num}; } - size_t GenSingleRange::cmeta(char* target, size_t pos) const + size_t GenSingleRange::cmeta(char* target, size_t pos) const { *reinterpret_cast(target) = pos; return sizeof(size_t); } - size_t GenSingleRange::cmetaSize() const + size_t GenSingleRange::cmetaSize() const { return sizeof(size_t); } - std::string GenSingleRange::stringMeta(size_t pos) const + std::string GenSingleRange::stringMeta(size_t pos) const { return std::to_string(get(pos)); } - vector GenSingleRange::data() const + vector GenSingleRange::data() const { DataHeader h = dataHeader(); vector out; @@ -86,7 +86,7 @@ namespace MultiArrayTools return out; } - DataHeader GenSingleRange::dataHeader() const + DataHeader GenSingleRange::dataHeader() const { DataHeader h; h.spaceType = static_cast( SpaceType::NONE ); @@ -96,17 +96,17 @@ namespace MultiArrayTools } - typename GenSingleRange::IndexType GenSingleRange::begin() const + typename GenSingleRange::IndexType GenSingleRange::begin() const { - GenSingleIndex i( std::dynamic_pointer_cast > + GenSingleIndex i( std::dynamic_pointer_cast > ( std::shared_ptr( RB::mThis ) ) ); i = 0; return i; } - typename GenSingleRange::IndexType GenSingleRange::end() const + typename GenSingleRange::IndexType GenSingleRange::end() const { - GenSingleIndex i( std::dynamic_pointer_cast > + GenSingleIndex i( std::dynamic_pointer_cast > ( std::shared_ptr( RB::mThis ) ) ); i = size(); return i; diff --git a/src/lib/ranges/range_types/space_range.cc b/src/lib/ranges/range_types/space_range.cc index 6ce6f33..00b214a 100644 --- a/src/lib/ranges/range_types/space_range.cc +++ b/src/lib/ranges/range_types/space_range.cc @@ -14,16 +14,16 @@ namespace MultiArrayTools * GenSingleRange * ********************/ - GenSingleRangeFactory::GenSingleRangeFactory(size_t size) + GenSingleRangeFactory::GenSingleRangeFactory(size_t size) { // Quasi Singleton if(not mProd){ - mProd = std::shared_ptr( new GenSingleRange(size) ); + mProd = std::shared_ptr( new GenSingleRange(size) ); setSelf(); } } - std::shared_ptr GenSingleRangeFactory::create() + std::shared_ptr GenSingleRangeFactory::create() { return mProd; } @@ -32,55 +32,55 @@ namespace MultiArrayTools * GenSingleRange * ********************/ - GenSingleRange::GenSingleRange(size_t size) : mSize(size) { } + GenSingleRange::GenSingleRange(size_t size) : mSize(size) { } - int GenSingleRange::get(size_t pos) const + int GenSingleRange::get(size_t pos) const { return pos > mSize / 2 ? pos - mSize : pos; } - size_t GenSingleRange::getMeta(int metaPos) const + size_t GenSingleRange::getMeta(int metaPos) const { return metaPos < 0 ? metaPos + mSize : metaPos; } - size_t GenSingleRange::size() const + size_t GenSingleRange::size() const { return mSize; } - size_t GenSingleRange::dim() const + size_t GenSingleRange::dim() const { return 1; } - SpaceType GenSingleRange::spaceType() const + SpaceType GenSingleRange::spaceType() const { return SpaceType::PSPACE; } - vector GenSingleRange::typeNum() const + vector GenSingleRange::typeNum() const { return {NumTypeMap::num}; } - size_t GenSingleRange::cmeta(char* target, size_t pos) const + size_t GenSingleRange::cmeta(char* target, size_t pos) const { *reinterpret_cast(target) = get(pos); return sizeof(int); } - size_t GenSingleRange::cmetaSize() const + size_t GenSingleRange::cmetaSize() const { return sizeof(int); } - std::string GenSingleRange::stringMeta(size_t pos) const + std::string GenSingleRange::stringMeta(size_t pos) const { return std::to_string(get(pos)); } - vector GenSingleRange::data() const + vector GenSingleRange::data() const { DataHeader h = dataHeader(); vector out; @@ -92,7 +92,7 @@ namespace MultiArrayTools return out; } - DataHeader GenSingleRange::dataHeader() const + DataHeader GenSingleRange::dataHeader() const { DataHeader h; h.spaceType = static_cast( SpaceType::PSPACE ); @@ -101,17 +101,17 @@ namespace MultiArrayTools return h; } - typename GenSingleRange::IndexType GenSingleRange::begin() const + typename GenSingleRange::IndexType GenSingleRange::begin() const { - GenSingleIndex i( std::dynamic_pointer_cast > + GenSingleIndex i( std::dynamic_pointer_cast > ( std::shared_ptr( RB::mThis ) ) ); i = 0; return i; } - typename GenSingleRange::IndexType GenSingleRange::end() const + typename GenSingleRange::IndexType GenSingleRange::end() const { - GenSingleIndex i( std::dynamic_pointer_cast > + GenSingleIndex i( std::dynamic_pointer_cast > ( std::shared_ptr( RB::mThis ) ) ); i = size(); return i;