These are chat archives for boostorg/hana

17th
Dec 2015
Louis Dionne
@ldionne
Dec 17 2015 12:55

Would it be possible to add that auto operator= to type and integral_constant?

You mean to create pairs? I think that's clearly out of Hana's scope, since Hana is a general purpose library, not a named parameter library. The right approach would be for you to create wrappers over type and integral_constant. Or more generally, I would probably do something like

template <typename Param>
struct param_t {
    // define operator=
};

template <typename Param>
constexpr param_t<Param> param{};

Then, you can use the thing as

f(param<hana::int_<3>> = "three", param<hana::type<int>> = "int", ...);

The syntactic overhead is very reasonable, and it clearly says what it's doing. Just my .02.

You mentioned some things about improving map before. I would like to discuss it, when you are not too busy.

I'd be happy to discuss it. I'll try to put my thoughts on paper and I'll create an issue documenting them. Then, we can talk about it either here or on GitHub. Sounds reasonable?

Jason Rice
@ricejasonf
Dec 17 2015 17:38
:thumbsup:
Jason Rice
@ricejasonf
Dec 17 2015 17:48
About the param thing, yeah, creating a wrapper is simple enough and I will do that, but I was speaking to constructing maps in general. (nbd of course)
constexpr auto foo = hana::type_c<int>;
constexpr auto bar = hana::type_c<double>;

hana::make_map(
    foo       = "foo",
    bar       = "bar",
    "foo"_s   = "foo",
    "bar"_s   = "bar",
    5_c       = "five",
    42_c      = "forty-two"
);
that's probably not that useful though
Louis Dionne
@ldionne
Dec 17 2015 17:55

But then the following fails, because assignment is not what we expect it to be:

hana::tuple<int, int, hana::type<char>> t{1, 2, {}};
hana::tuple<int, int, hana::type<char>> u{3, 4, {}};
t = u;

Actually, it will even compile but fail to do the right thing. Since type, integral_constant & al are stateless this is OK strictly speaking (assignment has no effect anyway), but I really think this is conceptually wrong.

Jason Rice
@ricejasonf
Dec 17 2015 18:06
yeah I guess that would be an abuse :sweat_smile:
Louis Dionne
@ldionne
Dec 17 2015 21:32
@ricejasonf See #223 regarding hana::map optimizations.
@ricejasonf It’s not an easy one to tackle, but if you’re willing to give it a shot I’ll provide guidance and help as needed.
Btw, this is likely the single most important improvement that can be done to Hana right now. But it’s a chunk of work.
Jason Rice
@ricejasonf
Dec 17 2015 22:09
@ldionne Yes, I definitely want to take a crack at this. :D I'll have to do some digging as to how you are automating benchmarks and their results.
Louis Dionne
@ldionne
Dec 17 2015 22:17
Just ask if you need guidance.