Commit graph

31 commits

Author SHA1 Message Date
Ali Mohammad Pur
5a0ad6812c AK: Add a CallableAs<R, Args...> concept
This is just the concept version of the IsCallableWithArguments type
trait previously defined in Function.h.
2023-07-08 23:13:00 +01:00
Timothy Flynn
996c020b0d Everywhere: Remove 'clang-format off' comments that are no longer needed 2023-07-08 10:32:56 +01:00
Lucas CHOLLET
e538fa203e AK: Add the ConvertibleTo concept 2023-02-04 18:47:02 -07:00
Timothy Flynn
f31bd190b0 AK: Ensure string types are actually considered hash-compatible
The AnyString concept is currently broken because it checks whether a
StringView is constructible from a type T. The StringView constructors,
however, only accept constant rvalue references - i.e. `T const&`.

This also adds a test to ensure this continues to work.
2023-02-02 19:14:00 +00:00
Lucas CHOLLET
6c83bd8fd4 AK: Introduce the DerivedFrom concept 2022-12-12 16:21:39 +00:00
kleines Filmröllchen
bbb256e8b5 AK: Introduce Indexable concept
This was dearly missing and can be used in many existing templates.
2022-12-12 15:03:57 +00:00
Moustafa Raafat
b8f1e1bed2 Everywhere: Remove unnecessary AK and Detail namespace scoping 2022-12-09 11:25:30 +00:00
Tim Schumacher
03fd9002da AK: Export Details and Concepts into the AK namespace
AK internals like to use concepts and details without a fully qualified
name, which usually works just fine because we make everything
AK-related available to the unqualified namespace.

However, this breaks as soon as we start not using `USING_AK_GLOBALLY`,
due to those identifiers no longer being made available. Instead, we
just export those into the `AK` namespace instead.
2022-11-27 23:54:40 +01:00
Andreas Kling
ae3ffdd521 AK: Make it possible to not using AK classes into the global namespace
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by
default, but can be overridden by build flags.

This is a step towards integrating Jakt and AK types.
2022-11-26 15:51:34 +01:00
Timothy Flynn
56ab529752 AK: Add a concept for requiring that a function is fallible
This ensures that the function may be wrapped with TRY() and MUST().
2022-11-18 12:21:57 +00:00
Ali Mohammad Pur
2b79f36148 AK: Add a OneOfIgnoringCV concept
Some functions want to ignore cv-qualifiers, and it's much easier to
constrain the type through a concept than a separate requires clause on
the function.
2022-04-20 00:15:23 +04:30
Ali Mohammad Pur
06cedf5bae AK: Add a 'OneOf' concept
Similar to 'SameAs', but for multiple types.
2022-03-28 23:11:48 +02:00
kleines Filmröllchen
604309327e AK: Add the Fundamental concept 2022-02-23 00:42:49 +00:00
Ali Mohammad Pur
7a58c510e5 AK: Add a 'SpecializationOf' concept
The counterpart to the IsSpecializationOf<...> template.
2022-02-15 18:03:02 +02:00
kleines Filmröllchen
07977ad94c AK: Introduce the ArrayLike concept
The ArrayLike type concept focuses on array-like data accesses. This
means the ability to randomly index, obtain size information, as well as
being able to expose the storage pointer. The last two already have the
standard APIs `size` and `data`, respectively.

The ArrayLike concept should always be fulfilled by Vector, FixedArray
and Array as the three main array-like types. C-style arrays themselves
of course can't fulfil ArrayLike (which could be considered ironic), but
as we don't use them much anyways this isn't a problem.
2022-01-28 23:40:25 +01:00
Timothy Flynn
01395169dc AK: Export the SameAs concept 2022-01-27 16:27:00 +00:00
Hendiadyoin1
c8bee92fb9 AK: Add the concept of hash-compatible types 2021-12-15 13:09:49 +03:30
Hendiadyoin1
92e824afa1 AK: Add a Concept for any String type 2021-12-15 13:09:49 +03:30
Ali Mohammad Pur
f879e04133 AK: Add a concept for iterable containers
This concept describes a type with a begin()/end() pair that can
function as an iterator, given the following criteria:
- The return type of begin() is comparable with the return type of
  end(), and the comparison (with operator!=) yields a bool
- The object returned from begin() can be pre-incremented
- The iterator has an operator*() implementation
2021-07-22 22:56:20 +02:00
Timothy
e42484bb65 AK+LibIPC: Make all enums codable
If an enum has a supported underlying type we can provide encoding and
decoding for the enum as well.
2021-07-04 13:48:20 +04:30
Daniel Bertalan
985adcca38 AK: Make C++ concepts support mandatory for compilers
The latest GCC and Clang versions both support this, so we can freely
use these in our code.
2021-06-24 17:35:49 +04:30
Nicholas Baron
aa4d41fe2c
AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
By constraining two implementations, the compiler will select the best
fitting one. All this will require is duplicating the implementation and
simplifying for the `void` case.

This constraining also informs both the caller and compiler by passing
the callback parameter types as part of the constraint
(e.g.: `IterationFunction<int>`).

Some `for_each` functions in LibELF only take functions which return
`void`. This is a minimal correctness check, as it removes one way for a
function to incompletely do something.

There seems to be a possible idiom where inside a lambda, a `return;` is
the same as `continue;` in a for-loop.
2021-05-16 10:36:52 +01:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
AnotherTest
a6e4482080 AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities
arguably more nice-looking by removing the need to reach into the
wrapper structs generated by them to get the value/type needed.
The C++ standard library had to invent `_v` and `_t` variants (likely
because of backwards compat), but we don't need to cater to any codebase
except our own, so might as well have good things for free. :^)
2021-04-10 21:01:31 +02:00
Michel Hermier
7d591432c4 AK: Add Signed/Unsigned concepts. 2021-03-28 11:45:51 +02:00
Michel Hermier
b8fac0a8b3 AK: Make Concepts.h and StdLibExtras.h properly alias their own sumbols. 2021-03-28 11:45:51 +02:00
Cesar Torres
f4f5a1c0e7 AK: Add complex number library
Useful for diverse algorithms.
Also added some tests for it.
2021-03-27 10:20:55 +01:00
Linus Groh
4dcd23c2be AK: Pull Is{Integral,FloatingPoint} into the global namespace 2020-12-05 23:52:17 +01:00
Brian Gianforcaro
ff0c7da75d AK: Add SFINAE fallback for AK C++ concepts use, for Coverity compiler
The Coverity compiler doesn't support C++2a yet, and thus doesn't
even recognize concept keywords. To allow serenity to be built and
analyzed on such compilers, add a fallback underdef to perform
the same template restriction based on AK::EnableIf<..> meta
programming.

Note: Coverity does seem to (annoyingly) define __cpp_concepts, even
though it doesn't support them, so we need to further check for
__COVERITY__ explicitly.
2020-08-17 09:17:57 +02:00
asynts
3fb62e8c63 AK: Remove unnecessary clang-format off comments. 2020-08-07 15:57:51 +02:00
asynts
5f7427ba4b AK: Add Integral and FloatingPoint concepts. 2020-08-06 10:33:16 +02:00