You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
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):
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).The text was updated successfully, but these errors were encountered: