srange casts + add first eindex implementation
This commit is contained in:
parent
3f8c7aacc3
commit
e9fde3d900
3 changed files with 79 additions and 0 deletions
28
src/include/ranges/eindex.cc.h
Normal file
28
src/include/ranges/eindex.cc.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
#ifndef __cxz_eindex_cc_h__
|
||||
#define __cxz_eindex_cc_h__
|
||||
|
||||
#include "eindex.h"
|
||||
|
||||
namespace CNORXZ
|
||||
{
|
||||
|
||||
template <typename MetaT, SizeT S>
|
||||
EIndex<MetaT,S>::EIndex(const SIndex<MetaT,S>& i) :
|
||||
SIndex<MetaT,S>(i) {}
|
||||
|
||||
template <typename MetaT, SizeT S>
|
||||
EIndex<MetaT,S>::EIndex(SIndex<MetaT,S>&& i) :
|
||||
SIndex<MetaT,S>(i) {}
|
||||
|
||||
template <typename MetaT, SizeT S>
|
||||
template <class Xpr, class F>
|
||||
decltype(auto) EIndex<MetaT,S>::ifor(const Xpr& xpr, F&& f) const
|
||||
{
|
||||
// TODO: EFor Function argument; meanwhile ignore unused function error!!!
|
||||
return EFor<S,0,Xpr>(this->id(), xpr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
29
src/include/ranges/eindex.h
Normal file
29
src/include/ranges/eindex.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
#ifndef __cxz_eindex_h__
|
||||
#define __cxz_eindex_h__
|
||||
|
||||
#include "base/base.h"
|
||||
#include "ranges/index_base.h"
|
||||
#include "ranges/range_base.h"
|
||||
#include "xpr/xpr.h"
|
||||
|
||||
namespace CNORXZ
|
||||
{
|
||||
template <typename MetaT, SizeT S>
|
||||
class EIndex : public SIndex<MetaT,S>
|
||||
{
|
||||
public:
|
||||
typedef typename SIndex<MetaT,S>::IB IB;
|
||||
typedef typename SIndex<MetaT,S>::RangeType RangeType;
|
||||
|
||||
DEFAULT_MEMBERS(EIndex);
|
||||
EIndex(const SIndex<MetaT,S>& i);
|
||||
EIndex(SIndex<MetaT,S>&& i);
|
||||
|
||||
template <class Xpr, class F>
|
||||
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -289,6 +289,28 @@ namespace CNORXZ
|
|||
return Vector<Uuid> { this->id() };
|
||||
}
|
||||
|
||||
/*******************
|
||||
* Range Casts *
|
||||
*******************/
|
||||
|
||||
template <typename MetaType, SizeT S>
|
||||
Sptr<SRange<MetaType,S>> RangeCast<SRange<MetaType,S>>::func(const RangePtr& r)
|
||||
{
|
||||
Sptr<URange<MetaType>> tmp;
|
||||
if(r->type() != typeid(URange<MetaType>)){
|
||||
tmp = castRange<URange<MetaType>>(r);
|
||||
}
|
||||
else {
|
||||
tmp = r;
|
||||
}
|
||||
CXZ_ASSERT(tmp->size() == S, "cannot cast range of size " << tmp->size()
|
||||
<< " into static range of size " << S);
|
||||
Arr<MetaType,S> space;
|
||||
std::copy(tmp->begin(), tmp->end(), space.begin());
|
||||
return std::dynamic_pointer_cast<SRange<MetaType,S>>
|
||||
( SRangeFactory<MetaType,S>(std::move(space)).create() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue