Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 15:06

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 24 07:47

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 23 02:04
    pthom commented #432
  • Jan 18 12:46

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 16 22:27
    ricejasonf commented #434
  • Jan 05 06:22
    ricejasonf commented #330
  • Jan 03 11:40

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 02 00:33
    ricejasonf closed #434
  • Jan 02 00:33
    ricejasonf commented #434
  • Jan 02 00:04
    ricejasonf opened #434
  • Dec 27 2018 13:11

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Dec 22 2018 11:56
    pthom commented #432
  • Dec 22 2018 11:55
    pthom commented #432
  • Dec 21 2018 15:48
    pthom synchronize #432
  • Dec 21 2018 09:19
    sdebionne opened #433
  • Dec 21 2018 00:08
    ricejasonf commented #432
  • Dec 21 2018 00:03
    ricejasonf commented #432
  • Dec 20 2018 23:36
    pthom commented #432
  • Dec 20 2018 23:36
    pthom commented #432
  • Dec 20 2018 23:13
    ricejasonf commented #432
Manu Sánchez
@Manu343726
There is no fancy "X does not satisfy Y concept" error message though. Just ignores the template. At least there's no 100k lines error like with SFINAE.
Louis Dionne
@ldionne
Exciting.
Can you put your experiments in a repo so I can watch it?
Manu Sánchez
@Manu343726
sure. I'm playing with Turbo datatypes now. I have added a concepts-lite branch, file examples/main.cpp.
Louis Dionne
@ldionne
Cool, thanks.
Manu Sánchez
@Manu343726
Note the order of concept parameters. It feels reversed for me.
Louis Dionne
@ldionne
I don’t get it. What do you mean?
Manu Sánchez
@Manu343726
Binary concepts such as Comparable<T,U> can be used explicitly via a requires Comparable<T,U> expression. The shorthand is template<Comparable<U> T>
I feel that should be template<Comparable<T> U>...
Louis Dionne
@ldionne
Oh, I get it.
Louis Dionne
@ldionne

Is it possible to constrain template-template parameters with concepts? Imagine the following (flawed) constraint:

template <typename Xs>
constexpr bool Foldable() { return ...; }

template <Foldable Xs>
constexpr decltype(auto) sum(Xs&& xs) {
    return foldl(xs, 0, _ + _);
}

Instead, the correct thing to write would be

template <template <typename> class Xs>
constexpr bool Foldable() { return ...; }

template <typename T>
constexpr bool Monoid() { return ...; }

template <Foldable Xs, Monoid T>
constexpr decltype(auto) sum(Xs<T> /* perfect forwarding magic */ xs) {
    // we also need to define the 0 and + of the Monoid
    return foldl(xs, 0, _ + _); 
}
Is this possible?
Manu Sánchez
@Manu343726
It works! Seems like any kind of template parameter is allowed
Louis Dionne
@ldionne
Awesome. I think Hana could benefit a lot from concepts. It could make a lot of tag-dispatching issues like the need to write sum<int> go away.
Manu Sánchez
@Manu343726
template<template<typename...> class T>
constexpr bool Template() { return true; }

template<Template T>
struct foo
{
    using type = T<int>;
};
Bye bye ugly template-template parameters.
Louis Dionne
@ldionne
lmfao
Wut wait.
Universal non-type template params?
template <typename T>
constexpr bool Integral() { 
    return T is in {int, char, long, ...}; 
}

