im com while implementing xfor (compiles without instanciating templates)
This commit is contained in:
parent
85f221f5e1
commit
ba86c2f9fa
5 changed files with 62 additions and 0 deletions
|
@ -88,6 +88,10 @@ namespace MultiArrayTools
|
||||||
std::string id();
|
std::string id();
|
||||||
void print(size_t offset);
|
void print(size_t offset);
|
||||||
|
|
||||||
|
template <class... Exprs>
|
||||||
|
auto ifor(Exprs&&... exs) const
|
||||||
|
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs...));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,6 +370,14 @@ namespace MultiArrayTools
|
||||||
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
|
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class... Indices>
|
||||||
|
template <class... Exprs>
|
||||||
|
auto ContainerIndex<Indices...>::ifor(Exprs&&... exs) const
|
||||||
|
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs...))
|
||||||
|
{
|
||||||
|
return RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs...);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
* ContainerRangeFactory *
|
* ContainerRangeFactory *
|
||||||
|
|
|
@ -103,6 +103,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
std::string id();
|
std::string id();
|
||||||
void print(size_t offset);
|
void print(size_t offset);
|
||||||
|
|
||||||
|
template <class... Exprs>
|
||||||
|
auto ifor(Exprs&&... exs) const
|
||||||
|
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs...));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
|
@ -410,6 +414,13 @@ namespace MultiArrayTools
|
||||||
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
|
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class... Indices>
|
||||||
|
template <class... Exprs>
|
||||||
|
auto MultiIndex<Indices...>::ifor(Exprs&&... exs) const
|
||||||
|
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs...))
|
||||||
|
{
|
||||||
|
return RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs...);
|
||||||
|
}
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
* MultiRangeFactory *
|
* MultiRangeFactory *
|
||||||
|
|
|
@ -219,6 +219,16 @@ namespace MultiArrayHelper
|
||||||
RPackNum<N-1>::buildInfoVec(out, ip, bs);
|
RPackNum<N-1>::buildInfoVec(out, ip, bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class IndexPack, class... Exprs>
|
||||||
|
static auto mkFor(const IndexPack& ipack, Exprs&&... exs)
|
||||||
|
-> decltype(std::get<std::tuple_size<IndexPack>::value-N>(ipack)
|
||||||
|
->ifor(RPackNum<N-1>::template mkFor<IndexPack,Exprs...>
|
||||||
|
(ipack, exs...) ) )
|
||||||
|
{
|
||||||
|
return std::get<std::tuple_size<IndexPack>::value-N>(ipack)
|
||||||
|
->ifor( RPackNum<N-1>::template mkFor<IndexPack,Exprs...>(ipack, exs...) );
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -382,6 +392,13 @@ namespace MultiArrayHelper
|
||||||
out.emplace_back(*std::get<POS>(ip), std::get<POS>(bs));
|
out.emplace_back(*std::get<POS>(ip), std::get<POS>(bs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class IndexPack, class... Exprs>
|
||||||
|
static auto mkFor(const IndexPack& ipack, Exprs&&... exs)
|
||||||
|
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
|
||||||
|
->ifor(exs...) )
|
||||||
|
{
|
||||||
|
return std::get<std::tuple_size<IndexPack>::value-1>(ipack)->ifor(exs...);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include "ranges/index_base.h"
|
#include "ranges/index_base.h"
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
|
|
||||||
|
#include "xfor/xfor.h"
|
||||||
|
|
||||||
|
using MultiArrayHelper::For;
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -59,6 +63,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
std::string id();
|
std::string id();
|
||||||
void print(size_t offset);
|
void print(size_t offset);
|
||||||
|
|
||||||
|
template <class Expr>
|
||||||
|
auto ifor(Expr&& ex) const -> For<SingleIndex<U,TYPE>,Expr>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE>
|
||||||
|
@ -239,6 +246,15 @@ namespace MultiArrayTools
|
||||||
<< "](" << IB::mRangePtr << "): " << meta() << std::endl;
|
<< "](" << IB::mRangePtr << "): " << meta() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE>
|
||||||
|
template <class Expr>
|
||||||
|
auto SingleIndex<U,TYPE>::ifor(Expr&& ex) const
|
||||||
|
-> For<SingleIndex<U,TYPE>,Expr>
|
||||||
|
{
|
||||||
|
return For<SingleIndex<U,TYPE>,Expr>
|
||||||
|
( std::make_shared<SingleIndex<U,TYPE> >(*this), ex );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* SingleRange *
|
||||||
|
|
|
@ -19,6 +19,8 @@ namespace MultiArrayHelper
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
For(const std::shared_ptr<IndexClass>& indPtr, const Args&... args);
|
For(const std::shared_ptr<IndexClass>& indPtr, const Args&... args);
|
||||||
|
|
||||||
|
For(const std::shared_ptr<IndexClass>& indPtr, Expr&& expr);
|
||||||
|
|
||||||
inline void operator()(size_t start = 0);
|
inline void operator()(size_t start = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -42,6 +44,10 @@ namespace MultiArrayHelper
|
||||||
For<IndexClass,Expr>::For(const std::shared_ptr<IndexClass>& indPtr,
|
For<IndexClass,Expr>::For(const std::shared_ptr<IndexClass>& indPtr,
|
||||||
const Args&... args) : mIndPtr(indPtr), mExpr(args...) {}
|
const Args&... args) : mIndPtr(indPtr), mExpr(args...) {}
|
||||||
|
|
||||||
|
template <class IndexClass, class Expr>
|
||||||
|
For<IndexClass,Expr>::For(const std::shared_ptr<IndexClass>& indPtr,
|
||||||
|
Expr&& expr) : mIndPtr(indPtr), mExpr(expr) {}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void For<IndexClass,Expr>::operator()(size_t start)
|
inline void For<IndexClass,Expr>::operator()(size_t start)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue