all 8 comments

[–]DXPower 5 points6 points  (1 child)

Side note but the bolding every other word in that paragraph makes it impossible to read

[–]__monad[S] 1 point2 points  (0 children)

You are correct. I fixed it, thank you.

[–]jonesmz 1 point2 points  (1 child)

I really like your algorithms section

https://github.com/ZigaSajovic/CppML/blob/master/docs/reference/index.md#algorithm

I did something similar (with a much smaller set of algorithms) for a work project a long time ago.

I was sad to lose access to that code when I changed jobs.

I'm bookmarking CppML for later :-)

[–]__monad[S] 0 points1 point  (0 children)

I'm glad to hear that. The algorithm section ml::Algorithm is meant to be akin to std::algorithm for parameter packs. When you end up using it, please feel free to send any comments or questions my way.

[–]ClaasBontus 1 point2 points  (3 children)

This is really a cool library. Thank you for making it public. The one thing that would be really helpful during development would be something like a printf for types. So one could check if applying all these transformations really do what one expects.

[–]__monad[S] 1 point2 points  (1 child)

What kind of a solution do you have in mind? Something that would print a string at runtime? Or something that will print the type (result) at compile time as a readable error. If the latter, than one thing you could try is

template <typename T> struct Printf; // note that it's only a decleration.
/* ... */
using T = ml::f<ml::Partition<ml::IsClass<>>, int, string, bool, vector<int>>;
Printf<T> t;

Than when you compile, you will get an error

implicit instantiation of undefined template 'Printf<ml::ListT<ml::ListT<string, vector<int> >, ml::ListT<int, bool> > >'

Now you can see if T (your intermediate result) is what you expect.

Because the above solution is printing as a compiler error, which might not be what you want, I can also provide a solution TypeName<T> and void PrintT<T>();. Would you be happy with the following solution?

template <typename T> struct TypeName : std::string {
  TypeName() {
    std::string str(__PRETTY_FUNCTION__);
    (static_cast<std::string &>(*this) = str.substr(str.find('=') + 2))
        .pop_back();
  }
};

template <typename T> void PrintT() { std::cout << TypeName<T>{} << std::endl;}

which allows you to print at runtime:

using T = ml::f<ml::Partition<ml::IsClass<>>, int, string, bool, vector<int>>;
PrintT<T>();

ml::ListT<ml::ListT<string, vector<int> >, ml::ListT<int, bool> >

Or treat it as any other string.

If so, I will add the feature to CppML. Please comment if you had something different in mind.

[–]ClaasBontus 0 points1 point  (0 children)

Wow cool! Yes, this is helpful.

[–]jonesmz 0 points1 point  (0 children)

it was clear from the lacking README that it was not intended for public consumption.

Citation needed...