comparison include/utils.hpp @ 708:a37c565f4b68

merged dev
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 22 Jul 2015 14:17:44 -0400
parents bee0e7407af7
children 6c5ce3ec497e
comparison
equal deleted inserted replaced
707:7efa36b9bcfd 708:a37c565f4b68
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