CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
dindex.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_dindex_cc_h__
13#define __cxz_dindex_cc_h__
14
15#include "dindex.h"
16
17namespace CNORXZ
18{
19 template <class Index, typename Meta>
24
25 template <class Xpr, class F>
26 decltype(auto) DIndex::ifor(const Xpr& xpr, F&& f) const
27 {
28 typedef typename std::remove_reference<decltype(Xpr()())>::type R;
29 if constexpr(std::is_same<F,NoF>::value) {
30 if constexpr(std::is_same<R,None>::value or std::is_same<R,void>::value){
31 return mI->ifor( DXpr<None>(xpr), std::forward<F>(f) );
32 }
33 else {
34 return DXpr<R>( bufxpr([&](auto x){ return mI->ifor( DXpr<None>( assignxpr(x, xpr) ), NoF {} ); }) );
35 }
36 }
37 else {
38 return DXpr<R>( bufxpr([&](auto x){ return mI->ifor( DXpr<None>( assignxpr(x, xpr) ), NoF {} ); }) );
39 }
40 }
41
42 template <class I>
43 decltype(auto) operator*(const Sptr<DIndex>& a, const Sptr<I>& b)
44 {
45 return iptrMul(a, b);
46 }
47
48 template <class I>
49 I indexAs(const DIndex& i)
50 {
51 static_assert(is_index<I>::value, "expected index type");
52 auto ptr = std::dynamic_pointer_cast<XIndex<I,typename I::MetaType>>( i.xptr() );
53 CXZ_ASSERT(ptr, "invalid cast");
54 return ptr->get();
55 }
56}
57
58#endif
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
DIndex(const DIndex &i)
Definition dindex.cc:16
decltype(auto) ifor(const Xpr &xpr, F &&f) const
Definition dindex.cc.h:26
Dynamic index declaration.
constexpr decltype(auto) bufxpr(IXprF &&ixprf)
Definition buf_xpr.cc.h:77
I indexAs(const DIndex &i)
Definition dindex.cc.h:49
decltype(auto) xpr(const Sptr< I > &i)
Sptr< Range > rangeCast(const RangePtr r)
decltype(auto) iptrMul(const Sptr< I1 > &a, const Sptr< I2 > &b)
constexpr decltype(auto) assignxpr(const Tar &tar, const Src &src)
std::shared_ptr< T > Sptr
Definition types.h:48