Skip to content

Commit f76f5cf

Browse files
committed
Reorder declarations, looking to replace Ptr()
* ra/small.hh (Wlen): Move after all Iterators have been defined. (start(is_builtin_array)): Use Cell<> directly. * ra/expr.hh (wlen): Move together with Len, Wlen forward decl.
1 parent 563da6a commit f76f5cf

File tree

3 files changed

+201
-204
lines changed

3 files changed

+201
-204
lines changed

ra/expr.hh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace ra {
6060
constexpr TYPE(TYPE && x) = default; \
6161
constexpr TYPE(TYPE const & x) = default;
6262

63-
// Contextual len: a unique object. See wlen in ply.hh.
63+
// Contextual len: a unique object. See wlen in small.hh.
6464

6565
constexpr struct Len
6666
{
@@ -81,6 +81,20 @@ template <class E> struct WLen; // defined in ply
8181
template <class E> concept has_len = requires(int ln, E && e) { WLen<std::decay_t<E>>::f(ln, RA_FW(e)); };
8282
template <has_len E> constexpr bool is_special_def<E> = true; // protect exprs with Len from reduction.
8383

84+
template <class Ln, class E>
85+
constexpr decltype(auto)
86+
wlen(Ln ln, E && e)
87+
{
88+
static_assert(std::is_integral_v<Ln> || is_constant<Ln>);
89+
if constexpr (has_len<E>) {
90+
return WLen<std::decay_t<E>>::f(ln, RA_FW(e));
91+
} else {
92+
return RA_FW(e);
93+
}
94+
}
95+
96+
// Sequence iterator.
97+
8498
template <class I>
8599
struct Seq
86100
{

ra/ply.hh

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,63 +16,6 @@
1616

1717
namespace ra {
1818

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-
7619
struct Nop {};
7720

7821
// run time order/rank.

0 commit comments

Comments
 (0)