diff --git a/test_tlist.cc b/test_tlist.cc new file mode 100644 index 0000000..88d6ccc --- /dev/null +++ b/test_tlist.cc @@ -0,0 +1,31 @@ +#include +#include +#include "type_utils.hxx" + + +template +struct SizeofReducer { + constexpr auto operator()() { + return sizeof(T); + } + + template + constexpr auto feed() { + if constexpr (sizeof(NT) > sizeof(T)) + return SizeofReducer{}; + else + return SizeofReducer{}; + } +}; + +using size_list = TList; +constexpr size_t max_size = size_list::template reduce()(); + +int main() { + using my_list = TList; + + static_assert(static_type_eq())>()); + + std::cout << max_size << std::endl; +} diff --git a/tlist.hxx b/tlist.hxx new file mode 100644 index 0000000..2f16f77 --- /dev/null +++ b/tlist.hxx @@ -0,0 +1,74 @@ +#include + +#define MYCLASS MYTEMPL class + +template +struct TNAME { + using type = TNAME; + + template class Templ, MYCLASS ...Args> + struct TParam { + using type = Templ; + }; + + template class Templ> + static constexpr auto apply() { + return typename TParam::type{}; + } + + template + static constexpr auto push_front() { + return TNAME{}; + } + + // unit helps working around syntaxical limitations + // where templated types need guiding. Good luck writting the stop + // case of the map function without a similar trick + template + static constexpr auto unit() { + return TNAME{}; + } + + template + static constexpr auto push_back() { + return TNAME{}; + } + + template