Turn util::to_string into a callable object
This commit is contained in:
parent
10ddf4933b
commit
aa61c63609
1 changed files with 13 additions and 17 deletions
|
|
@ -19,25 +19,21 @@ namespace psemek::util
|
|||
return oss.str();
|
||||
}
|
||||
|
||||
template <typename Char, typename Traits = std::char_traits<Char>>
|
||||
struct to_string_impl
|
||||
{
|
||||
template <typename ... Args>
|
||||
std::basic_string<Char, Traits> operator()(Args const & ... args) const
|
||||
{
|
||||
return detail::to_string<Char, Traits>(args...);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
std::string to_string(Args const & ... args)
|
||||
{
|
||||
return detail::to_string<char>(args...);
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
std::wstring to_wstring(Args const & ... args)
|
||||
{
|
||||
return detail::to_string<wchar_t>(args...);
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
std::u32string to_u32string(Args const & ... args)
|
||||
{
|
||||
return detail::to_string<char32_t>(args...);
|
||||
}
|
||||
constexpr detail::to_string_impl<char> to_string;
|
||||
constexpr detail::to_string_impl<wchar_t> to_wstring;
|
||||
constexpr detail::to_string_impl<char32_t> to_u32string;
|
||||
|
||||
template <typename T, typename Char, typename Traits>
|
||||
T from_string(std::basic_string<Char, Traits> const & s)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue