diff options
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 b714cdc64..9eebb67fd 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -366,6 +366,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); |