1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00: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
17 changed files with 60 additions and 61 deletions

View file

@ -6,6 +6,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Concepts.h>
#include <AK/DeprecatedString.h>
#include <LibJS/Print.h>
#include <LibJS/Runtime/Array.h>
@ -362,9 +363,8 @@ ErrorOr<void> print_async_generator(JS::PrintContext& print_context, JS::AsyncGe
return {};
}
template<typename T>
template<Arithmetic T>
ErrorOr<void> print_number(JS::PrintContext& print_context, T number)
requires IsArithmetic<T>
{
TRY(js_out(print_context, "\033[35;1m"));
TRY(js_out(print_context, "{}", number));

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/Concepts.h>
#include <AK/Forward.h>
#include <LibCrypto/Forward.h>
#include <LibJS/Forward.h>
@ -167,9 +168,8 @@ Vector<T> merge_lists(Vector<T> const& a, Vector<T> const& b)
}
// x modulo y, https://tc39.es/ecma262/#eqn-modulo
template<typename T, typename U>
template<Arithmetic T, Arithmetic U>
auto modulo(T x, U y)
requires(IsArithmetic<T>, IsArithmetic<U>)
{
// The notation “x modulo y” (y must be finite and non-zero) computes a value k of the same sign as y (or zero) such that abs(k) < abs(y) and x - k = q × y for some integer q.
VERIFY(y != 0);