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
Louis Dionne
@ldionne
I think it would work if make_partial did not decay the arguments
Since X would be a reference type (some T&), and then X&& would be T& &&, which collapses to T& by reference collapsing rules.
Barrett Adair
@badair
That makes sense
Same logic as std::forward
Louis Dionne
@ldionne
Yyes.
Barrett Adair
@badair
Wouldn't you still need to move-construct from rvalue references? For safety? And then re-move on the re-forward?
Or probably const ref on the re-forward
That's a difficult decision, since you can't bind crefs to rrefs, but you can do the opposite. So it depends on the signature of the hosted callable
Right?
Did that make sense?
Louis Dionne
@ldionne
partial would only hold references, and it would assume that whatever the references point to are in scope for the whole lifetime of the partial object. So there would be no need to move-construct any actual objects. One way to think of it is like if partial was holding pointers to external objects. No need to move construct anything there.
Now, if you had const refs and you did not use decay when creating partial_t<…>, you would end up with T const& &&, which collapses to T const&, and it would still work. At least, AFAICT.
Note that we wouldn’t be using std::cref or std::ref at all to implement this.
Barrett Adair
@badair
When are destructors called on prvalues? E.g. the second argument to hana::partial(f, foo{})
That was my concern
You know more about storing references to rvalues than I do.
Barrett Adair
@badair
And yes, we are on the same page - i meant for "cref" to be shorthand for const lvalue reference, not the library function. That was confusing
Louis Dionne
@ldionne
Ok, in hana::partial(f, foo{}), hana::partial would store a rvalue-reference to the foo{} temporary. Of course, this reference is valid exactly until the temporary is destructed. However, the lifetime of a temporary is until the end of the enclosing expression. So, for example, consider some_algorithm(sequence, hana::partial(f, foo{})). hana::partial holds a rvalue reference to the foo{} temporary. Then, this partial is used by some_algorithm, which is fine because the temporary is still in scope. Then, the algorithm returns and the temporary goes out of scope, which is fine.
Basically, what you couldn’t do if we stored rvalue references in partial is the following: auto p = hana::partial(f, foo{}); use(p);. This is because by the time p is used (and hence the rvalue reference to foo{} accessed), foo{} has gone out of scope.
Barrett Adair
@badair
Ok, that's what I thought. So you just wouldn't keep the partial object around. Got it
Louis Dionne
@ldionne
Right.
That is, at least, my understanding of temporary lifetime.
But I could be wrong. C++ is complicated :)
Barrett Adair
@badair
Indeed. I wasn't sure if it was expression-level or scope-level for prvalues.
Louis Dionne
@ldionne
I’m pretty sure it’s expression-level.
Barrett Adair
@badair
I wonder whether it would be nice to enable the use to specify the forward semantics with a wrapper function. Such as hana::partial(f, hana::move_then_copy(foo{})); Or even a generic function taking a template tag. Verbose, but granular, and could be specialized over the existing impl.
*the user
That allows for customization over "copy only" partial/"ref only" partial. Just an idea
Barrett Adair
@badair
Users who happen to need more granularity than the existing implementation will probably appreciate that
Louis Dionne
@ldionne
I have one thing in mind. We could allow hana::partial(f, std::ref(x)) to store a reference instead of a reference_wrapper. If we supported the special semantics for make_xxx(std::ref(…)) discussed in boostorg/hana#176, it would be very easy to implement this in hana::partial (because hana::partial stores the arguments in a tuple). However, this hits the same wall as #176, which is storing references in containers at all.
Jason Rice
@ricejasonf
Wouldn't it also be a problem if f was actually expecting an std::ref(x)?
Barrett Adair
@badair
I would be tempted to file that in the "too bad" folder :)
Jason Rice
@ricejasonf
I guess you could do hana::partial(hana::make_pair, hana::dont_unwrap_me(std::ref(x))) :P
Louis Dionne
@ldionne
Well, you can construct a std::reference_wrapper<T> from a T&, so it would work.
Jason Rice
@ricejasonf
ahh
Barrett Adair
@badair
I didn't realize the conversion worked both ways
Jason Rice
@ricejasonf
are you saying that f would do that?
Louis Dionne
@ldionne
Yes, it does. And both are implicit.
@ricejasonf I’m just saying that if f takes a reference_wrapper, and partial turns reference_wrappers into actual refs, then f would be called with actual refs.
But it would be fine, since (what I said).
Maik Klein
@MaikKlein
Is it possible to get compile time timers for code blocks?
START_CT_TIMER
//some code
END_CT_TIMER
No idea how I should profile my code. I have a function that takes up 2 sec and I compile it several times :(.
Maik Klein
@MaikKlein
Actually I don't think the thing I am trying to do is feasible in C++ at all, which makes me quite sad.
Barrett Adair
@badair
Not without compiler hooks
AFAIK
Louis Dionne
@ldionne
@MaikKlein No, that’s impossible. You have to try and isolate what is taking up compile-time, and then fix this.
Basically, just reduce the example until you have a small amount of code that shows the 2s compile-time.
Jason Rice
@ricejasonf
I've read in places that it is best practice to not pass primitive types by const& and instead just pass by value. If that is correct, does that mean the same should be done for empty or near empty types like hana::type?
http://stackoverflow.com/questions/10770410/reasons-to-not-pass-simple-types-by-reference?lq=1
Jason Rice
@ricejasonf
If I use const& it allocates 8 bytes instead of 1
Jason Rice
@ricejasonf
Sorry, please disregard all of that. It appears to be pretty trivial. (though unpacking a tuple of 100 types does call alloc align 8 100 times, but there is not noticeable difference)