From 14ebde52893263930cdcde1406cc91cc5c42556f Mon Sep 17 00:00:00 2001 From: Christian Theune Date: Tue, 5 Jan 2016 00:40:40 +0100 Subject: First hit at providing support for floats in the language. --- src/libutil/util.hh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libutil/util.hh') diff --git a/src/libutil/util.hh b/src/libutil/util.hh index f4026a0a88..7ebfd7cee0 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -358,6 +358,14 @@ template bool string2Int(const string & s, N & n) return str && str.get() == EOF; } +/* Parse a string into a float. */ +template 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); -- cgit 1.4.1