Mercurial > hg > nsaunier > traffic-intelligence
comparison include/utils.hpp @ 703:bee0e7407af7 dev
corrected compilation bug on linux
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 21 Jul 2015 15:52:43 -0400 |
| parents | b32947b002da |
| children | 6c5ce3ec497e |
comparison
equal
deleted
inserted
replaced
| 702:f0a897d7f3a5 | 703:bee0e7407af7 |
|---|---|
| 1 #ifndef UTILS_HPP | 1 #ifndef UTILS_HPP |
| 2 #define UTILS_HPP | 2 #define UTILS_HPP |
| 3 | 3 |
| 4 #include <sstream> | |
| 4 #include <iosfwd> | 5 #include <iosfwd> |
| 5 #include <string> | 6 #include <string> |
| 6 #include <vector> | 7 #include <vector> |
| 7 | 8 |
| 8 static const double pi = 3.14159265358979323846; | 9 static const double pi = 3.14159265358979323846; |
| 71 | 72 |
| 72 /** Converts strings to numbers. */ | 73 /** Converts strings to numbers. */ |
| 73 template<typename T> | 74 template<typename T> |
| 74 bool fromString(T & result, const std::string & s) { | 75 bool fromString(T & result, const std::string & s) { |
| 75 std::istringstream iss(s); | 76 std::istringstream iss(s); |
| 76 return iss >> result != 0; | 77 iss >> result; |
| 78 return iss.good() || iss.eof(); | |
| 77 } | 79 } |
| 78 | 80 |
| 79 #endif | 81 #endif |
