summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
diff options
context:
space:
mode:
authorMoustafa Raafat <MoustafaRaafat2@gmail.com>2022-11-14 18:20:59 +0000
committerSam Atkins <atkinssj@gmail.com>2022-12-09 11:25:30 +0000
commitae2abcebbbabf7ca8b806b5555c11cd0b216dbdb (patch)
treecef5406660d2e60fedda9dcd0839c8f88e0a2d93 /Userland/Libraries/LibCore
parent9721da2e6ae2948319ae731b65073d1fe7200b4f (diff)
downloadserenity-ae2abcebbbabf7ca8b806b5555c11cd0b216dbdb.zip
Everywhere: Use C++ concepts instead of requires clauses
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r--Userland/Libraries/LibCore/ArgsParser.cpp13
-rw-r--r--Userland/Libraries/LibCore/ArgsParser.h6
2 files changed, 9 insertions, 10 deletions
diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp
index 72d226c579..2d145b365c 100644
--- a/Userland/Libraries/LibCore/ArgsParser.cpp
+++ b/Userland/Libraries/LibCore/ArgsParser.cpp
@@ -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();
},
diff --git a/Userland/Libraries/LibCore/ArgsParser.h b/Userland/Libraries/LibCore/ArgsParser.h
index 420f52213b..66331760de 100644
--- a/Userland/Libraries/LibCore/ArgsParser.h
+++ b/Userland/Libraries/LibCore/ArgsParser.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/Concepts.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/Vector.h>
@@ -89,9 +90,8 @@ public:
void add_option(char const*& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
void add_option(DeprecatedString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
void add_option(StringView& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
- template<typename Integral>
- void add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None)
- requires(IsIntegral<Integral>);
+ template<Integral I>
+ void add_option(I& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
void add_option(double& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
void add_option(Optional<double>& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
void add_option(Optional<size_t>& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);