diff options
author | Christian Theune <ct@flyingcircus.io> | 2016-01-04T23·40+0100 |
---|---|---|
committer | Christian Theune <ct@flyingcircus.io> | 2016-01-04T23·40+0100 |
commit | 14ebde52893263930cdcde1406cc91cc5c42556f (patch) | |
tree | 2b65c11405f9aef33eb284208716f9cb5b434599 /src/libutil/util.hh | |
parent | b8258a4475726b56a4caa6553568c67a343a091d (diff) |
First hit at providing support for floats in the language.
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 8 |
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); |