From aa61c63609908d46b9582de418e5164b594429e6 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 24 Feb 2023 15:01:27 +0300 Subject: [PATCH] Turn util::to_string into a callable object --- libs/util/include/psemek/util/to_string.hpp | 30 +++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/libs/util/include/psemek/util/to_string.hpp b/libs/util/include/psemek/util/to_string.hpp index 2573d01f..103f05fc 100644 --- a/libs/util/include/psemek/util/to_string.hpp +++ b/libs/util/include/psemek/util/to_string.hpp @@ -19,25 +19,21 @@ namespace psemek::util return oss.str(); } + template > + struct to_string_impl + { + template + std::basic_string operator()(Args const & ... args) const + { + return detail::to_string(args...); + } + }; + } - template - std::string to_string(Args const & ... args) - { - return detail::to_string(args...); - } - - template - std::wstring to_wstring(Args const & ... args) - { - return detail::to_string(args...); - } - - template - std::u32string to_u32string(Args const & ... args) - { - return detail::to_string(args...); - } + constexpr detail::to_string_impl to_string; + constexpr detail::to_string_impl to_wstring; + constexpr detail::to_string_impl to_u32string; template T from_string(std::basic_string const & s)