diff --git a/src/anonymous_range.h b/src/anonymous_range.h index 5bd4953..5b87367 100644 --- a/src/anonymous_range.h +++ b/src/anonymous_range.h @@ -19,7 +19,13 @@ namespace MultiArrayTools typedef AnonymousRange oType; AnonymousRangeFactory() = delete; - AnonymousRangeFactory(const std::shared_ptr... origs); + + template + AnonymousRangeFactory(const std::tuple...>& origs); + + template + AnonymousRangeFactory(std::shared_ptr... origs); + std::shared_ptr create(); }; @@ -48,7 +54,10 @@ namespace MultiArrayTools AnonymousRange(const AnonymousRange& in) = delete; template - AnonymousRange(const std::shared_ptr... origs); + AnonymousRange(const std::tuple...>& origs) + + template + AnonymousRange(std::shared_ptr... origs); size_t mSize; @@ -67,10 +76,17 @@ namespace MultiArrayTools /*********************** * AnonymousRange * ***********************/ - - AnonymousRangeFactory::AnonymousRangeFactory(const std::shared_ptr... origs) + + template + AnonymousRangeFactory::AnonymousRangeFactory(const std::tuple...>& origs) { - mProd = std::shared_ptr( new AnonymousRange( space ) ); + mProd = std::shared_ptr( new AnonymousRange( origs ) ); + } + + template + AnonymousRangeFactory::AnonymousRangeFactory(std::shared_ptr... origs) + { + mProd = std::shared_ptr( new AnonymousRange( origs... ) ); } std::shared_ptr AnonymousRangeFactory::create() @@ -84,13 +100,22 @@ namespace MultiArrayTools ***********************/ template - AnonymousRange::AnonymousRange(const std::shared_ptr... origs) : + AnonymousRange::AnonymousRange(const std::tuple...>& origs) : RangeInterface() { mOrig.resize(sizeof...(Ranges)); - PackNum::RangesToVec(); - // mOrig !!!! - // mSize !!! = (prod origs.size...) + PackNum::RangesToVec( origs, mOrig ); + PackNum::getSize( rst ); + } + + template + AnonymousRange::AnonymousRange(std::shared_ptr... origs) : + RangeInterface() + { + auto rst = std::make_tuple(origs...); + mOrig.resize(sizeof...(Ranges)); + PackNum::RangesToVec( rst, mOrig ); + PackNum::getSize( rst ); } size_t AnonymousRange::get(size_t pos) const diff --git a/src/base_def.h b/src/base_def.h index f181565..ca81680 100644 --- a/src/base_def.h +++ b/src/base_def.h @@ -106,6 +106,12 @@ namespace MultiArrayTools template class ContainerIndex; + // anonymous_range.h + class AnonymousRangeFactory; + + // anonymous_range.h + class AnonymousRange; + // multi_array.h template class MultiArrayBase; diff --git a/src/op_unit_test.cc b/src/op_unit_test.cc index df261e1..7d78bb6 100644 --- a/src/op_unit_test.cc +++ b/src/op_unit_test.cc @@ -151,8 +151,10 @@ namespace { mrptr = std::dynamic_pointer_cast(rfbptr->create()); } - const size_t vs1 = 10000; - const size_t vs2 = 1000; + //const size_t vs1 = 10000; + //const size_t vs2 = 1000; + const size_t vs1 = 4000; + const size_t vs2 = 2500; std::shared_ptr rfbptr; std::shared_ptr sr1ptr; diff --git a/src/pack_num.h b/src/pack_num.h index e6de26c..9fa0fb7 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -245,12 +245,12 @@ namespace MultiArrayHelper PackNum::printTuple(out, tp); } - template - static void RangesToVec(const std::shared_ptr r, - const std::shared_ptr... rs, + template + static void RangesToVec(const std::tuple...>& rst, std::vector v) { - + v[N] = std::get(rst); + PackNum::RangesToVec(rst, v); } }; @@ -433,6 +433,13 @@ namespace MultiArrayHelper out << std::get(tp); } + template + static void RangesToVec(const std::tuple...>& rst, + std::vector v) + { + v[0] = std::get<0>(rst); + } + }; template diff --git a/src/range_types/header.h b/src/range_types/header.h index d551506..6826c94 100644 --- a/src/range_types/header.h +++ b/src/range_types/header.h @@ -1,7 +1,14 @@ +#ifdef include_range_type +#define __incl_this__ +#endif #ifdef __single_range_h__ // singel_range is template which is specialized here // therefore it must be defined before... +#define __incl_this__ +#endif + +#ifdef __incl_this__ #ifndef __ranges_header__ #define __ranges_header__ @@ -10,3 +17,5 @@ #endif #endif + +#undef __incl_this__