|
16 | 16 |
|
17 | 17 | namespace ra { |
18 | 18 |
|
19 | | - |
20 | | -// --------------------- |
21 | | -// replace Len in expr tree. VAL arguments that must be either is_constant or is_scalar. |
22 | | -// --------------------- |
23 | | - |
24 | | -template <class Ln, class E> |
25 | | -constexpr decltype(auto) |
26 | | -wlen(Ln ln, E && e) |
27 | | -{ |
28 | | - static_assert(std::is_integral_v<Ln> || is_constant<Ln>); |
29 | | - if constexpr (has_len<E>) { |
30 | | - return WLen<std::decay_t<E>>::f(ln, RA_FW(e)); |
31 | | - } else { |
32 | | - return RA_FW(e); |
33 | | - } |
34 | | -} |
35 | | - |
36 | | -template <> |
37 | | -struct WLen<Len> |
38 | | -{ |
39 | | - constexpr static auto |
40 | | - f(auto ln, auto && e) { return Scalar {ln}; } |
41 | | -}; |
42 | | - |
43 | | -template <class Op, Iterator ... P, int ... I> requires (has_len<P> || ...) |
44 | | -struct WLen<Map<Op, std::tuple<P ...>, ilist_t<I ...>>> |
45 | | -{ |
46 | | - constexpr static auto |
47 | | - f(auto ln, auto && e) { return map_(RA_FW(e).op, wlen(ln, std::get<I>(RA_FW(e).t)) ...); } |
48 | | -}; |
49 | | - |
50 | | -template <Iterator ... P, int ... I> requires (has_len<P> || ...) |
51 | | -struct WLen<Pick<std::tuple<P ...>, ilist_t<I ...>>> |
52 | | -{ |
53 | | - constexpr static auto |
54 | | - f(auto ln, auto && e) { return pick(wlen(ln, std::get<I>(RA_FW(e).t)) ...); } |
55 | | -}; |
56 | | - |
57 | | -template <class I> requires (has_len<I>) |
58 | | -struct WLen<Seq<I>> |
59 | | -{ |
60 | | - constexpr static auto |
61 | | - f(auto ln, auto && e) { return Seq { VAL(wlen(ln, e.i)) }; } |
62 | | -}; |
63 | | - |
64 | | -template <class I, class N, class S> requires (has_len<I> || has_len<N> || has_len<S>) |
65 | | -struct WLen<Ptr<I, N, S>> |
66 | | -{ |
67 | | - constexpr static auto |
68 | | - f(auto ln, auto && e) { return Ptr(wlen(ln, e.cp), VAL(wlen(ln, e.n)), VAL(wlen(ln, e.s))); } |
69 | | -}; |
70 | | - |
71 | | - |
72 | | -// -------------- |
73 | | -// ply |
74 | | -// -------------- |
75 | | - |
76 | 19 | struct Nop {}; |
77 | 20 |
|
78 | 21 | // run time order/rank. |
|
0 commit comments