I'm not a fan of how this schedules an exception, it's a non-obvious side effect. Maybe return `static_cast<size_t>(-1)` and have callers check the return value.