about summary refs log tree commit diff
path: root/src/libutil/util.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-11-24T12·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-11-24T12·26+0000
commit9b8fda796b620a5476e8a50edcc29a3462667fc3 (patch)
treefa546a5b5a0b08c01a7bdc9ee50e69d7bfd87165 /src/libutil/util.hh
parent80220155523fb21c938d595e96597f6511aa7bd0 (diff)
* Templatise getIntArg / string2Int.
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r--src/libutil/util.hh9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 5744e56922..2d75a7a506 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -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'. */