Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
#ifndef KGR_KANGARU_INCLUDE_KANGARU_PREDICATE_HPP
#define KGR_KANGARU_INCLUDE_KANGARU_PREDICATE_HPP
#include "type_id.hpp"
namespace kgr {
struct All {
constexpr inline bool operator()(type_id_t) const {
return true;
}
};
template<typename First, typename... Ts>
struct NoneOf {
constexpr bool operator()(type_id_t id) const {
return !compare<type_id<First>, type_id<Ts>...>(id);
}
private:
template<type_id_t comp, type_id_t second, type_id_t... others>
constexpr bool compare(type_id_t id) const {
return id == comp && compare<second, others...>(id);
}
template<type_id_t comp>
constexpr bool compare(type_id_t id) const {
return id == comp;
}
};
template<typename First, typename... Ts>
struct AnyOf {
constexpr bool operator()(type_id_t id) const {
return compare<type_id<First>, type_id<Ts>...>(id);
}
private:
template<type_id_t comp, type_id_t second, type_id_t... others>
constexpr bool compare(type_id_t id) const {
return id == comp && compare<second, others...>(id);
}
template<type_id_t comp>
constexpr bool compare(type_id_t id) const {
return id == comp;
}
};
} // namespace kgr
#endif // KGR_KANGARU_INCLUDE_KANGARU_PREDICATE_HPP