Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider to update the library to high-level tmp techniques and C++11 features #1

Open
Manu343726 opened this issue Feb 28, 2014 · 0 comments

Comments

@Manu343726
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant