These are chat archives for boostorg/hana

11th
Dec 2015
Jason Rice
@ricejasonf
Dec 11 2015 00:00
Yes, thanks for your help. I like how Hana is organized, but what is the rationale for separating declaration/definition with the fwd header files?
Jason Rice
@ricejasonf
Dec 11 2015 00:34
nm. found it in doc/tutorial.hpp
Louis Dionne
@ldionne
Dec 11 2015 00:43
Really, did I document that?
Anyway, the rationale is so that we can #include lightweight declarations instead of full blown definitions when only a declaration is requried. This can help with compile times. Also, it’s necessary for some circularly-dependent stuff.
Jason Rice
@ricejasonf
Dec 11 2015 00:44
Yes, under "Header Organization" in the doc menu.
aha
Louis Dionne
@ldionne
Dec 11 2015 00:46
And finally, I think it makes for a nice separation between interface and implementation, and also it gives a place to systematically put documentation. Since the implementation is sometimes hairy, I think it’s nice not to entangle the documentation with it.
Jason Rice
@ricejasonf
Dec 11 2015 00:48
oh I get it fwd is for "forward" declaration :laughing:
Louis Dionne
@ldionne
Dec 11 2015 00:49
Yes, yes. Lol, that would have been a strange idea otherwise.
Jason Rice
@ricejasonf
Dec 11 2015 20:31
I was thinking that I could use a function that returns int_c as a predicate. What am I doing wrong here?
#include<boost/hana.hpp>

namespace hana = boost::hana;

int main()
{
  static_assert(hana::find_if(hana::make_tuple(
      hana::make_tuple(),
      hana::make_tuple(),
      hana::make_tuple(hana::int_c<0>, hana::int_c<1>),
      hana::make_tuple()), hana::length)
        ==
      hana::just(hana::make_tuple(hana::int_c<0>, hana::int_c<1>)), "");
}
/usr/local/include/boost/hana/detail/index_if.hpp:56:50: error: implicit instantiation of undefined
      template 'boost::hana::detail::index_if<const boost::hana::length_t &,
      boost::hana::detail::pack<boost::hana::tuple<boost::hana::integral_constant<int, 0>,
      boost::hana::integral_constant<int, 1> >, boost::hana::tuple<> >, boost::hana::when<true> >'
        static constexpr std::size_t value = 1 + index_if<Pred, pack<Ts...>>::value;
Jason Rice
@ricejasonf
Dec 11 2015 20:37
trying to rule out "operator" abuse here :laughing: get it?
Louis Dionne
@ldionne
Dec 11 2015 20:40
Can you please create an issue?
Jason Rice
@ricejasonf
Dec 11 2015 20:43
k, just wanted to make sure there wasn't something glaringly obvious here
[integral_constant] ??
Louis Dionne
@ldionne
Dec 11 2015 20:45
Well, it’s because your predicate does not return a boolean.
I’m not a fan of returning an int from a predicate, but it should probably still work.
Yeah, it should work cause int is a Logical.
Jason Rice
@ricejasonf
Dec 11 2015 20:46
"the predicate has to return an IntegralConstant holding a value that can be converted to bool" - from find_if
Louis Dionne
@ldionne
Dec 11 2015 20:47
Right, then it’s a bug.
Just open an issue on GitHub to document the problem (basically paste your above code). I’ll commit a fix in a minute.
Jason Rice
@ricejasonf
Dec 11 2015 20:52
cool!
Jason Rice
@ricejasonf
Dec 11 2015 21:59
I could add more checks to that test to check all functions that take a predicate (in cases where it makes sense)
unless you think that is a big can of worms
Louis Dionne
@ldionne
Dec 11 2015 22:00
No, I would love that actually.
There shouldn’t be too much code changes required to make it work. It probably just requires sprinkling a couple of static_cast<bool>s around.
If you have the time, make a PR. Otherwise, I’ll check it out when my exams are done.
Jason Rice
@ricejasonf
Dec 11 2015 22:03
:D I do, but it might be tomorrow. I'll see if I can fix any of them that might be broken.
Louis Dionne
@ldionne
Dec 11 2015 22:04
Cool, thanks!