template <Integral i> 
struct foo { };
Manu Sánchez
@Manu343726
Whaaaaaaaaaaaaaaaaaaaaaaaaaaat?????????? Wait wait wait.
Louis Dionne
@ldionne
I don’t know, I’m just throwing stuff around. My GCC-clite is still compiling :)
Manu Sánchez
@Manu343726
Nooooo, it expects a class :(
Louis Dionne
@ldionne
Too bad.
Anyway, I have to go for a bit, bye.
Manu Sánchez
@Manu343726
Bye
Manu Sánchez
@Manu343726
It's explained on the examples http://concepts.axiomatics.org/~ans/
The implementation only does constraining on types. Note he is still using template functions.
Manu Sánchez
@Manu343726
what's up with your gcc build? were you able to give concepts lite a try?
Louis Dionne
@ldionne
The GCC build is done. I have not tried it yet since I’m working on my upcoming presentation at C++Now. Any updates on your side?
Manu Sánchez
@Manu343726
Nope, maybe this weekend
Louis Dionne
@ldionne
Ok. I’ll give it a try as soon as I have the time. I think this is really promising.
Manu Sánchez
@Manu343726
Don't worry, I will be experimenting with gcc-lite capabilities, looking at its limitations, etc. Let's talk next week. Good luck at c++ now.
Louis Dionne
@ldionne
Thanks
Manu Sánchez
@Manu343726

Hi Louis. I managed to get a couple of hours to play with this. Some tips:

  • I have forked pfultz2/Tick C++11 concepts definition lib. My fork just adds a constexpr predicate as gcc-clite expects. Given a tick trait T, I also add a T() predicate in a nested conceptsnamespace. Just a first approximation, I'm not very happy because of naming: Traits are usually snake case, but I find concepts on camel case more readable (Like the proposal). So concepts::is_integral() does not look very well for me. Integral looks better.

  • After playing a bit I finally found a way to successfully do partial template specialization on templates constrained with concepts: Define a concept which represents any type (I named it Auto following proposal wording about the unconstrained type concept)

     template<typename T>
     constexpr bool Auto()
     {
         return true;
     }

    Use it instead of typenamekeyword. In other words, all parameters that will be specialized based on a concept constraint should be constrained at the beginning too. Else build fails with a type/value mismatch. Do the same with template template parameters.

     template<typename T> //Does not work. 
     struct foo
     {
         typedef struct error {} type;
     };
    
     template<Comparable T> //Type/value mismatch here. Use Auto concept instead of typename above
     struct foo<T>
     {
         using type = void;
     };

    The cool point is that this works on all levels. For example, this is how I'm defining the Template concept:

     template<template<Auto...> class T>
     consexpt bool Template()
     {
         return true;
     }
Louis Dionne
@ldionne
Wow, that’s cool! I asked Andrew Sutton about it, and he told me templates could be used in concepts. I’m at C++Now right now but I’ll be back home sunday; I’ll take a closer look into this then.
Manu Sánchez
@Manu343726
Hans Meyer
@HaMster21
@ldionne I'm sorry but it doesn't seem that I'm getting into the biicode bootstrap any time soon. At the moment work and family is keeping me busy.
Maybe @Manu343726 can help with this? You seem to be "a little" more qualified for that :wink:
There is already an issue for that, #55
Louis Dionne
@ldionne
No problem @HaMster21 . I’ll try to see if I can make it to work when I get some time.
Manu Sánchez
@Manu343726
I wasn't aware you were talking about integrating hana into biicode. I should subscribe to the repo notifications...
I will check your CMakeLists.txt files, let's talk at #55
Louis Dionne
@ldionne
Alright, thanks!
Louis Dionne
@ldionne

To everyone

Hana's formal review for entry into Boost will be taking place from Wednesday June 10 to Wednesday June 24.
If you have the time and interest to do so, please consider reviewing the library or providing some feedback on the Boost.Devel mailing list. Any kind of constructive feedback is greatly appreciated.

The library's repository is at https://github.com/ldionne/hana.
The documentation is at http://ldionne.github.io/hana.
GitHub issues are available at https://github.com/ldionne/hana/issues.

You are encouraged to open GitHub issues for any problem you might encounter with the library, typo in the documentation, etc. I try to be very responsive to those.

Manu Sánchez
@Manu343726
Hi Louis, it's too late to send a formal review right?
Louis Dionne
@ldionne
Technically, yes because the review was until June 24. However, I think Glen (my review manager) would have the right to still consider your review.
Manu Sánchez
@Manu343726
Ok I will try to have a review ready for tomorrow afternoon if possible. I'm sad I could not follow hana's formal review as I would have liked to. Anyway, I will be glad to collaborate on Hana during my free time as long as my help has some value for the lib . Tmp posts and experiments are fun, but Hana is much more useful than whatever project may raise from these. Also I have th
Manu Sánchez
@Manu343726
I noticed a little typo on the docs. At the quickstart, just after the template_ lifter definition:

and it also provides a generic lifter for MPL metafunction classes names metafunction_class.

It's "named" right?

Louis Dionne
@ldionne
@Manu343726 Thanks; fixed
Manu Sánchez
@Manu343726
Hi Louis, I'm playing with Concepts TS using gcc trunk and it looks very promising. It supports auto unconstrained type in function parameters and constraints in lambda parameters. Also finally error messages are self-explanatory. Sadly the Integral trick above still doesn't work, constraints are applied to types only, seems not to have value template parameters in mind.
Louis Dionne
@ldionne
That’s sad, but at the same time I can understand that concepts only apply to types, at least conceptually. It would be a nice hack to be able to apply them to compile-time values, but that’s really just an abuse.
Louis Dionne
@ldionne
@Manu343726 At any rate, I’m currently looking at the possibility of converting Hana’s concepts to constexpr bool functions, and getting rid of the models<> metafunction. This way, one could write something like:
template <hana::Sequence S>
void my_function(S const& s) {
    // works with std::tuple, hana::tuple and anything which satisfies the concept
}
When Concepts are there, of course.
gnzlbg
@gnzlbg

@ldionne hi louis, do you happen to know how to enable automatic pushing of documentation to github pages?

I can figure out from your travis build script that I need to have a gh-pages branch in my repo, and a github token, do I have to do something specific the first time I initialize it?