diff --git a/src/include/ranges/anonymous_range.h b/src/include/ranges/anonymous_range.h index ca24747..4801a00 100644 --- a/src/include/ranges/anonymous_range.h +++ b/src/include/ranges/anonymous_range.h @@ -131,6 +131,7 @@ namespace MultiArrayTools namespace MultiArrayHelper { using namespace MultiArrayTools; + template <> inline void resolveSetRange(std::shared_ptr rp, std::vector > orig, @@ -142,6 +143,16 @@ namespace MultiArrayHelper } rp = std::dynamic_pointer_cast( arf.create() ); } + + template <> + inline void setRangeToVec(std::vector >& v, + std::shared_ptr r) + { + for(size_t i = 0; i != r->dim(); ++i){ + v.insert(v.begin(), r->sub(i)); + } + } + } namespace MultiArrayTools @@ -156,7 +167,7 @@ namespace MultiArrayTools { mOrig.resize(sizeof...(RangeTypes)); RPackNum::RangesToVec( origs, mOrig ); - RPackNum::getSize( origs ); + mSize = RPackNum::getSize( origs ); } template @@ -166,7 +177,7 @@ namespace MultiArrayTools auto rst = std::make_tuple(origs...); mOrig.resize(sizeof...(RangeTypes)); RPackNum::RangesToVec( rst, mOrig ); - RPackNum::getSize( rst ); + mSize = RPackNum::getSize( rst ); } template diff --git a/src/include/ranges/rpack_num.h b/src/include/ranges/rpack_num.h index 8366f43..c5d6492 100644 --- a/src/include/ranges/rpack_num.h +++ b/src/include/ranges/rpack_num.h @@ -46,12 +46,19 @@ namespace MultiArrayHelper template - void resolveSetRange(std::shared_ptr rp, std::vector > orig, - size_t origpos, size_t size) + inline void resolveSetRange(std::shared_ptr rp, std::vector > orig, + size_t origpos, size_t size) { assert(size == 1); rp = std::dynamic_pointer_cast( orig[origpos] ); // catch bad cast here!! } + + template + inline void setRangeToVec(std::vector >& v, + std::shared_ptr r) + { + v.insert(v.begin(), r); + } template struct RPackNum @@ -216,10 +223,11 @@ namespace MultiArrayHelper template - static void RangesToVec(const std::tuple...>& rst, + static inline void RangesToVec(const std::tuple...>& rst, std::vector >& v) { - v[N] = std::get(rst); + setRangeToVec(v, std::get(rst)); + //v[N] = std::get(rst); RPackNum::RangesToVec(rst, v); } @@ -409,7 +417,7 @@ namespace MultiArrayHelper } template - static void RangesToVec(const std::tuple...>& rst, + static inline void RangesToVec(const std::tuple...>& rst, std::vector >& v) { v[0] = std::get<0>(rst);