ndarray: /home/runner/work/ndarray/ndarray/include/ndarray/detail/NestedIterator.h Source File

1

2

3

4

5

6

7

8

9

10

11#ifndef NDARRAY_DETAIL_NestedIterator_h_INCLUDED

12#define NDARRAY_DETAIL_NestedIterator_h_INCLUDED

13

20#include <boost/iterator/iterator_facade.hpp>

22

23namespace ndarray {

24namespace detail {

25

39template <typename T, int N, int C>

41 NestedIterator<T,N,C>,

42 typename ArrayTraits<T,N,C>::Value,

43 boost::random_access_traversal_tag,

44 typename ArrayTraits<T,N,C>::Reference

45 >

46{

47public:

50

51 Reference operator[](Size n) const {

53 r._data += n * _stride;

54 return r;

55 }

56

57 Reference const & operator*() const { return _ref; }

58

59 Reference const * operator->() { return &_ref; }

60

62

64

66

67 template <typename T_, int C_>

69

71 if (&other != this) {

72 _ref._data = other._ref._data;

73 _ref._core = other._ref._core;

74 _stride = other._stride;

75 }

76 return *this;

77 }

78

79 template <typename T_, int C_>

81 _ref._data = other._ref._data;

82 _ref._core = other._ref._core;

83 _stride = other._stride;

84 return *this;

85 }

86

87private:

88

89 friend class boost::iterator_core_access;

90

91 template <typename T_, int N_, int C_> friend class NestedIterator;

92

93 Reference const & dereference() const { return _ref; }

94

95 void increment() { _ref._data += _stride; }

96 void decrement() { _ref._data -= _stride; }

97 void advance(Offset n) { _ref._data += _stride * n; }

98

99 template <typename T_, int C_>

101 return std::distance(_ref._data, other._ref._data) / _stride;

102 }

103

104 template <typename T_, int C_>

106 return _ref._data == other._ref._data;

107 }

108

110 Offset _stride;

111};

112

113}

114}

115

116#endif

A proxy class for Array with deep assignment operators.

Definition ArrayRef.h:34

A multidimensional strided array.

Definition Array.h:35

Definition NestedIterator.h:46

Forward declarations and default template parameters for ndarray.