AK: Add IsTemplateBaseOf<Base, Derived> concept

This concept checks if any specialization of `Base<...>` is a base class
of `Derived`.
This commit is contained in:
Jonne Ransijn 2024-11-19 15:34:23 +01:00
parent 1a03a27c86
commit b09595e147
No known key found for this signature in database
GPG key ID: 49DC70026D2C578C

View file

@ -456,6 +456,19 @@ using AssertSize = __AssertSize<T, ExpectedSize, sizeof(T)>;
template<typename T>
inline constexpr bool IsPOD = __is_pod(T);
template<template<typename...> class Base, typename Derived>
struct __IsTemplateBaseOf {
template<typename... Args>
static TrueType test(Base<Args...> const*);
static FalseType test(...);
using type = decltype(test(declval<Derived*>()));
};
template<template<typename...> class Base, typename Derived>
inline constexpr bool IsTemplateBaseOf = __IsTemplateBaseOf<Base, Derived>::type::value;
template<typename T>
inline constexpr bool IsTrivial = __is_trivial(T);
@ -654,6 +667,7 @@ using AK::Detail::IsSame;
using AK::Detail::IsSameIgnoringCV;
using AK::Detail::IsSigned;
using AK::Detail::IsSpecializationOf;
using AK::Detail::IsTemplateBaseOf;
using AK::Detail::IsTrivial;
using AK::Detail::IsTriviallyAssignable;
using AK::Detail::IsTriviallyConstructible;