This commit is contained in:
ZY4N
2024-12-22 16:58:40 +01:00
parent 2704814de2
commit db8db8f9d7
161 changed files with 17102 additions and 0 deletions

49
include/util/for_each.hpp Executable file
View File

@@ -0,0 +1,49 @@
#pragma once
#include <utility>
namespace ztu::for_each {
template<typename... Types>
inline constexpr bool type(auto &&f) {
return (f.template operator()<Types>() || ...);
}
template<auto... Values>
inline constexpr bool value(auto &&f) {
return (f.template operator()<Values>() || ...);
}
template<typename... Args>
inline constexpr bool argument(auto &&f, Args&&... args) {
return (f(std::forward<Args>(args)) || ...);
}
template <auto Size>
inline constexpr bool index(auto&& f) {
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
return (f.template operator()<Indices>() || ...);
}(std::make_index_sequence<Size>());
}
template<typename... Types>
inline constexpr bool indexed_type(auto &&f) {
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
return (f.template operator()<Indices, Types>() || ...);
}(std::make_index_sequence<sizeof...(Types)>());
}
template<auto... Values>
inline constexpr bool indexed_value(auto &&f) {
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
return (f.template operator()<Indices, Values>() || ...);
}(std::make_index_sequence<sizeof...(Values)>());
}
template<typename... Args>
inline constexpr bool indexed_argument(auto &&f, Args&&... args) {
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
return (f.template operator()<Indices>(std::forward<Args>(args)) || ...);
}(std::make_index_sequence<sizeof...(Args)>());
}
}