add from_string to utility

This commit is contained in:
ToruNiina
2018-12-08 20:18:50 +09:00
parent 66807d19d1
commit 2b2a05148e
2 changed files with 23 additions and 0 deletions

View File

@@ -62,5 +62,16 @@ std::string concat_to_string(Ts&& ... args)
return detail::concat_to_string_impl(oss, std::forward<Ts>(args) ...);
}
template<typename T, typename U>
T from_string(const std::string& str, U&& opt)
{
T v(std::forward<U>(opt));
std::istringstream iss(str);
iss >> v;
return v;
}
}// toml
#endif // TOML11_UTILITY