These are chat archives for boostorg/hana

19th
Oct 2015
Louis Dionne
@ldionne
Oct 19 2015 13:37
Test message after transferring the repository to boostorg.
Andreas Pokorny
@APokorny
Oct 19 2015 15:11
@ldionne: I have been struggling with having user defined types as keys in boost::hana::map - I run into a static_assert saying that the comparison must be possible at compile time. I did implement constexpr bool operator== for combintations of (I believe) all of them.
Louis Dionne
@ldionne
Oct 19 2015 15:28
@APokorny You must return an integral_constant<bool, …> from your comparison operator, not a constexpr bool.
Louis Dionne
@ldionne
Oct 19 2015 15:35
#include <boost/hana.hpp>
namespace hana = boost::hana;

template <int i>
struct _int {
    template <int a, int b>
    friend constexpr auto operator==(_int<a>, _int<b>) {
        return hana::bool_c<a == b>;
    }

    template <int a, int b>
    friend constexpr auto operator!=(_int<a>, _int<b>) {
        return hana::bool_c<a != b>;
    }
};

auto m = hana::make_map(
    hana::make_pair(_int<0>{}, 0),
    hana::make_pair(_int<1>{}, 1)
);

auto zero = m[_int<0>{}];
This works for me.
Also note that making the operator== and operator!= constexpr is not necessary, as long as they return IntegralConstants.
Andreas Pokorny
@APokorny
Oct 19 2015 16:50
Oh why not bool if the value could be picked at ct - will switch those to IntegralConstants..
Andreas Pokorny
@APokorny
Oct 19 2015 16:58
Btw due to abi issues in Ubuntu 15.10 i use gcc again 5.2.1 seems to be fine fort hana
Louis Dionne
@ldionne
Oct 19 2015 17:07
GCC 5.2.1 might be able to compile some of it, but I’m pretty sure that some tests will break. Can you please run make check and let me know if that works?
Also, regarding your question, do you mind if I turn it into a StackOverflow answer so that everybody can benefit?
Louis Dionne
@ldionne
Oct 19 2015 17:33
@APokorny I went ahead and answered your question here. Let me know if that solves your problem.