This is a way to have optional arguments. Basically, if you are interested in knowing who is the first character that has not been converted to a number. If you are not very interested in this result, you can pass nullptr.
§21.5 [string.conversions] / 1 [...] If the function does not throw an exception and idx! = 0, the function saves in * idx the index of the first uncured str element.
It is intended for use as:
int main() { std::string two{"2 and more contents"};
Using a pointer, you can make the argument really optional if it was an out parameter, but required the link to be used, but this will require user code to create the variable always regardless of whether it is interested in the value or not, so it will not be really optional .
David Rodríguez - dribeas Jun 20 2018-11-11T00: 00Z
source share