MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / subSlice

Method subSlice

include/exiv2/slice.hpp:230–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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/*!

Callers

nothing calls this directly

Calls 1

rangeCheckMethod · 0.80

Tested by

no test coverage detected