Add is_numeric Method
This commit is contained in:
@@ -118,4 +118,15 @@ std::string::const_iterator find_nth(const std::string& haystack, const std::str
|
|||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_numeric(const std::string& string)
|
||||||
|
{
|
||||||
|
auto result = double();
|
||||||
|
std::stringstream i;
|
||||||
|
|
||||||
|
i << string;
|
||||||
|
i >> result;
|
||||||
|
|
||||||
|
return !i.fail() && i.eof();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace StringAlgorithm
|
} // namespace StringAlgorithm
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ bool icontains(const std::string& subject, const std::string& find);
|
|||||||
|
|
||||||
std::string::const_iterator find_nth(const std::string& haystack, const std::string& needle, size_t nth);
|
std::string::const_iterator find_nth(const std::string& haystack, const std::string& needle, size_t nth);
|
||||||
|
|
||||||
|
bool is_numeric(const std::string& str);
|
||||||
|
|
||||||
} // namespace StringAlgorithm
|
} // namespace StringAlgorithm
|
||||||
|
|
||||||
#endif // STRINGALGORITHM_H
|
#endif // STRINGALGORITHM_H
|
||||||
|
|||||||
Reference in New Issue
Block a user