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 committed by Sam Atkins
parent b7e22f0916
commit e8b2d35410
Notes: github-actions[bot] 2024-12-04 16:47:14 +00:00

View file

@ -456,6 +456,19 @@ using AssertSize = __AssertSize<T, ExpectedSize, sizeof(T)>;
template<typename T> template<typename T>
inline constexpr bool IsPOD = __is_pod(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> template<typename T>
inline constexpr bool IsTrivial = __is_trivial(T); inline constexpr bool IsTrivial = __is_trivial(T);
@ -654,6 +667,7 @@ using AK::Detail::IsSame;
using AK::Detail::IsSameIgnoringCV; using AK::Detail::IsSameIgnoringCV;
using AK::Detail::IsSigned; using AK::Detail::IsSigned;
using AK::Detail::IsSpecializationOf; using AK::Detail::IsSpecializationOf;
using AK::Detail::IsTemplateBaseOf;
using AK::Detail::IsTrivial; using AK::Detail::IsTrivial;
using AK::Detail::IsTriviallyAssignable; using AK::Detail::IsTriviallyAssignable;
using AK::Detail::IsTriviallyConstructible; using AK::Detail::IsTriviallyConstructible;