| 67 | // ----------------------------------- |
| 68 | |
| 69 | class row |
| 70 | { |
| 71 | /*! |
| 72 | CONVENTION |
| 73 | - nc_ == nc() |
| 74 | - for all x < nc_: |
| 75 | - (*this)[x] == data[x] |
| 76 | !*/ |
| 77 | |
| 78 | friend class array2d<T,mem_manager>; |
| 79 | friend class row_helper; |
| 80 | |
| 81 | public: |
| 82 | long nc ( |
| 83 | ) const { return nc_; } |
| 84 | |
| 85 | const T& operator[] ( |
| 86 | long column |
| 87 | ) const |
| 88 | { |
| 89 | // make sure requires clause is not broken |
| 90 | DLIB_ASSERT(column < nc() && column >= 0, |
| 91 | "\tconst T& array2d::operator[](long column) const" |
| 92 | << "\n\tThe column index given must be less than the number of columns." |
| 93 | << "\n\tthis: " << this |
| 94 | << "\n\tcolumn: " << column |
| 95 | << "\n\tnc(): " << nc() |
| 96 | ); |
| 97 | |
| 98 | return data[column]; |
| 99 | } |
| 100 | |
| 101 | T& operator[] ( |
| 102 | long column |
| 103 | ) |
| 104 | { |
| 105 | // make sure requires clause is not broken |
| 106 | DLIB_ASSERT(column < nc() && column >= 0, |
| 107 | "\tT& array2d::operator[](long column)" |
| 108 | << "\n\tThe column index given must be less than the number of columns." |
| 109 | << "\n\tthis: " << this |
| 110 | << "\n\tcolumn: " << column |
| 111 | << "\n\tnc(): " << nc() |
| 112 | ); |
| 113 | |
| 114 | return data[column]; |
| 115 | } |
| 116 | |
| 117 | private: |
| 118 | |
| 119 | row(T* data_, long cols) : data(data_), nc_(cols) {} |
| 120 | row(row&& r) = default; |
| 121 | row& operator=(row&& r) = default; |
| 122 | |
| 123 | T* data = nullptr; |
| 124 | long nc_ = 0; |
| 125 | |
| 126 |
no outgoing calls