🧹 utils: refactor templates in C++20-style

This commit is contained in:
Vladislav Nepogodin 2024-07-01 15:52:11 +04:00
parent 3facb2a41c
commit 42138cf365
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9

View File

@ -74,17 +74,15 @@ void grub_mkconfig() noexcept;
void enable_services() noexcept;
void final_check() noexcept;
template <typename T = std::int32_t,
typename = std::enable_if_t<std::numeric_limits<T>::is_integer>>
inline T to_int(const std::string_view& str) {
template <typename T = std::int32_t>
inline T to_int(const std::string_view& str) requires std::numeric_limits<T>::is_integer {
T result = 0;
std::from_chars(str.data(), str.data() + str.size(), result);
return result;
}
template <typename T = double,
typename = std::enable_if_t<std::is_floating_point<T>::value>>
inline T to_floating(const std::string_view& str) {
template <typename T = double>
inline T to_floating(const std::string_view& str) requires std::is_floating_point<T>::value {
T result = 0;
std::from_chars(str.data(), str.data() + str.size(), result);
return result;