1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 10:31:15 +02:00

* Templatise getIntArg / string2Int.

This commit is contained in:
Eelco Dolstra 2009-11-24 12:26:25 +00:00
parent 8022015552
commit 9b8fda796b
5 changed files with 25 additions and 40 deletions

View file

@ -295,9 +295,14 @@ bool statusOk(int status);
/* Parse a string into an integer. */
template<class N> bool string2Int(const string & s, N & n)
{
std::istringstream str(s);
str >> n;
return str && str.get() == EOF;
}
string int2String(int n);
bool string2Int(const string & s, int & n);
bool string2Int(const string & s, long long & n);
/* Return true iff `s' ends in `suffix'. */