1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:27:45 +00:00

AK: Use conditionally trivial special member functions

This commit makes use of the conditionally trivial special member
functions introduced in C++20. Basically, `Optional` and `Variant`
inherits whether its wrapped type is trivially copy constructible,
trivially copy assignable or trivially destructible. This lets the
compiler optimize optimize a large number of their use cases.

The constraints have been applied to `Optional`'s converting
constructors too in order to make the API more explicit.

This feature is not supported by Clang yet, so we use conditional
compilation so that Lagom can be built on macOS. Once Clang has P0848R3
support, these can be removed.
This commit is contained in:
Daniel Bertalan 2021-07-02 17:42:50 +02:00 committed by Ali Mohammad Pur
parent 6c0b9919ce
commit 515e2d9734
3 changed files with 70 additions and 37 deletions

View file

@ -25,6 +25,10 @@
#define ARCH(arch) (defined(AK_ARCH_##arch) && AK_ARCH_##arch)
#if !defined(__clang__)
# define AK_HAS_CONDITIONALLY_TRIVIAL
#endif
#ifdef ALWAYS_INLINE
# undef ALWAYS_INLINE
#endif