CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Count.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "TypeList.hpp"
11
12#include <type_traits>
13
14namespace CeresEngine::MPL {
15
17 template<typename T, typename TTypeList> struct CountHelper : std::integral_constant<std::size_t, 0> {};
18
20 template<typename T, typename TTypeList> inline constexpr size_t Count = CountHelper<T, TTypeList>::value;
21
23 template<typename T, typename T0, typename... Ts>
24 struct CountHelper<T, TypeList<T0, Ts...>> : std::integral_constant<std::size_t, (std::is_same_v<T, T0> ? 1 : 0) + Count<T, TypeList<Ts...>>> {};
25
27 template<typename T, typename TTypeList> inline constexpr bool Contains = Count<T, TTypeList> > 0;
28
29} // namespace CeresEngine::MPL
Definition All.hpp:15
constexpr size_t Count
Interface type alias.
Definition Count.hpp:20
constexpr bool Contains
Alias for Count > 0.
Definition Count.hpp:27
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Count base case: 0.
Definition Count.hpp:17
Compile-time list of types.
Definition TypeList.hpp:15