These are chat archives for boostorg/hana

20th
Dec 2017
Gleb Popov
@arrowd
Dec 20 2017 19:55

Hello. I'm using hana::transform on a hana::tuple to deserialize args pack using boost serialization:

    boost::hana::basic_tuple<Args...> t;

    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    {
        t = boost::hana::transform(t, [&](auto e) {
            ar >> e;
            return e;
        });
    }

This works, but in reversed order. That is, if my Args are, say, 1, 2, 3, they get deserialized into 3,2,1. Is it a bug, or I'm using tranform in a wrong way?

Alastair Rankine
@randomphrase
Dec 20 2017 20:06
What are you actually transforming here? Seems like no transformation is taking place, but the serialization is a side effect?
Maybe you want for_each, or possibly fold(t, ar, [] (auto& ar, auto& el) { return ar >> el; });
Gleb Popov
@arrowd
Dec 20 2017 20:11
@randomphrase Whoa, I completely missed that I can change lambda's argument to auto&. With that, for_each indeed does the job. Awesome, thanks.