mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-02-02 22:07:13 +08:00
🧹 utils: refactor templates in C++20-style
This commit is contained in:
parent
3facb2a41c
commit
42138cf365
@ -74,17 +74,15 @@ void grub_mkconfig() noexcept;
|
|||||||
void enable_services() noexcept;
|
void enable_services() noexcept;
|
||||||
void final_check() noexcept;
|
void final_check() noexcept;
|
||||||
|
|
||||||
template <typename T = std::int32_t,
|
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) requires std::numeric_limits<T>::is_integer {
|
||||||
inline T to_int(const std::string_view& str) {
|
|
||||||
T result = 0;
|
T result = 0;
|
||||||
std::from_chars(str.data(), str.data() + str.size(), result);
|
std::from_chars(str.data(), str.data() + str.size(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T = double,
|
template <typename T = double>
|
||||||
typename = std::enable_if_t<std::is_floating_point<T>::value>>
|
inline T to_floating(const std::string_view& str) requires std::is_floating_point<T>::value {
|
||||||
inline T to_floating(const std::string_view& str) {
|
|
||||||
T result = 0;
|
T result = 0;
|
||||||
std::from_chars(str.data(), str.data() + str.size(), result);
|
std::from_chars(str.data(), str.data() + str.size(), result);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user