X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.txx;h=553c9b5f1df523ab1efdd0cdbc3aa63f7dc9598b;hb=c20a6b26e1ed141fbcdb7d72592ce7f0537698c7;hp=b5a34712a9988438db9ec4afbf06c35d21092f76;hpb=c7f6f682ddc01d2a41740bbdb806f9ef967b57d5;p=clitk.git diff --git a/common/clitkCommon.txx b/common/clitkCommon.txx index b5a3471..553c9b5 100644 --- a/common/clitkCommon.txx +++ b/common/clitkCommon.txx @@ -76,6 +76,19 @@ std::string toString(const T & t) } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// http://www.codeguru.com/forum/showthread.php?t=231054 +template +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