Created
August 10, 2021 22:01
-
-
Save ttldtor/c5a18116a8909bf55134c4cc0b9a6ebb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
template<typename...Ts> | |
struct TypeList { | |
}; | |
template<typename T, typename...Ts> | |
using Tail = TypeList<Ts...>; | |
//template<typename T> | |
//struct FunctionTraits | |
// : public FunctionTraits<decltype(&T::operator())> { | |
//}; | |
template<typename T> | |
struct FunctionTraits | |
: public FunctionTraits<decltype(&std::remove_pointer_t<T>::operator())> { | |
}; | |
template<typename C, typename R, typename... Ts> | |
struct FunctionTraits<R(C::*)(Ts...) const> { | |
enum { | |
Arity = sizeof...(Ts) | |
}; | |
using ResultType = R; | |
using Params = TypeList<Ts...>; | |
template<size_t i> | |
struct Param { | |
typedef typename std::tuple_element<i, std::tuple<Ts...>>::type Type; | |
}; | |
}; | |
template<typename F> | |
auto getParams(F &&) { | |
typedef FunctionTraits<F> Traits; | |
return typename Traits::Params{}; | |
} | |
//struct Entity { | |
//}; | |
// | |
//template<class... PickComponents, size_t... PickComponentIndices> | |
//void iterateEntitiesInternal( | |
// const std::function<void(Entity, const PickComponents &...)> iterFn, | |
// std::index_sequence<PickComponentIndices...> sequence); | |
// | |
//template<class... PickComponents> | |
//void iterateEntities(std::function<void(Entity, const PickComponents &...)> iterFn) { | |
// iterateEntitiesInternal(iterFn, std::index_sequence_for<PickComponents...>{}); | |
//} | |
int main() { | |
getParams([](Entity entity, const auto &c1, const auto &c2, const auto &c3) -> void { | |
}); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment