00001 00020 #ifndef CONVERT_TEMPLATE_H_ 00021 #define CONVERT_TEMPLATE_H_ 00022 00023 #include <sstream> 00024 00025 template <class T> 00026 bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) 00027 { 00028 std::istringstream iss(s); 00029 return !(iss >> f >> t).fail(); 00030 } 00031 00032 00033 #endif /*CONVERT_TEMPLATE_H_*/