These are chat archives for boostorg/hana

17th
Jan 2016
Maik Klein
@MaikKlein
Jan 17 2016 21:14
template <typename Iterable, typename T>
constexpr auto index_of(Iterable const& iterable, T const& element) {
  auto size = hana::size(iterable);
  auto dropped = decltype(
      hana::size(hana::drop_while(iterable, hana::not_equal.to(element)))){};
  return size - dropped;
}
template <typename Iterable, typename ...Ts>
constexpr auto indices_of(Iterable const& iterable, const Ts&...  elements) {
  return std::index_sequence<(index_of(iterable, elements)::value)...>{};
}

The problem is this line

  return std::index_sequence<(index_of(iterable, elements)::value)...>{};

Does :: not work with fold expressions?

Maik Klein
@MaikKlein
Jan 17 2016 21:25
oh nvm it actually returns std::size_t, thought it would return hana::size_t
Jason Rice
@ricejasonf
Jan 17 2016 23:42
hana::size returns an hana::integral_constant. To get the value from a size_c you can use hana::value(foo) or decltype(foo)::value.