| 34 | beginning of the input `first`. */ |
| 35 | template<typename Iter> |
| 36 | line_position<Iter> find_line_position(Iter first, Iter it) |
| 37 | { |
| 38 | bool prev_cr = false; |
| 39 | auto retval = line_position<Iter>{first, 0, 0}; |
| 40 | for (Iter pos = first; pos != it; ++pos) { |
| 41 | auto const c = *pos; |
| 42 | bool const found = |
| 43 | (c & detail::eol_cp_mask) == c && |
| 44 | std::find(detail::eol_cps.begin(), detail::eol_cps.end(), c) != |
| 45 | detail::eol_cps.end(); |
| 46 | if (found) { |
| 47 | retval.line_start = std::next(pos); |
| 48 | retval.column_number = 0; |
| 49 | } else { |
| 50 | ++retval.column_number; |
| 51 | } |
| 52 | if (found && (!prev_cr || c != 0x000a)) |
| 53 | ++retval.line_number; |
| 54 | prev_cr = c == 0x000d; |
| 55 | } |
| 56 | return retval; |
| 57 | } |
| 58 | |
| 59 | /** Returns the iterator to the end of the line in which `it` is |
| 60 | found. */ |
no test coverage detected