! @param[in] s reference token to be converted into an array index @return integer representation of @a s @throw out_of_range.404 if string @a s could not be converted to an integer */
| 8737 | @throw out_of_range.404 if string @a s could not be converted to an integer |
| 8738 | */ |
| 8739 | static int array_index(const std::string& s) |
| 8740 | { |
| 8741 | std::size_t processed_chars = 0; |
| 8742 | const int res = std::stoi(s, &processed_chars); |
| 8743 | |
| 8744 | // check if the string was completely read |
| 8745 | if (JSON_UNLIKELY(processed_chars != s.size())) |
| 8746 | { |
| 8747 | JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); |
| 8748 | } |
| 8749 | |
| 8750 | return res; |
| 8751 | } |
| 8752 | |
| 8753 | json_pointer top() const |
| 8754 | { |