| 350 | } |
| 351 | |
| 352 | StringView StringView::substr(size_t position, size_t n) const { |
| 353 | StringView ret; |
| 354 | auto itEnd = end(); |
| 355 | auto it = begin(); |
| 356 | |
| 357 | for (size_t i = 0; i != position; ++i) { |
| 358 | if (it == itEnd) |
| 359 | throw OutOfRangeException(strf("out of range in StringView::substr({}, {})", position, n)); |
| 360 | it++; |
| 361 | } |
| 362 | |
| 363 | const auto itStart = it; |
| 364 | |
| 365 | for (size_t i = 0; i != n; ++i) { |
| 366 | if (it == itEnd) |
| 367 | break; |
| 368 | ++it; |
| 369 | } |
| 370 | |
| 371 | return StringView(&*itStart.base(), it.base() - itStart.base()); |
| 372 | } |
| 373 | |
| 374 | int StringView::compare(size_t selfOffset, size_t selfLen, StringView other, |
| 375 | size_t otherOffset, size_t otherLen, CaseSensitivity cs) const { |
no test coverage detected