CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
iter.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_iter_cc_h__
13#define __cxz_iter_cc_h__
14
15#include "iter.h"
16#include "xpr/func.h"
17
18namespace CNORXZ
19{
21 template <class G, class F, SizeT... Is>
22 constexpr decltype(auto) iteri(const G& g, const F& f, Isq<Is...> is)
23 {
24 if constexpr(std::is_same<F,NoF>::value){
25 ( g(CSizeT<Is>{}), ... );
26 }
27 else {
28 return f( g(CSizeT<Is>{}) ... );
29 }
30 }
33 template <SizeT B, SizeT E, class G, class F>
34 constexpr decltype(auto) iter(const G& g, const F& f)
35 {
36 return iteri(g, f, Isqr<B,E>{});
37 }
38
40 template <SizeT E, SizeT I, class G, class F, class C, typename... Args>
41 constexpr decltype(auto) iterIfi(const G& g, const F& f, const C& c, const Args&... args)
42 {
43 if constexpr(I >= E){
44 if constexpr(std::is_same<F,NoF>::value){
45 return;
46 }
47 else {
48 return f(args...);
49 }
50 }
51 else {
52 if constexpr(c(CSizeT<I>{})){
53 return iterIfi<E,I+1>(g, f, c, args..., g(CSizeT<I>{}));
54 }
55 else {
56 return iterIfi<E,I+1>(g, f, c, args...);
57 }
58 }
59 }
62 template <SizeT B, SizeT E, class G, class F, class C>
63 constexpr decltype(auto) iterIf(const G& g, const F& f, const C& c)
64 {
65 return iterIfi<E,B>(g, f, c);
66 }
67}
68
69#endif
Special function objects declarations.
Static for-loops.
typename MkIsq< B, E >::type Isqr
Definition isq.h:45
Sptr< Range > rangeCast(const RangePtr r)
constexpr decltype(auto) iterIf(const G &g, const F &f, const C &c)
Definition iter.cc.h:63
constexpr decltype(auto) iter(const G &g, const F &f)
Definition iter.cc.h:34