Boost logo

Boost :

Subject: Re: [boost] [Hana] Announcing Hana's formal review next week (June 10th)
From: Larry Evans (cppljevans_at_[hidden])
Date: 2015-06-13 06:43:54


On 06/09/2015 11:00 AM, Louis Dionne wrote:
[snip]
>
> Indeed, you are using a Map when what you really want is a Tuple, since
> your keys are integers. Here's the version I would have written:
>
> #include <boost/hana/integral_constant.hpp>
> #include <boost/hana/range.hpp>
> #include <boost/hana/tuple.hpp>
> using namespace boost::hana;
>
> static constexpr int map_size = 100;
>
> void run() {
> constexpr auto hana_range = range(int_<0>, int_<map_size>);
> auto hana_tuple = unpack(hana_range, [](auto ...n) {
> return tuple_t<std::array<char, decltype(n)::value>...>;
> });
>
> auto Array = hana_tuple[int_<69>];
>
> // instantiate the array
> constexpr decltype(Array)::type arr = {{0}};
> static_assert(sizeof(arr) == 69, "");
> }
>
> However, I can easily imagine another example where you actually need the
> functionality of a Map. See below for performance comments.
>
[snip]
Why couldn't map be implemented as a tuple, as shown here:

https://gist.github.com/cppljevans/8e545e8d83946cd74311

Wouldn't that eliminate the difference in performance between
map and tuple?

-regards,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk