mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 22:42:31 +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 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;
|
||||
|
Loading…
Reference in New Issue
Block a user