These are chat archives for boostorg/hana

8th
Mar 2016
hia3
@hia3
Mar 08 2016 09:52
I've tried zip_with, but had 2 issues: (1) function can't return void (so I had to return 42. I'd expect zip_with to return void if function returns void); (2) since it is "pure", function applied in reverse order and this is bad for performance in my case. Am I allowed to call non-const functions of arguments of the function (to modify input sequences of zip_with)?
hia3
@hia3
Mar 08 2016 11:26
I'd like to tuple1[N].call(tuple2[N]); where tuple1 and tuple2 are of same size and 'call' is void non-const function. Can I do this with hana?
Jason Rice
@ricejasonf
Mar 08 2016 16:07
@hia3 You could use hana::for_each on an iterable of Ns.
#include<boost/hana.hpp>

namespace hana = boost::hana;

int main() {
    auto xs = hana::make_tuple(1, 2, 3);
    auto ys = hana::make_tuple(1, 2, 3);
    hana::for_each(hana::range_c<int, 0, hana::length(xs)>,
        [&](auto i) {
            //xs[i].call(ys[i]);
            xs[i] += ys[i];
        });

    BOOST_HANA_RUNTIME_ASSERT(xs == hana::make_tuple(2, 4, 6));
}
hia3
@hia3
Mar 08 2016 18:15
@ricejasonf Thank you! Looks like raw for loop :-)
Jason Rice
@ricejasonf
Mar 08 2016 18:33
np
Jason Rice
@ricejasonf
Mar 08 2016 19:37
@ldionne I'm kind of on the fence about #260 lmk what you think :)
Louis Dionne
@ldionne
Mar 08 2016 19:49
@hia3 What Jason says is the correct way to go. It would be very difficult for the implementation to provide guarantees for impure function objects, so you should do any mutation explicitly.
@ricejasonf I gtg now, I’ll have a look at #260 in more details later.
Jason Rice
@ricejasonf
Mar 08 2016 20:05
cool
Jason Rice
@ricejasonf
Mar 08 2016 23:13
It would be awesome to be able to create tags on the fly without having to define them anywhere. I'm tempted to use hana::string, but I'm guessing that would be a pretty big hit for something so simple. hana::int_ would do it but is not very descriptive. Is there anything like this in C++?
Jason Rice
@ricejasonf
Mar 08 2016 23:47
err.. or maybe my stuff is just needlessly complex :P