Consider to update the library to high-level tmp techniques and C++11 features
Opened this issue · 0 comments
Manu343726 commented
I have looked at your implementation and I think it could be improved using modern C++ techniques.
For example, you have implemented lists in a pure-functional way (The head/tail way, where tail is another list), but C++11 variadic templates could be used to implement typelists in a more fancy way.
Consider this example (Using my Turbo C++11 Metaprogramming Library):
#include "Turbo/list.hpp"
#include "Turbo/sort.hpp"
#include "Turbo/to_string.hpp"
#include <iostream>
using list = tml::list<char,bool,int,float,double>;
template<typename T , typename U>
using comparer = tml::boolean<(sizeof(T) >= sizeof<(U))>;
using sorted_list = tml::sort<list,comparer>;
int main()
{
std::cout << tml::to_string<sorted_list>() << std::endl;
}
[double,float,int,bool,char]
As you can see, variadic templates makes declaring a list easier ( tml::list<a,b,c,d,e>
), and template aliases makes a lot easier the definition and ussage of metafunctions (See the library examples).