1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

Everywhere: Use C++ concepts instead of requires clauses

This commit is contained in:
Moustafa Raafat 2022-11-14 18:20:59 +00:00 committed by Sam Atkins
parent 9721da2e6a
commit ae2abcebbb
Notes: sideshowbarker 2024-07-17 03:36:21 +09:00
17 changed files with 60 additions and 61 deletions

View file

@ -460,9 +460,8 @@ void ArgsParser::add_option(StringView& value, char const* help_string, char con
add_option(move(option));
}
template<typename Integral>
void ArgsParser::add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
requires(IsIntegral<Integral>)
template<Integral I>
void ArgsParser::add_option(I& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
{
Option option {
OptionArgumentMode::Required,
@ -472,11 +471,11 @@ requires(IsIntegral<Integral>)
value_name,
[&value](char const* s) {
auto view = StringView { s, strlen(s) };
Optional<Integral> opt;
if constexpr (IsSigned<Integral>)
opt = view.to_int<Integral>();
Optional<I> opt;
if constexpr (IsSigned<I>)
opt = view.to_int<I>();
else
opt = view.to_uint<Integral>();
opt = view.to_uint<I>();
value = opt.value_or(0);
return opt.has_value();
},