From 42138cf365b876fc68beef534bd92d0f05091190 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Mon, 1 Jul 2024 15:52:11 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20utils:=20refactor=20templates=20?= =?UTF-8?q?in=20C++20-style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils.hpp b/src/utils.hpp index a5e7bae..0bd9fdb 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -74,17 +74,15 @@ void grub_mkconfig() noexcept; void enable_services() noexcept; void final_check() noexcept; -template ::is_integer>> -inline T to_int(const std::string_view& str) { +template +inline T to_int(const std::string_view& str) requires std::numeric_limits::is_integer { T result = 0; std::from_chars(str.data(), str.data() + str.size(), result); return result; } -template ::value>> -inline T to_floating(const std::string_view& str) { +template +inline T to_floating(const std::string_view& str) requires std::is_floating_point::value { T result = 0; std::from_chars(str.data(), str.data() + str.size(), result); return result;