| 39 | } |
| 40 | |
| 41 | long stol(const string& str, size_t* idx, int base) |
| 42 | { |
| 43 | char* end; |
| 44 | long result = ::strtol(str.c_str(), &end, base); |
| 45 | |
| 46 | if (end != str.c_str()) |
| 47 | { |
| 48 | if (idx) |
| 49 | *idx = static_cast<size_t>(end - str.c_str()); |
| 50 | return result; |
| 51 | } |
| 52 | // TODO: no conversion -> invalid_argument |
| 53 | // TODO: ERANGE in errno -> out_of_range |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | unsigned long stoul(const string& str, size_t* idx, int base) |
| 58 | { |