Skip to content

Commit 3238743

Browse files
committed
Refactor reverse/transpose/cat
In preparation of ViewSmall/ViewBig refactor. * ra/arrays.hh (ViewSmall): Add members sdim, Dimv. Remove view(). (ViewBig): Add members sdim, Dimv. (reverse, transpose, cat): Write against Slice concept instead of against ViewSmall/ViewBig. * ra/ply.hh (is_iota): Rewrite. Remove unneeded accessory concepts.
1 parent 062a1fc commit 3238743

File tree

6 files changed

+204
-268
lines changed

6 files changed

+204
-268
lines changed

ra/arrays.hh

Lines changed: 198 additions & 252 deletions
Large diffs are not rendered by default.

ra/base.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static_assert(sizeof(rank_t)>=4 && sizeof(rank_t)>=sizeof(int) && sizeof(dim_t)>
310310
static_assert(std::is_signed_v<rank_t> && std::is_signed_v<dim_t>);
311311

312312
constexpr struct none_t {} none; // in constructors: don't initialize
313-
struct noarg { noarg() = delete; }; // in constructors: don't instantiate
313+
template <class T=void> struct noarg { noarg() = delete; }; // in constructors: don't instantiate
314314

315315
constexpr bool inside(dim_t i, dim_t b) { return 0<=i && i<b; }
316316
constexpr bool any(bool const x) { return x; } // extended in ra.hh

ra/expr.hh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,6 @@ ptr(P && p, N && n=N {}, S && s=S(maybe_step<S>))
317317
}
318318
}
319319

320-
template <class I, class N, class S, class K=ic_t<dim_t(0)>>
321-
constexpr auto
322-
reverse(Ptr<Seq<I>, N, S> const & i, K k = {})
323-
{
324-
static_assert(UNB!=i.len_s(0), "Bad arguments to reverse.");
325-
return ptr(Seq { i.data().i+(i.dimv[0].len-1)*i.dimv[0].step }, i.dimv[0].len, csub(ic<0>, i.dimv[0].step));
326-
}
327-
328320
constexpr auto iter(is_fov auto && a) { return ra::ptr(RA_FW(a)); }
329321
template <class T> constexpr auto iter(std::initializer_list<T> a) { return ra::ptr(a.begin(), a.size()); }
330322

ra/ply.hh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,7 @@ ii(ra::ilist_t<i ...>, T o=0)
345345
}
346346

347347
template <class A> concept is_ptr = requires (A a) { []<class I, class N, class S>(Ptr<Seq<I>, N, S> const &){}(a); };
348-
template <class A> concept is_iota_static = requires (A a) { []<class I, class Dimv>(ViewSmall<Seq<I>, Dimv> const &){}(a); };
349-
template <class A> concept is_iota_dynamic = requires (A a) { []<class I, rank_t RANK>(ViewBig<Seq<I>, RANK> const &){}(a); };
350-
template <class A> concept is_iota = (is_ptr<A> || is_iota_dynamic<A> || is_iota_static<A>);
348+
template <class A> concept is_iota = (Slice<A> && requires (A a) { []<class I>(Seq<I> const &){}(a.data()); });
351349
template <class A> concept is_scalar_index = is_ra_0<A>;
352350

353351
// beaten, whole or piecewise. Presize bv/ds not to need push_back

ra/ra.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#endif
2525

2626
// ADL with explicit template args. See http://stackoverflow.com/questions/9838862.
27-
template <int A> constexpr void iter(ra::noarg);
28-
template <class T> constexpr void cast(ra::noarg);
27+
template <int A> constexpr void iter(ra::noarg<>);
28+
template <class T> constexpr void cast(ra::noarg<>);
2929

3030

3131
// ---------------------------

test/sizeof.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ int main()
5656
{
5757
cout << sizeof(std::array<ra::none_t, 9> {}) << endl;
5858
cout << sizeof(ra::none_t [9]) << endl;
59-
cout << sizeof(ra::noarg [9]) << endl;
59+
cout << sizeof(ra::noarg<> [9]) << endl;
6060
cout << sizeof(std::array<ra::none_t, 0> {}) << endl;
6161
cout << sizeof(ra::none_t [0]) << endl;
62-
cout << sizeof(ra::noarg [0]) << endl;
62+
cout << sizeof(ra::noarg<> [0]) << endl;
6363
cout << sizeof(ra::Small<int, 0>) << endl;
6464
cout << sizeof(ra::Small<ra::none_t, 0>) << endl;
6565
cout << sizeof(ra::Small<noargx, 0>) << endl;

0 commit comments

Comments
 (0)