]> Creatis software - clitk.git/blobdiff - common/clitkCommon.txx
Enable interactive display in tool binarize
[clitk.git] / common / clitkCommon.txx
index b5a34712a9988438db9ec4afbf06c35d21092f76..553c9b5f1df523ab1efdd0cdbc3aa63f7dc9598b 100644 (file)
@@ -76,6 +76,19 @@ std::string toString(const T & t)
 }
 //--------------------------------------------------------------------
 
+
+//--------------------------------------------------------------------
+// http://www.codeguru.com/forum/showthread.php?t=231054
+template <class T>
+bool fromString(T& t, const std::string& s, 
+                std::ios_base& (*f)(std::ios_base&))
+{
+  std::istringstream iss(s);
+  return !(iss >> f >> t).fail();
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 // Convert float*, double* ... to string
 template<class T>