| 228 | */ |
| 229 | template <typename slice_type> |
| 230 | slice_type subSlice(size_t begin, size_t end) { |
| 231 | this->rangeCheck(begin); |
| 232 | // end == size() is a legal value, since end is the first |
| 233 | // element beyond the slice |
| 234 | // end == 0 is not a legal value (subtraction will underflow and |
| 235 | // throw an exception) |
| 236 | this->rangeCheck(end - 1); |
| 237 | |
| 238 | // additions are safe, begin & end are smaller than size() |
| 239 | const size_t new_begin = begin + this->begin_; |
| 240 | const size_t new_end = this->begin_ + end; |
| 241 | if (new_end > this->end_) { |
| 242 | throw std::out_of_range("Invalid input parameters to slice"); |
| 243 | } |
| 244 | return slice_type(this->storage_.data_, new_begin, new_end); |
| 245 | } |
| 246 | }; |
| 247 | |
| 248 | /*! |
nothing calls this directly
no test coverage detected