These are chat archives for boostorg/hana

22nd
Jan 2016
Jason Rice
@ricejasonf
Jan 22 2016 00:00
I have a spitball idea about making the buckets themselves maps as they are now.
... and making maps chainable
I have an actual use case where I need a many-to-one relationship.
Louis Dionne
@ldionne
Jan 22 2016 00:01
In my view, buckets would be maps as they are now (tuples of pairs with linear search).
What do you mean, chainable?
Jason Rice
@ricejasonf
Jan 22 2016 00:03
consider this: { set(path1, path2) => provider }
I want to get the instance of provider by path1 or path2 as keys.
I'll probably just make an ad-hoc solution to this, but it sounds like the same solution could be used for maps/buckets.
So say that map had three possible representations: type_map, comparable_map, and map_composition or something like that.
so make_map would return a map_composition(type_map, comparable_map)
and the raw type_map could be used for cases where keys are strictly types for performance.
Louis Dionne
@ldionne
Jan 22 2016 00:12
Well, comparable_map really is just a tuple of pairs, and you search it on(first).
We could create a generic map_composition, but I would definitely suggest tackling the problem of the map before trying to generalize.
Jason Rice
@ricejasonf
Jan 22 2016 00:17
ok
Louis Dionne
@ldionne
Jan 22 2016 00:18
Well I mean, if you find that it is easier and simpler to use a map_composition, go ahead, but I would think that using an ad-hoc solution would be simpler for a start.
Are we on the same page regarding collisions, buckets and the need for x == y to imply that hash(x) == hash(y)?
Jason Rice
@ricejasonf
Jan 22 2016 00:20
I think so, but size_c<5> != int_c<5>
and hash(size_c<5>) == hash(int_c<5>)
I was trying to figure out why we are normalizing IntegralConstants to a common hash type.
Louis Dionne
@ldionne
Jan 22 2016 00:23
Ah fuck, you’re right that size_c<5> != int_c<5>, cause they can’t be compared because of signedness.
Which is also a problem because of #234.
Ok, but assuming that size_c<5> == int_c<5>, then are we on the same page?
The solution to this is actually quite easy: normalize all signed IntegralConstants to llong_c<…>, and all unsigned to ullong_c<…>.
Jason Rice
@ricejasonf
Jan 22 2016 00:26
Is there a case when ANY IntregralConstant<5> == IntregralConstant<5> ?
Louis Dionne
@ldionne
Jan 22 2016 00:26
I think this should work, right?
Jason Rice
@ricejasonf
Jan 22 2016 00:26
ahh
Louis Dionne
@ldionne
Jan 22 2016 00:27
Or, FWIW, they could also be normalized to some int_c<> and uint_c<…>, and then we’d simply get more collisons but it would still work (I think).
Jason Rice
@ricejasonf
Jan 22 2016 00:29
I think the collisions will be few and far between :P
but I get it now
Louis Dionne
@ldionne
Jan 22 2016 00:34
Ok. In the meantime, I’ll try to improve the benchmarks we have right now. One big problem is that the size of the maps we’re creating changes, so we’re really measuring the cost of creating the map + looking up, not only the cost of looking up.
Unfortunately, doing compile-time microbenchmarks is very f*cking difficult.
Jason Rice
@ricejasonf
Jan 22 2016 00:35
all the benchmarks?
Louis Dionne
@ldionne
Jan 22 2016 00:35
Well, basically all benchmarks have this problem, but I think I’ll start by the map ones.
Since we’re trying to improve it and that’ll help us right away.
Jason Rice
@ricejasonf
Jan 22 2016 01:51
On a somewhat unrelated note, I made my own append_if function. https://github.com/ricejasonf/nbdl/blob/master/test/mpdef/append_if.cpp
Simon Brand
@TartanLlama
Jan 22 2016 12:32
Hi everyone, I have a quick question about hana::when and the associated documentation.
The API states "when is used to control the priority of partial specializations in a finer grained manner than what can be achieved with the usual typename Enable = void and std::enable_if pattern. For example, a partially specialized tag-dispatched method will have a higher priority than an equivalent specialization that uses when."
I'm having trouble visualizing what that example looks like. Is there some corresponding code somewhere I could look at? I would certainly find it useful if the page had such code as it contains just a textual description.
Louis Dionne
@ldionne
Jan 22 2016 12:52
@TartanLlama See the end of the tutorial section on tag-dispatching. I’ll add a link to this section in the reference documentation; thanks for the heads up.
Simon Brand
@TartanLlama
Jan 22 2016 12:56
That's perfect, thanks!
Louis Dionne
@ldionne
Jan 22 2016 12:56
No problem. Don’t hesitate to let me know if you run into something else!
And thanks for trying the library out.