| 200 | // interface. |
| 201 | template <typename T, std::size_t NumDims> |
| 202 | class sub_array : public const_sub_array<T,NumDims,T*> |
| 203 | { |
| 204 | typedef const_sub_array<T,NumDims,T*> super_type; |
| 205 | public: |
| 206 | typedef typename super_type::element element; |
| 207 | typedef typename super_type::reference reference; |
| 208 | typedef typename super_type::index index; |
| 209 | typedef typename super_type::size_type size_type; |
| 210 | typedef typename super_type::iterator iterator; |
| 211 | typedef typename super_type::reverse_iterator reverse_iterator; |
| 212 | typedef typename super_type::const_reference const_reference; |
| 213 | typedef typename super_type::const_iterator const_iterator; |
| 214 | typedef typename super_type::const_reverse_iterator const_reverse_iterator; |
| 215 | |
| 216 | // template typedefs |
| 217 | template <std::size_t NDims> |
| 218 | struct const_array_view { |
| 219 | typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type; |
| 220 | }; |
| 221 | |
| 222 | template <std::size_t NDims> |
| 223 | struct array_view { |
| 224 | typedef boost::detail::multi_array::multi_array_view<T,NDims> type; |
| 225 | }; |
| 226 | |
| 227 | // Assignment from other ConstMultiArray types. |
| 228 | template <typename ConstMultiArray> |
| 229 | sub_array& operator=(const ConstMultiArray& other) { |
| 230 | function_requires< boost::multi_array_concepts::ConstMultiArrayConcept< |
| 231 | ConstMultiArray, NumDims> >(); |
| 232 | |
| 233 | // make sure the dimensions agree |
| 234 | BOOST_ASSERT(other.num_dimensions() == this->num_dimensions()); |
| 235 | BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(), |
| 236 | this->shape())); |
| 237 | // iterator-based copy |
| 238 | std::copy(other.begin(),other.end(),begin()); |
| 239 | return *this; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | sub_array& operator=(const sub_array& other) { |
| 244 | if (&other != this) { |
| 245 | // make sure the dimensions agree |
| 246 | BOOST_ASSERT(other.num_dimensions() == this->num_dimensions()); |
| 247 | BOOST_ASSERT(std::equal(other.shape(), |
| 248 | other.shape()+this->num_dimensions(), |
| 249 | this->shape())); |
| 250 | // iterator-based copy |
| 251 | std::copy(other.begin(),other.end(),begin()); |
| 252 | } |
| 253 | return *this; |
| 254 | } |
| 255 | |
| 256 | T* origin() { return this->base_; } |
| 257 | const T* origin() const { return this->base_; } |
| 258 | |
| 259 | reference operator[](index idx) { |
nothing calls this directly
no test coverage detected