Skip to content

Commit

Permalink
concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
stasoid committed Dec 9, 2024
1 parent 18132a0 commit aa70a15
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions Libraries/LibIPC/Concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,21 @@ namespace IPC::Concepts {

namespace Detail {

// Cannot use SpecializationOf with these templates because they have non-type parameters. See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1985r3.pdf
template<typename T>
constexpr inline bool IsHashMap = false;
template<typename K, typename V, typename KeyTraits, typename ValueTraits, bool IsOrdered>
constexpr inline bool IsHashMap<HashMap<K, V, KeyTraits, ValueTraits, IsOrdered>> = true;

template<typename T>
constexpr inline bool IsOptional = false;
template<typename T>
constexpr inline bool IsOptional<Optional<T>> = true;

template<typename T>
constexpr inline bool IsSharedSingleProducerCircularQueue = false;
template<typename T, size_t Size>
constexpr inline bool IsSharedSingleProducerCircularQueue<Core::SharedSingleProducerCircularQueue<T, Size>> = true;

template<typename T>
constexpr inline bool IsVariant = false;
template<typename... Ts>
constexpr inline bool IsVariant<Variant<Ts...>> = true;

template<typename T>
constexpr inline bool IsVector = false;
template<typename T>
constexpr inline bool IsVector<Vector<T>> = true;
template<typename T, size_t inline_capacity>
constexpr inline bool IsVector<Vector<T, inline_capacity>> = true;

template<typename T>
constexpr inline bool IsArray = false;
Expand All @@ -63,13 +54,13 @@ template<typename T>
concept HashMap = Detail::IsHashMap<T>;

template<typename T>
concept Optional = Detail::IsOptional<T>;
concept Optional = SpecializationOf<T, AK::Optional>;

template<typename T>
concept SharedSingleProducerCircularQueue = Detail::IsSharedSingleProducerCircularQueue<T>;

template<typename T>
concept Variant = Detail::IsVariant<T>;
concept Variant = SpecializationOf<T, AK::Variant>;

template<typename T>
concept Vector = Detail::IsVector<T>;
Expand Down

0 comments on commit aa70a15

Please sign in to comment.