about summary refs log tree commit diff
path: root/src/libutil/util.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r--src/libutil/util.hh8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index f4026a0a884b..7ebfd7cee0e9 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -358,6 +358,14 @@ template<class N> bool string2Int(const string & s, N & n)
     return str && str.get() == EOF;
 }
 
+/* Parse a string into a float. */
+template<class N> bool string2Float(const string & s, N & n)
+{
+    std::istringstream str(s);
+    str >> n;
+    return str && str.get() == EOF;
+}
+
 
 /* Return true iff `s' ends in `suffix'. */
 bool hasSuffix(const string & s, const string & suffix);