test-small-iterator.C 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // (c) Daniel Llorens - 2014, 2016
  2. // This library is free software; you can redistribute it and/or modify it under
  3. // the terms of the GNU Lesser General Public License as published by the Free
  4. // Software Foundation; either version 3 of the License, or (at your option) any
  5. // later version.
  6. /// @file test-small.C
  7. /// @brief WIP: creating a higher-rank iterator for SmallArray/SmallView.
  8. #include <iostream>
  9. #include <iterator>
  10. #include "ra/complex.H"
  11. #include "ra/small.H"
  12. #include "ra/iterator.H"
  13. #include "ra/operators.H"
  14. #include "ra/io.H"
  15. #include "ra/big.H"
  16. #include "ra/small.H"
  17. #include "ra/format.H"
  18. #include "ra/test.H"
  19. #include "ra/mpdebug.H"
  20. using std::cout; using std::endl; using std::flush;
  21. template <int i, class V> struct small_iterator_def;
  22. template <int i_, template <class, class, class> class Child, class T, class sizes, class strides>
  23. struct small_iterator_def<i_, ra::SmallBase<Child, T, sizes, strides>>
  24. {
  25. constexpr static int i = i_;
  26. using V = ra::SmallBase<Child, T, sizes, strides>;
  27. using type = ra::ra_iterator<V, i>;
  28. };
  29. template <int i, class V> using small_iterator = small_iterator_def<i, typename std::decay_t<V>::Base>;
  30. int main()
  31. {
  32. TestRecorder tr;
  33. {
  34. using A = ra::Small<int, 2, 3>;
  35. A a(0.);
  36. cout << a << endl;
  37. using AI = typename small_iterator<0, A>::type;
  38. cout << std::is_same<int, AI>::value << endl;
  39. cout << small_iterator<0, A>::i << endl;
  40. AI ai {}; // TODO start fixing cell_iterator here
  41. cout << ai.p << endl;
  42. }
  43. return tr.summary();
  44. }