Add some type list machinery
This commit is contained in:
parent
4439218141
commit
f1d995340b
1 changed files with 33 additions and 0 deletions
33
libs/util/include/psemek/util/type_list.hpp
Normal file
33
libs/util/include/psemek/util/type_list.hpp
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
namespace psemek::util
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename ...>
|
||||||
|
struct type_list;
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template <template <typename> typename F, typename ... Args>
|
||||||
|
struct type_list_map_impl
|
||||||
|
{
|
||||||
|
using type = type_list<typename F<Args>::type ...>;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ... Args>
|
||||||
|
struct type_list
|
||||||
|
{
|
||||||
|
template <template <typename> typename F>
|
||||||
|
using map = detail::type_list_map_impl<F, Args...>::type;
|
||||||
|
|
||||||
|
using tuple = std::tuple<Args...>;
|
||||||
|
using variant = std::variant<Args...>;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue